Sha256: 040028b44ce62917298364bd3878fe05c9ff8f83756772bd0b0b85b34d6ee893

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

require 'find'
require 'fileutils'
require "xcode/version"
require "xcode/project"
require "xcode/info_plist"

module Xcode
  @@projects = nil
  @@sdks = nil
  
  # def self.project(name)
  #   parse_projects if @@projects.nil?
  #   @@projects.each do |p|
  #     return p if p.name == name
  #   end
  #   raise "Unable to find project named #{name}"
  # end
  
  def self.find_projects(dir='.')
    parse_projects(dir)
  end

  def self.is_sdk_available?(sdk)
    parse_sdks if @@sdks.nil?
    @@sdks.values.include? sdk
  end
  
  def self.available_sdks
    parse_sdks if @@sdks.nil?
    @@sdks
  end
 
  private
  def self.parse_sdks
    @@sdks = {}
    parsing = false
    `xcodebuild -showsdks`.split("\n").each do |l|
      l.strip!
      if l=~/(.*)\s+SDKs:/
        parsing = true
      elsif l=~/^\s*$/
        parsing = false
      elsif parsing
        l=~/([^\t]+)\t+\-sdk (.*)/
        @@sdks[$1.strip] = $2.strip unless $1.nil? and $2.nil?
      end
    end
  end

  def self.parse_projects(dir='.')
    projects = []
    Find.find(dir) do |path|
      if path=~/(.*)\.xcodeproj$/
        projects << Xcode::Project.new(path)
      end
    end
    projects
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xcoder-0.0.6 lib/xcoder.rb
xcoder-0.0.5 lib/xcoder.rb
xcoder-0.0.4 lib/xcoder.rb
xcoder-0.0.3 lib/xcoder.rb
xcoder-0.0.2 lib/xcoder.rb
xcoder-0.0.1 lib/xcoder.rb