Module: XcTools::XcodeBuild
- Defined in:
- lib/xctools/xcode_build.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 32 |
# File 'lib/xctools/xcode_build.rb', line 23 def self.info(*args) = args.last.is_a?(Hash) ? args.pop : {} cmd_args = (args + ()).join(' ') output = `xcodebuild -list #{cmd_args} 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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/xctools/xcode_build.rb', line 34 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
51 52 53 |
# File 'lib/xctools/xcode_build.rb', line 51 def self.parse_info_project_name(line) $1 if line =~ /\"(.+)\"\:/ end |
.parse_settings_output(output) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/xctools/xcode_build.rb', line 78 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
105 106 107 |
# File 'lib/xctools/xcode_build.rb', line 105 def self.parse_xcode_version(output) $1 if output =~ /([\d+\.?]+)/ end |
.settings(*args) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/xctools/xcode_build.rb', line 67 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
100 101 102 103 |
# File 'lib/xctools/xcode_build.rb', line 100 def self.version output = `xcodebuild -version` parse_xcode_version(output) end |