xctools 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/LICENSE +22 -0
 - data/README.md +36 -0
 - data/lib/xctools/agvtool.rb +8 -0
 - data/lib/xctools/version.rb +3 -0
 - data/lib/xctools/xcode_build.rb +116 -0
 - data/lib/xctools.rb +6 -0
 - metadata +64 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: ec3323bd32436ef729ee18fac50e286da1c13e7e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4a675015897e2abb5a160442489d8a2f5455befc
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9fdef60736a7653364ae3f244795650ecc960bd38caddcfe467a3d17d65abab48effceec2b42ec4b68e65516f0f48dd479c4902f98dda24937a99a120839091e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0bacc039a0914c45d2230b91baf9ae7365eeafa4140489d4721a27b42a0023f271c9718d78bd369e1d7be96b203b5b9f0e5696a77958e2d9c3b82a861533c92e
         
     | 
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2014 Anatoliy Plastinin
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # XcTools
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Collection of helpers for parsing Xcode CLI tools output.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            This is an extract from [ognivo gem](https://github.com/antlypls/ognivo).
         
     | 
| 
      
 6 
     | 
    
         
            +
            Originally code is based on a [shenzhen tool](https://github.com/nomad/shenzhen).
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                gem 'xctools'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                $ gem install xctools
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                XcTools::Agvtool.marketing_version
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                XcTools::XcodeBuild.info(workspace: 'Project.xcworkspace')
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                XcTools::XcodeBuild.settings("-workspace \"Project.xcworkspace\"")
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            1. Fork it ( https://github.com/antlypls/xctools/fork )
         
     | 
| 
      
 33 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 34 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 35 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 36 
     | 
    
         
            +
            5. Create a new Pull Request
         
     | 
| 
         @@ -0,0 +1,116 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # based on source code from nomad/shenzhen project
         
     | 
| 
      
 2 
     | 
    
         
            +
            # see https://github.com/nomad/shenzhen/blob/master/lib/shenzhen/xcodebuild.rb
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            require 'ostruct'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module XcTools
         
     | 
| 
      
 7 
     | 
    
         
            +
              module XcodeBuild
         
     | 
| 
      
 8 
     | 
    
         
            +
                Error = Class.new(StandardError)
         
     | 
| 
      
 9 
     | 
    
         
            +
                NilOutputError = Class.new(Error)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                Info = Class.new(OpenStruct)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                class Settings < Hash
         
     | 
| 
      
 14 
     | 
    
         
            +
                  def initialize(hash = {})
         
     | 
| 
      
 15 
     | 
    
         
            +
                    merge!(hash)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def find_app
         
     | 
| 
      
 19 
     | 
    
         
            +
                    values.find { |settings| settings['WRAPPER_EXTENSION'] == 'app' }
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                def self.info(*args)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  options = args.last.is_a?(Hash) ? args.pop : {}
         
     | 
| 
      
 25 
     | 
    
         
            +
                  cmd_args = (args + args_from_options(options)).join(' ')
         
     | 
| 
      
 26 
     | 
    
         
            +
                  output = `xcodebuild -list #{cmd_args} 2>&1`
         
     | 
| 
      
 27 
     | 
    
         
            +
                  fail Error, $1 if output =~ /^xcodebuild\: error\: (.+)$/
         
     | 
| 
      
 28 
     | 
    
         
            +
                  fail NilOutputError unless output =~ /\S/
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  info = parse_info_output(output)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  Info.new(info)
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                def self.parse_info_output(output)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  lines = output.split(/\n/)
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  project_name = parse_info_project_name(lines.first)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  info, _ = lines.drop(1).reduce([{}, nil]) do |(info, group), line|
         
     | 
| 
      
 40 
     | 
    
         
            +
                    parse_info_line(line, info, group)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  info.each do |_, values|
         
     | 
| 
      
 44 
     | 
    
         
            +
                    values.delete('')
         
     | 
| 
      
 45 
     | 
    
         
            +
                    values.uniq!
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  info.merge(project: project_name)
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                def self.parse_info_project_name(line)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  $1 if line =~ /\"(.+)\"\:/
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                def self.parse_info_line(line, info, group)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  if line =~ /\:$/
         
     | 
| 
      
 57 
     | 
    
         
            +
                    group = line.strip[0...-1].downcase.gsub(/\s+/, '_')
         
     | 
| 
      
 58 
     | 
    
         
            +
                    info[group] = []
         
     | 
| 
      
 59 
     | 
    
         
            +
                  else
         
     | 
| 
      
 60 
     | 
    
         
            +
                    info[group] << line.strip unless group.nil? || line =~ /\.$/
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  [info, group]
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
                private_class_method :parse_info_line
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                def self.settings(*args)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  options = args.last.is_a?(Hash) ? args.pop : {}
         
     | 
| 
      
 69 
     | 
    
         
            +
                  cmd_args = (args + args_from_options(options)).join(' ')
         
     | 
| 
      
 70 
     | 
    
         
            +
                  output = `xcodebuild #{cmd_args} -showBuildSettings 2> /dev/null`
         
     | 
| 
      
 71 
     | 
    
         
            +
                  fail Error, $1 if output =~ /^xcodebuild\: error\: (.+)$/
         
     | 
| 
      
 72 
     | 
    
         
            +
                  fail NilOutputError unless output =~ /\S/
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                  settings = parse_settings_output(output)
         
     | 
| 
      
 75 
     | 
    
         
            +
                  Settings.new(settings)
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                def self.parse_settings_output(output)
         
     | 
| 
      
 79 
     | 
    
         
            +
                  lines = output.split(/\n/)
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  lines.reduce([{}, nil]) do |(settings, target), line|
         
     | 
| 
      
 82 
     | 
    
         
            +
                    parse_settings_line(line, settings, target)
         
     | 
| 
      
 83 
     | 
    
         
            +
                  end.first
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                def self.parse_settings_line(line, settings, target)
         
     | 
| 
      
 87 
     | 
    
         
            +
                  case line
         
     | 
| 
      
 88 
     | 
    
         
            +
                  when /Build settings for action build and target \"?([^":]+)/
         
     | 
| 
      
 89 
     | 
    
         
            +
                    target = $1
         
     | 
| 
      
 90 
     | 
    
         
            +
                    settings[target] = {}
         
     | 
| 
      
 91 
     | 
    
         
            +
                  else
         
     | 
| 
      
 92 
     | 
    
         
            +
                    key, value = line.split(/\=/).map(&:strip)
         
     | 
| 
      
 93 
     | 
    
         
            +
                    settings[target][key] = value if target
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                  [settings, target]
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
      
 98 
     | 
    
         
            +
                private_class_method :parse_settings_line
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                def self.version
         
     | 
| 
      
 101 
     | 
    
         
            +
                  output = `xcodebuild -version`
         
     | 
| 
      
 102 
     | 
    
         
            +
                  parse_xcode_version(output)
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                def self.parse_xcode_version(output)
         
     | 
| 
      
 106 
     | 
    
         
            +
                  $1 if output =~ /([\d+\.?]+)/
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                def self.args_from_options(options = {})
         
     | 
| 
      
 110 
     | 
    
         
            +
                  options
         
     | 
| 
      
 111 
     | 
    
         
            +
                    .reject { |_, value| value.nil? }
         
     | 
| 
      
 112 
     | 
    
         
            +
                    .map { |key, value| "-#{key} '#{value}'" }
         
     | 
| 
      
 113 
     | 
    
         
            +
                end
         
     | 
| 
      
 114 
     | 
    
         
            +
                private_class_method :args_from_options
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
      
 116 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/xctools.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: xctools
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Anatoliy Plastinin
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-10-14 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.6'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.6'
         
     | 
| 
      
 27 
     | 
    
         
            +
            description: Helpers for parsing Xcode CLI tools output.
         
     | 
| 
      
 28 
     | 
    
         
            +
            email:
         
     | 
| 
      
 29 
     | 
    
         
            +
            - hello@antlypls.com
         
     | 
| 
      
 30 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 31 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 32 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 33 
     | 
    
         
            +
            files:
         
     | 
| 
      
 34 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 35 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/xctools.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/xctools/agvtool.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - lib/xctools/version.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - lib/xctools/xcode_build.rb
         
     | 
| 
      
 40 
     | 
    
         
            +
            homepage: https://github.com/antlypls/xctools
         
     | 
| 
      
 41 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 42 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 43 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 44 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 45 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 46 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 48 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 50 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 51 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 52 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 53 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 54 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 55 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 56 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 57 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 58 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 59 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 60 
     | 
    
         
            +
            rubygems_version: 2.4.1
         
     | 
| 
      
 61 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 62 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 63 
     | 
    
         
            +
            summary: Helpers for parsing Xcode CLI tools output.
         
     | 
| 
      
 64 
     | 
    
         
            +
            test_files: []
         
     |