Sha256: f09999023649ca56fcb2e697779d5fafc3b03e422ecc1935db074dba63d111e9

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'xcodeide/io_scanner'
require 'xcodeide/obj_node'
require 'xcodeide/arr_node'


module XcodeIDE

  class Project
    
    def initialize(package)
      @package = package
      @file = package + '/project.pbxproj'
      parse
    end
    
    def configurations
      @pbx.configurations
    end
    
    private
      def parse
        File.open(@file) do |io|
          @pbx = PBX.load(io)
        end
      end
    
  end
  
  
  class PBX
    def self.load(io)
      ios = IOScanner.new(io)
      
      token = ios.tokenize
      raise "Unable to deserialize root object." if token != ?{
      
      pbx = PBX.new
      pbx.parse(io)
      pbx
    end
    
    def initialize
      @root = nil
    end
    
    def configurations
      configs = []
      
      objects = @root['objects']
      objects.each do |key, value|
        if value.is_a == 'PBXBuildStyle' || value.is_a == 'XCBuildConfiguration'
          configs << value['name']
        end
      end
      
      return configs.uniq
    end
    
    def parse(io)
      @root = ObjectNode.new(io)
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xcodeide-0.1.1 lib/xcodeide/project.rb
xcodeide-0.1.0 lib/xcodeide/project.rb