Module: Mesmerize::XcodeBuildInfo

Defined in:
lib/mesmerize/xcodebuildinfo.rb

Defined Under Namespace

Classes: Error, Info, NilOutputError

Class Method Summary collapse

Class Method Details

.infoObject

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mesmerize/xcodebuildinfo.rb', line 10

def info
  output = `xcodebuild -list 2> /dev/null`
  raise Error.new $1 if /^xcodebuild\: error\: (.+)$/ === output
  raise NilOutputError unless /\S/ === output

  lines = output.split(/\n/)
  hash = {}
  group = nil

  hash[:project] = lines.shift.match(/\"(.+)\"\:/)[1]

  lines.each do |line|
    if /\:$/ === line
      group = line.strip[0...-1].downcase.gsub(/\s+/, '-')
      hash[group] = []
      next
    end

    unless group.nil? or /\.$/ === line
      hash[group] << line.strip
    end
  end

  Info.new(hash)
end

.versionObject



36
37
38
39
# File 'lib/mesmerize/xcodebuildinfo.rb', line 36

def version
  output = `xcodebuild -version`
  output.scan(/([\d\.?]+)/).flatten.first rescue nil
end