xcinvoke 0.1.0
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/.gitignore +8 -0
- data/.rubocop.yml +71 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +57 -0
- data/README.md +33 -0
- data/Rakefile +63 -0
- data/bin/console +11 -0
- data/bin/rake +16 -0
- data/bin/setup +7 -0
- data/lib/xcinvoke.rb +4 -0
- data/lib/xcinvoke/version.rb +3 -0
- data/lib/xcinvoke/xcode.rb +110 -0
- data/xcinvoke.gemspec +24 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5801a55bb74f9fc80bc999371bfa4076e9b7cf7b
|
4
|
+
data.tar.gz: 4d83ebf8936738acf25c676e600ffe234adb85e5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b317b87f5b74c579ab3977e5a0b7e6449069a5f59a0a32314cb0040d4f3a5382658a46998e764e3d20d1b27c4380fc3be7fe888612a775b21f0f1e3d01c62219
|
7
|
+
data.tar.gz: 1d060b6f26b1912d9d16f718297cbe92e6310331cd11653bc1c64f8ec73bce19faf396d2955e796c2e91ff978315ef4e0f608b41be1b6e1db651442da4f04d6b
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- ./Rakefile
|
4
|
+
- ./Gemfile
|
5
|
+
- ./*.gemspec
|
6
|
+
|
7
|
+
# At the moment not ready to be used
|
8
|
+
# https://github.com/bbatsov/rubocop/issues/947
|
9
|
+
Documentation:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
#- XCInvoke -----------------------------------------------------------------#
|
13
|
+
|
14
|
+
Metrics/LineLength:
|
15
|
+
Max: 100
|
16
|
+
|
17
|
+
# 20 lines is more reasonable than rubocop's default of 10
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Max: 20
|
20
|
+
|
21
|
+
# We adopted raise instead of fail.
|
22
|
+
SignalException:
|
23
|
+
EnforcedStyle: only_raise
|
24
|
+
|
25
|
+
# They are idiomatic
|
26
|
+
AssignmentInCondition:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
# Allow backticks
|
30
|
+
AsciiComments:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# Indentation clarifies logic branches in implementations
|
34
|
+
IfUnlessModifier:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
# No enforced convention here.
|
38
|
+
SingleLineBlockParams:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
# We only add the comment when needed.
|
42
|
+
Encoding:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
# Having these make it easier to *not* forget to add one when adding a new
|
46
|
+
# value and you can simply copy the previous line.
|
47
|
+
TrailingComma:
|
48
|
+
EnforcedStyleForMultiline: comma
|
49
|
+
|
50
|
+
Style/SpecialGlobalVars:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
#- XCInvoke specs -----------------------------------------------------------#
|
54
|
+
|
55
|
+
# Allow for `should.match /regexp/`.
|
56
|
+
AmbiguousRegexpLiteral:
|
57
|
+
Exclude:
|
58
|
+
- spec/**/*
|
59
|
+
|
60
|
+
# Allow `object.should == object` syntax.
|
61
|
+
Void:
|
62
|
+
Exclude:
|
63
|
+
- spec/**/*
|
64
|
+
|
65
|
+
ClassAndModuleChildren:
|
66
|
+
Exclude:
|
67
|
+
- spec/**/*
|
68
|
+
|
69
|
+
UselessComparison:
|
70
|
+
Exclude:
|
71
|
+
- spec/**/*
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in xcinvoke.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
# Code style
|
8
|
+
gem 'rubocop'
|
9
|
+
|
10
|
+
# Tests
|
11
|
+
gem 'bacon'
|
12
|
+
gem 'mocha'
|
13
|
+
gem 'mocha-on-bacon'
|
14
|
+
gem 'prettybacon'
|
15
|
+
gem 'webmock'
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
xcinvoke (0.1.0)
|
5
|
+
liferaft (~> 0.0.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.3.8)
|
11
|
+
ast (2.0.0)
|
12
|
+
astrolabe (1.3.1)
|
13
|
+
parser (~> 2.2)
|
14
|
+
bacon (1.2.0)
|
15
|
+
crack (0.4.2)
|
16
|
+
safe_yaml (~> 1.0.0)
|
17
|
+
liferaft (0.0.4)
|
18
|
+
metaclass (0.0.4)
|
19
|
+
mocha (1.1.0)
|
20
|
+
metaclass (~> 0.0.1)
|
21
|
+
mocha-on-bacon (0.2.2)
|
22
|
+
mocha (>= 0.13.0)
|
23
|
+
parser (2.2.2.6)
|
24
|
+
ast (>= 1.1, < 3.0)
|
25
|
+
powerpack (0.1.1)
|
26
|
+
prettybacon (0.0.2)
|
27
|
+
bacon (~> 1.2)
|
28
|
+
rainbow (2.0.0)
|
29
|
+
rake (10.4.2)
|
30
|
+
rubocop (0.32.1)
|
31
|
+
astrolabe (~> 1.3)
|
32
|
+
parser (>= 2.2.2.5, < 3.0)
|
33
|
+
powerpack (~> 0.1)
|
34
|
+
rainbow (>= 1.99.1, < 3.0)
|
35
|
+
ruby-progressbar (~> 1.4)
|
36
|
+
ruby-progressbar (1.7.5)
|
37
|
+
safe_yaml (1.0.4)
|
38
|
+
webmock (1.21.0)
|
39
|
+
addressable (>= 2.3.6)
|
40
|
+
crack (>= 0.3.2)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
bacon
|
47
|
+
bundler (~> 1.10)
|
48
|
+
mocha
|
49
|
+
mocha-on-bacon
|
50
|
+
prettybacon
|
51
|
+
rake (~> 10.0)
|
52
|
+
rubocop
|
53
|
+
webmock
|
54
|
+
xcinvoke!
|
55
|
+
|
56
|
+
BUNDLED WITH
|
57
|
+
1.10.6
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# XCInvoke
|
2
|
+
|
3
|
+
XCInvoke is a tiny gem that makes managing Xcode versions a breeze.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'xcinvoke'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install xcinvoke
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/segiddins/xcinvoke.
|
data/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#-- Bootstrap --------------------------------------------------------------#
|
2
|
+
|
3
|
+
desc 'Initializes your working copy to run the specs'
|
4
|
+
task :bootstrap do
|
5
|
+
if system('which bundle')
|
6
|
+
title 'Installing gems'
|
7
|
+
sh 'bundle install'
|
8
|
+
|
9
|
+
title 'Updating submodules'
|
10
|
+
sh 'git submodule update --init --recursive'
|
11
|
+
else
|
12
|
+
$stderr.puts "\033[0;31m" \
|
13
|
+
"[!] Please install the bundler gem manually:\n" \
|
14
|
+
' $ [sudo] gem install bundler' \
|
15
|
+
"\e[0m"
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
begin
|
21
|
+
require 'bundler/gem_tasks'
|
22
|
+
require 'fileutils'
|
23
|
+
|
24
|
+
task default: :spec
|
25
|
+
|
26
|
+
#-- Specs ------------------------------------------------------------------#
|
27
|
+
|
28
|
+
desc 'Run specs'
|
29
|
+
task :spec do
|
30
|
+
title 'Running Unit Tests'
|
31
|
+
files = FileList['spec/**/*_spec.rb']
|
32
|
+
.exclude('spec/integration_spec.rb').shuffle.join(' ')
|
33
|
+
sh "bundle exec bacon #{files}"
|
34
|
+
|
35
|
+
title 'Checking Style Conformance'
|
36
|
+
Rake::Task['rubocop'].invoke
|
37
|
+
end
|
38
|
+
|
39
|
+
#-- RuboCop ----------------------------------------------------------------#
|
40
|
+
|
41
|
+
require 'rubocop/rake_task'
|
42
|
+
RuboCop::RakeTask.new(:rubocop)
|
43
|
+
|
44
|
+
rescue LoadError, NameError => e
|
45
|
+
$stderr.puts "\033[0;31m" \
|
46
|
+
'[!] Some Rake tasks haven been disabled because the environment' \
|
47
|
+
' couldn’t be loaded. Be sure to run `rake bootstrap` first.' \
|
48
|
+
"\e[0m"
|
49
|
+
$stderr.puts e.message
|
50
|
+
$stderr.puts e.backtrace
|
51
|
+
$stderr.puts
|
52
|
+
end
|
53
|
+
|
54
|
+
#-- Helpers ------------------------------------------------------------------#
|
55
|
+
|
56
|
+
def title(title)
|
57
|
+
cyan_title = "\033[0;36m#{title}\033[0m"
|
58
|
+
puts
|
59
|
+
puts '-' * 80
|
60
|
+
puts cyan_title
|
61
|
+
puts '-' * 80
|
62
|
+
puts
|
63
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'xcinvoke'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require 'irb'
|
11
|
+
IRB.start
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/setup
ADDED
data/lib/xcinvoke.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'liferaft'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
module Liferaft
|
5
|
+
class Version
|
6
|
+
unless instance_methods.include?(:other)
|
7
|
+
def <=>(other)
|
8
|
+
if self == other
|
9
|
+
0
|
10
|
+
elsif self < other
|
11
|
+
-1
|
12
|
+
else
|
13
|
+
1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module XCInvoke
|
21
|
+
class Xcode
|
22
|
+
extend Enumerable
|
23
|
+
|
24
|
+
attr_reader :developer_dir
|
25
|
+
|
26
|
+
def initialize(path)
|
27
|
+
@developer_dir = Pathname(path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.selected
|
31
|
+
dir, = Open3.capture2('xcode-select', '-p', err: '/dev/null')
|
32
|
+
new(dir.strip)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.each(&blk)
|
36
|
+
xcodes, = Open3.capture2('mdfind',
|
37
|
+
"kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'",
|
38
|
+
err: '/dev/null')
|
39
|
+
xcodes = xcodes.split("\n").map(&:strip)
|
40
|
+
xcodes = xcodes.map do |xc|
|
41
|
+
xc = Pathname(xc) + 'Contents/Developer'
|
42
|
+
new(xc)
|
43
|
+
end
|
44
|
+
xcodes.each(&blk)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.all
|
48
|
+
to_a
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.find_swift_version(swift_version)
|
52
|
+
select { |xc| xc.swift_version == swift_version }.sort.last
|
53
|
+
end
|
54
|
+
|
55
|
+
def swift_version
|
56
|
+
info = swift_info
|
57
|
+
info.first if info
|
58
|
+
end
|
59
|
+
|
60
|
+
def build_number
|
61
|
+
info = xcodebuild_info
|
62
|
+
info[1] if info
|
63
|
+
end
|
64
|
+
|
65
|
+
def version
|
66
|
+
Liferaft::Version.new(build_number)
|
67
|
+
end
|
68
|
+
|
69
|
+
def <=>(other)
|
70
|
+
version <=> other.version
|
71
|
+
end
|
72
|
+
|
73
|
+
def xcrun(cmd, env: {})
|
74
|
+
env = env.merge(as_env)
|
75
|
+
cmd = %w(xcrun) + cmd
|
76
|
+
output, = Open3.capture2(env, *cmd, err: '/dev/null')
|
77
|
+
output
|
78
|
+
end
|
79
|
+
|
80
|
+
def as_env
|
81
|
+
{
|
82
|
+
'DEVELOPER_DIR' => developer_dir.to_path,
|
83
|
+
'DYLD_FRAMEWORK_PATH' => dyld_framework_path.to_path,
|
84
|
+
'DYLD_LIBRARY_PATH' => dyld_library_path.to_path,
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def dyld_framework_path
|
89
|
+
developer_dir + 'Toolchains/XcodeDefault.xctoolchain/usr/lib'
|
90
|
+
end
|
91
|
+
|
92
|
+
def dyld_library_path
|
93
|
+
developer_dir + 'Toolchains/XcodeDefault.xctoolchain/usr/lib'
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def xcodebuild_info
|
99
|
+
xcodebuild_info_regex = /\AXcode (.*?)\s*Build version (.*?)\s*\Z/i
|
100
|
+
return unless xcrun(%w(xcodebuild -version)) =~ xcodebuild_info_regex
|
101
|
+
[Regexp.last_match(1), Regexp.last_match(2)]
|
102
|
+
end
|
103
|
+
|
104
|
+
def swift_info
|
105
|
+
swift_info_regex = /Swift version ([\d\.]+) \(swift(?:lang)?-([\d\.]+)/i
|
106
|
+
return unless xcrun(%w(swift --version)) =~ swift_info_regex
|
107
|
+
[Regexp.last_match(1), Regexp.last_match(2)]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/xcinvoke.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'xcinvoke/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'xcinvoke'
|
8
|
+
spec.version = XCInvoke::VERSION
|
9
|
+
spec.authors = ['Samuel E. Giddins']
|
10
|
+
spec.email = ['segiddins@segiddins.me']
|
11
|
+
|
12
|
+
spec.summary = 'Manage Xcode versions with ease!'
|
13
|
+
spec.homepage = 'https://github.com/segiddins/xcinvoke'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = 'exe'
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'liferaft', '~> 0.0.4'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xcinvoke
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel E. Giddins
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: liferaft
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- segiddins@segiddins.me
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rubocop.yml"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CHANGELOG.md
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/rake
|
72
|
+
- bin/setup
|
73
|
+
- lib/xcinvoke.rb
|
74
|
+
- lib/xcinvoke/version.rb
|
75
|
+
- lib/xcinvoke/xcode.rb
|
76
|
+
- xcinvoke.gemspec
|
77
|
+
homepage: https://github.com/segiddins/xcinvoke
|
78
|
+
licenses: []
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.4.8
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Manage Xcode versions with ease!
|
100
|
+
test_files: []
|