Module: Ognivo::XcodeBuild
- Defined in:
- lib/ognivo/xcodebuild.rb
Defined Under Namespace
Classes: Settings
Constant Summary collapse
- Error =
Class.new(StandardError)
- NilOutputError =
Class.new(Error)
- Info =
Class.new(OpenStruct)
Class Method Summary collapse
- .info(*args) ⇒ Object
- .parse_info_output(output) ⇒ Object
- .parse_info_project_name(line) ⇒ Object
- .parse_settings_output(output) ⇒ Object
- .parse_xcode_version(output) ⇒ Object
- .settings(*args) ⇒ Object
- .version ⇒ Object
Class Method Details
.info(*args) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/ognivo/xcodebuild.rb', line 23 def self.info(*args) = args.last.is_a?(Hash) ? args.pop : {} output = `xcodebuild -list #{(args + args_from_options(options)).join(' ')} 2>&1` fail Error, $1 if output =~ /^xcodebuild\: error\: (.+)$/ fail NilOutputError unless output =~ /\S/ info = parse_info_output(output) Info.new(info) end |
.parse_info_output(output) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ognivo/xcodebuild.rb', line 33 def self.parse_info_output(output) lines = output.split(/\n/) project_name = parse_info_project_name(lines.first) info, _ = lines.drop(1).reduce([{}, nil]) do |(info, group), line| parse_info_line(line, info, group) end info.each do |_, values| values.delete('') values.uniq! end info.merge(project: project_name) end |
.parse_info_project_name(line) ⇒ Object
50 51 52 |
# File 'lib/ognivo/xcodebuild.rb', line 50 def self.parse_info_project_name(line) $1 if line =~ /\"(.+)\"\:/ end |
.parse_settings_output(output) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/ognivo/xcodebuild.rb', line 77 def self.parse_settings_output(output) lines = output.split(/\n/) lines.reduce([{}, nil]) do |(settings, target), line| parse_settings_line(line, settings, target) end.first end |
.parse_xcode_version(output) ⇒ Object
104 105 106 |
# File 'lib/ognivo/xcodebuild.rb', line 104 def self.parse_xcode_version(output) $1 if output =~ /([\d+\.?]+)/ end |
.settings(*args) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ognivo/xcodebuild.rb', line 66 def self.settings(*args) = args.last.is_a?(Hash) ? args.pop : {} cmd_args = (args + ()).join(' ') output = `xcodebuild #{cmd_args} -showBuildSettings 2> /dev/null` fail Error, $1 if output =~ /^xcodebuild\: error\: (.+)$/ fail NilOutputError unless output =~ /\S/ settings = parse_settings_output(output) Settings.new(settings) end |
.version ⇒ Object
99 100 101 102 |
# File 'lib/ognivo/xcodebuild.rb', line 99 def self.version output = `xcodebuild -version` parse_xcode_version(output) end |