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