class Xcodeproj::Pbxproj::PbxObject::Pbxproj

Public Class Methods

new(path, stdout) click to toggle source
# File lib/xsort/xcodeproj/pbxproj/pbxobject/Pbxproj.rb, line 69
def initialize(path, stdout)
    @path = path
    @stdout = stdout
    @pbxGroups = Array.new
end

Public Instance Methods

parse() click to toggle source
# File lib/xsort/xcodeproj/pbxproj/pbxobject/Pbxproj.rb, line 75
def parse ()

    isPbxGroup = false
    isPbxOneValue = false
    isPbxChild = false
    pbxValue = ""

    begin
        File.open(@path, "r") do |pbx|
            pbx.each_line do |pbx_line|

                if @stdout == true
                    puts pbx_line
                end

                if pbx_line.index("/* End PBXGroup section */")
                    isPbxGroup = false
                end

                # In PBX Group
                if isPbxGroup == true

                    if pbx_line.index(");")
                        isPbxChild = false
                    end

                    if isPbxChild == true
                        name = Emurate.emurates(pbx_line)
                        @child = Xcodeproj::Pbxproj::PbxObject::PbxChild.new(name,pbx_line)
                        @group.setChildren(@child)
                    end

                    # Children
                    if pbx_line.index("children = (")
                        isPbxChild = true
                    end

                    if pbx_line.index(" = {")
                        isPbxOneValue = true
                        name = Emurate.emurates(pbx_line)
                        @group = Xcodeproj::Pbxproj::PbxObject::PbxGroup.new                                        
                    end

                    if isPbxOneValue == true
                        pbxValue << pbx_line
                    end

                    if pbx_line.index("};")
                        isPbxOneValue = false
                        @group.setPbxBase(pbxValue)
                        @pbxGroups.push(@group)
                        pbxValue = ""
                    end
                end

                if pbx_line.index("/* Begin PBXGroup section */")
                    isPbxGroup = true
                end
            end
        end
    rescue IOError => ioerr
        puts "Error #{ioerr.message}"
    rescue SystemCallError => sysCallErr
        puts "Failuer: reason #{sysCallErr.message}"
        puts "The entered path is invalid."
    end
end
pbxGroups() click to toggle source
# File lib/xsort/xcodeproj/pbxproj/pbxobject/Pbxproj.rb, line 143
def pbxGroups
    @pbxGroups
end