xbuild 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +114 -0
- data/Rakefile +2 -0
- data/bin/xbuild +6 -0
- data/lib/xbuild/cli.rb +102 -0
- data/lib/xbuild/runner.rb +132 -0
- data/lib/xbuild/version.rb +3 -0
- data/lib/xbuild.rb +6 -0
- data/spec/runner_spec.rb +172 -0
- data/spec/spec_helper.rb +11 -0
- data/xbuild.gemspec +28 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 548d1300c7687e2c95aee2805131f3a6a50ae0fa
|
4
|
+
data.tar.gz: 9006f9c42de7419e08672a0414ffc8dbac1fb80d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8b209fff927e63d315a015d1a878241125bfe96ca892550c5cfeb33aad8ffc91e06596dbb2875dfb7730b3a66dbe21f61fc29531bf3d286817a58aa69c9dea05
|
7
|
+
data.tar.gz: 125a0ffe58609d7a33ebd41fb409a36e23bd499e976030a4ff7c7229332cdaf34550cb82d300db0e734228fca56273e9a081e7874645a730416569f4a64acfdb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.2
|
data/.travis.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
os:
|
2
|
+
- osx
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
rvm:
|
6
|
+
# OS X 10.9.5-10.10.0 (2.0.0-p481)
|
7
|
+
- system
|
8
|
+
# OS X 10.9.3-10.9.4
|
9
|
+
- 2.0.0-p451
|
10
|
+
# OS X 10.9.0-10.9.2
|
11
|
+
# TODO: currently unavailable: https://github.com/travis-ci/travis-ci/issues/2918
|
12
|
+
# - 2.0.0-p247
|
13
|
+
|
14
|
+
before_install:
|
15
|
+
# There is a bug in travis. When using system ruby, bundler is not
|
16
|
+
# installed and causes the default install action to fail.
|
17
|
+
- sudo gem install bundler
|
18
|
+
|
19
|
+
script: bundle exec rspec spec
|
20
|
+
|
21
|
+
addons:
|
22
|
+
code_climate:
|
23
|
+
repo_token: 495c653a664ee0f8d94acd821498d39571bb9b19550f13e0283fafc74f1b254
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Guido Marucci Blas
|
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,114 @@
|
|
1
|
+
# XBuild
|
2
|
+
|
3
|
+
[![CI Status](https://travis-ci.org/guidomb/xbuild.svg?branch=master)](https://travis-ci.org/guidomb/xbuild)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/guidomb/xbuild/badges/gpa.svg)](https://codeclimate.com/github/guidomb/xbuild)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/guidomb/xbuild/badges/coverage.svg)](https://codeclimate.com/github/guidomb/xbuild)
|
6
|
+
|
7
|
+
|
8
|
+
**XBuild** is a thin wrapper on top of `xcodebuild` and `xctool` that allows you to configure your favorite iOS & Mac build tool for your project.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'xbuild'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install xbuild
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
xbuild [OPTIONS] ACTION [WORKSPACE] [SCHEME]
|
29
|
+
|
30
|
+
Parameters:
|
31
|
+
ACTION The build action to be run. (clean|build|test|archive|analyze|install)
|
32
|
+
[WORKSPACE] Sets the project's workspace.
|
33
|
+
[SCHEME] Sets the project's scheme.
|
34
|
+
|
35
|
+
Options:
|
36
|
+
-x, --dry-run Runs all the process without actually calling the build tool.
|
37
|
+
-p, --pretty Uses xcpretty to format build output (only when using xcodebuild).
|
38
|
+
-v, --verbose Enables verbose mode.
|
39
|
+
-F, --xctool Uses xctool instead of xcodebuild as the build tool.
|
40
|
+
-h, --help print help
|
41
|
+
|
42
|
+
|
43
|
+
You can have a `.xbuild.yml` on the current working directory where you run `xbuild`
|
44
|
+
command is run. In this file you can configure the options, workspace and scheme. Here
|
45
|
+
is an example:
|
46
|
+
|
47
|
+
```yaml
|
48
|
+
dry_run: false
|
49
|
+
pretty: false
|
50
|
+
verbose: true
|
51
|
+
xctool: true
|
52
|
+
scheme: MyProjectShared
|
53
|
+
workspace: MyProject.xcworkspace
|
54
|
+
```
|
55
|
+
|
56
|
+
Options and arguments passed through the command line have more precedence that the
|
57
|
+
ones defined in the `.xbuild.yml` file.
|
58
|
+
|
59
|
+
The `scheme` and `workspace` arguments are mandatory and must be defined either using
|
60
|
+
the `.xbuild.yml` or through the command line.
|
61
|
+
|
62
|
+
### Action arguments
|
63
|
+
|
64
|
+
You can configure action arguments to be included for a specific action in your `.xbuild.yml`. For example lets say that you want to add the arguments `-foo 1 -bar 2` for the `build` action. You should defined those actions like this"
|
65
|
+
|
66
|
+
```yaml
|
67
|
+
dry_run: true
|
68
|
+
pretty: true
|
69
|
+
verbose: true
|
70
|
+
xctool: false
|
71
|
+
scheme: MyProjectShared
|
72
|
+
workspace: MyProject.xcworkspace
|
73
|
+
action_arguments:
|
74
|
+
build:
|
75
|
+
foo: 1
|
76
|
+
bar: 2
|
77
|
+
```
|
78
|
+
|
79
|
+
When you run the `xbuild` command with the previous `.xbuild.yml` you will get the following output:
|
80
|
+
|
81
|
+
XBuild::Runner: Executing command 'set -o pipefail && xcodebuild -workspace MyProject.xcworkspace -scheme MyProjectShared build -foo 1 -bar 2 | xcpretty -c'
|
82
|
+
|
83
|
+
|
84
|
+
## Contributing
|
85
|
+
|
86
|
+
1. Fork it ( https://github.com/guidomb/xbuild/fork )
|
87
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
88
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
89
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
90
|
+
5. Create a new Pull Request
|
91
|
+
|
92
|
+
## License
|
93
|
+
|
94
|
+
**XBuild** is available under the MIT [license](https://raw.githubusercontent.com/guidomb/xbuild/master/LICENSE).
|
95
|
+
|
96
|
+
Copyright (c) 2014 Guido Marucci Blas <guidomb@gmail.com.ar>
|
97
|
+
|
98
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
99
|
+
of this software and associated documentation files (the "Software"), to deal
|
100
|
+
in the Software without restriction, including without limitation the rights
|
101
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
102
|
+
copies of the Software, and to permit persons to whom the Software is
|
103
|
+
furnished to do so, subject to the following conditions:
|
104
|
+
|
105
|
+
The above copyright notice and this permission notice shall be included in
|
106
|
+
all copies or substantial portions of the Software.
|
107
|
+
|
108
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
109
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
110
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
111
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
112
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
113
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
114
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/xbuild
ADDED
data/lib/xbuild/cli.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'clamp'
|
2
|
+
require 'yaml'
|
3
|
+
require 'xbuild'
|
4
|
+
|
5
|
+
module XBuild
|
6
|
+
|
7
|
+
class CLI < Clamp::Command
|
8
|
+
|
9
|
+
CONFIG_FILE_NAME = ".xbuild.yml"
|
10
|
+
|
11
|
+
option ["-x", "--dry-run"],
|
12
|
+
:flag,
|
13
|
+
"Runs all the process without actually calling the build tool.",
|
14
|
+
argument_name: :dry_run
|
15
|
+
option ["-p", "--pretty"],
|
16
|
+
:flag,
|
17
|
+
"Uses xcpretty to format build output (only when using xcodebuild).",
|
18
|
+
argument_name: :pretty
|
19
|
+
option ["-v", "--verbose"],
|
20
|
+
:flag,
|
21
|
+
"Enables verbose mode.",
|
22
|
+
argument_name: :verbose
|
23
|
+
option ["-F", "--xctool"],
|
24
|
+
:flag,
|
25
|
+
"Uses xctool instead of xcodebuild as the build tool.",
|
26
|
+
argument_name: :xctool
|
27
|
+
|
28
|
+
parameter "ACTION", "The build action to be run. (#{Runner::ACTIONS.join("|")})"
|
29
|
+
parameter "[WORKSPACE]", "Sets the project's workspace."
|
30
|
+
parameter "[SCHEME]", "Sets the project's scheme."
|
31
|
+
|
32
|
+
def execute
|
33
|
+
parse_config_file!
|
34
|
+
validate!
|
35
|
+
exit(1) unless runner.run(action)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def validate!
|
41
|
+
[:workspace, :scheme].each do |parameter|
|
42
|
+
if send(parameter).nil?
|
43
|
+
puts "Error: Parameter '#{parameter}' must be set either using '#{CONFIG_FILE_NAME}' or through command line."
|
44
|
+
exit(1)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def parse_config_file!
|
50
|
+
return unless File.exist?(CONFIG_FILE_NAME)
|
51
|
+
config = load_yaml_file(CONFIG_FILE_NAME)
|
52
|
+
set_parameter_value(config, :workspace)
|
53
|
+
set_parameter_value(config, :scheme)
|
54
|
+
# clan's default options are not used
|
55
|
+
# because if a config file is defined
|
56
|
+
# we want command line options to
|
57
|
+
# have precedence over options defined
|
58
|
+
# in the config file. That is why
|
59
|
+
# default value are manually applied
|
60
|
+
# after merging config file options
|
61
|
+
# with command line options
|
62
|
+
@options = default_options.merge(config.merge(options))
|
63
|
+
end
|
64
|
+
|
65
|
+
def options
|
66
|
+
return @options if @options
|
67
|
+
@options = {}
|
68
|
+
@options[:dry_run] = dry_run? unless dry_run?.nil?
|
69
|
+
@options[:verbose] = verbose? unless verbose?.nil?
|
70
|
+
@options[:pretty] = pretty? unless pretty?.nil?
|
71
|
+
@options[:xctool] = xctool? unless xctool?.nil?
|
72
|
+
@options
|
73
|
+
end
|
74
|
+
|
75
|
+
def default_options
|
76
|
+
{
|
77
|
+
dry_run: false,
|
78
|
+
verbose: false,
|
79
|
+
pretty: true,
|
80
|
+
xctool: false
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
def runner
|
85
|
+
@runner ||= Runner.new(workspace, scheme, options)
|
86
|
+
end
|
87
|
+
|
88
|
+
def load_yaml_file(file)
|
89
|
+
yaml = YAML.load_file(file)
|
90
|
+
Hash[yaml.map{ |k, v| [k.to_sym, v] }]
|
91
|
+
end
|
92
|
+
|
93
|
+
def set_parameter_value(config, parameter)
|
94
|
+
value = config.delete(parameter)
|
95
|
+
if send(parameter).nil?
|
96
|
+
instance_variable_set("@#{parameter}", value)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
module XBuild
|
2
|
+
|
3
|
+
class SystemCommandExecutor
|
4
|
+
|
5
|
+
def execute(command)
|
6
|
+
system(command)
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
class Runner
|
12
|
+
|
13
|
+
ACTIONS = %w(
|
14
|
+
clean
|
15
|
+
build
|
16
|
+
test
|
17
|
+
archive
|
18
|
+
analyze
|
19
|
+
install
|
20
|
+
)
|
21
|
+
|
22
|
+
DEFAULT_ACTION_ARGUMENTS = {
|
23
|
+
'test' => {
|
24
|
+
'sdk' => 'iphonesimulator'
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
attr_reader :workspace, :scheme, :command_executor, :action_arguments
|
29
|
+
|
30
|
+
def initialize(workspace, scheme, opts = {})
|
31
|
+
@workspace = workspace
|
32
|
+
@scheme = scheme
|
33
|
+
opts = {verbose: false, dry_run: false, pretty: true, xctool: false}.merge(opts)
|
34
|
+
@pretty = opts[:pretty]
|
35
|
+
@verbose = opts[:verbose]
|
36
|
+
@dry_run = opts[:dry_run]
|
37
|
+
@xctool = opts[:xctool]
|
38
|
+
@action_arguments = opts[:action_arguments] || {}
|
39
|
+
@command_executor = opts[:command_executor] || SystemCommandExecutor.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def xctool?
|
43
|
+
@xctool
|
44
|
+
end
|
45
|
+
|
46
|
+
def pretty?
|
47
|
+
!xctool? && @pretty
|
48
|
+
end
|
49
|
+
|
50
|
+
def run(action, arguments = {}, options = {})
|
51
|
+
success = false
|
52
|
+
if valid_action?(action)
|
53
|
+
options = default_base_options.merge(options)
|
54
|
+
arguments = merge_action_arguments(action, arguments)
|
55
|
+
command = build_command(action, arguments, options)
|
56
|
+
success = execute(command)
|
57
|
+
else
|
58
|
+
raise "Invalid action #{action}"
|
59
|
+
end
|
60
|
+
success
|
61
|
+
end
|
62
|
+
|
63
|
+
def dry_run?
|
64
|
+
@dry_run
|
65
|
+
end
|
66
|
+
|
67
|
+
def verbose?
|
68
|
+
@verbose
|
69
|
+
end
|
70
|
+
|
71
|
+
ACTIONS.each do |action|
|
72
|
+
define_method(action) do |*args|
|
73
|
+
run(action, *args)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def merge_action_arguments(action, arguments)
|
80
|
+
args = action_arguments.fetch(action, {}).merge(arguments)
|
81
|
+
DEFAULT_ACTION_ARGUMENTS.fetch(action, {}).merge(args)
|
82
|
+
end
|
83
|
+
|
84
|
+
def build_command(action, arguments, options)
|
85
|
+
options = to_options_string(options)
|
86
|
+
arguments = to_options_string(arguments)
|
87
|
+
cmd = "#{build_tool}#{options} #{action}#{arguments}".strip
|
88
|
+
cmd = pipe_xcpretty(cmd) if pretty?
|
89
|
+
cmd
|
90
|
+
end
|
91
|
+
|
92
|
+
def build_tool
|
93
|
+
if xctool?
|
94
|
+
"xctool"
|
95
|
+
else
|
96
|
+
"xcodebuild"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def execute(command)
|
101
|
+
log("Executing command '#{command}'")
|
102
|
+
command_executor.execute(command) unless dry_run?
|
103
|
+
end
|
104
|
+
|
105
|
+
def valid_action?(action)
|
106
|
+
ACTIONS.include?(action)
|
107
|
+
end
|
108
|
+
|
109
|
+
def log(message)
|
110
|
+
puts "#{self.class}: #{message}" if verbose?
|
111
|
+
end
|
112
|
+
|
113
|
+
def default_base_options
|
114
|
+
@default_base_options ||= { workspace: workspace, scheme: scheme }
|
115
|
+
end
|
116
|
+
|
117
|
+
def pipe_xcpretty(cmd)
|
118
|
+
"set -o pipefail && #{cmd} | xcpretty -c"
|
119
|
+
end
|
120
|
+
|
121
|
+
def to_options_string(options = {})
|
122
|
+
options.reduce("") do |options_string, (key, value)|
|
123
|
+
if value
|
124
|
+
options_string + " -#{key} #{value}"
|
125
|
+
else
|
126
|
+
options_string + " -#{key}"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
data/lib/xbuild.rb
ADDED
data/spec/runner_spec.rb
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe XBuild::Runner do
|
4
|
+
|
5
|
+
subject(:xbuild) { XBuild::Runner.new(workspace, scheme, options) }
|
6
|
+
|
7
|
+
let(:project) { "SpecProject" }
|
8
|
+
let(:scheme) { project }
|
9
|
+
let(:workspace) { "#{project}.xcworkspace" }
|
10
|
+
let(:command_executor) { double("command_executor") }
|
11
|
+
let(:pretty) { false }
|
12
|
+
let(:dry_run) { false }
|
13
|
+
let(:action) { XBuild::Runner::ACTIONS.sample }
|
14
|
+
let(:options) do
|
15
|
+
{
|
16
|
+
xctool: build_tool == "xctool",
|
17
|
+
command_executor: command_executor,
|
18
|
+
pretty: pretty,
|
19
|
+
dry_run: dry_run
|
20
|
+
}
|
21
|
+
end
|
22
|
+
let(:command_for_task) do
|
23
|
+
->(task) do
|
24
|
+
cmd = "#{build_tool} -workspace #{workspace} -scheme #{scheme} #{task}"
|
25
|
+
cmd += " -sdk iphonesimulator" if task == "test"
|
26
|
+
cmd
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
shared_examples "a build tool runner" do
|
31
|
+
|
32
|
+
XBuild::Runner::ACTIONS.each do |action|
|
33
|
+
|
34
|
+
describe "##{action}" do
|
35
|
+
it "executes the #{action} task" do
|
36
|
+
expect(command_executor).to receive(:execute).with(command_for_task[action])
|
37
|
+
xbuild.send(action)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#run" do
|
44
|
+
|
45
|
+
context "when the action is valid" do
|
46
|
+
|
47
|
+
it "executes the action" do
|
48
|
+
expect(command_executor).to receive(:execute).with(command_for_task[action])
|
49
|
+
xbuild.run(action)
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when arguments are present" do
|
53
|
+
|
54
|
+
let(:arguments) { {foo: 1, bar:2, baz: nil} }
|
55
|
+
|
56
|
+
it "executes the action with the given arguments" do
|
57
|
+
expect(command_executor).to receive(:execute).with(match(/^.* #{action} .*-foo 1 -bar 2 -baz.*$/))
|
58
|
+
xbuild.run(action, arguments)
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when xbuild was initialized with arguments for the given action" do
|
62
|
+
|
63
|
+
let(:options) do
|
64
|
+
{
|
65
|
+
xctool: build_tool == "xctool",
|
66
|
+
command_executor: command_executor,
|
67
|
+
pretty: pretty,
|
68
|
+
dry_run: dry_run,
|
69
|
+
action_arguments: {
|
70
|
+
action => {
|
71
|
+
:foo => 4,
|
72
|
+
:jaz => nil
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
it "combines both arguments" do
|
79
|
+
expect(command_executor).to receive(:execute).with(match(/^.* #{action} .*-foo 1 -jaz -bar 2 -baz.*$/))
|
80
|
+
xbuild.run(action, arguments)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when options are present" do
|
88
|
+
|
89
|
+
let(:arguments) { {} }
|
90
|
+
let(:build_options) { {foo: 1, bar:2, baz: nil} }
|
91
|
+
|
92
|
+
it "executes the action with the given options" do
|
93
|
+
expect(command_executor).to receive(:execute).with(match(/^.* -foo 1 -bar 2 -baz.* #{action}.*$/))
|
94
|
+
xbuild.run(action, arguments, build_options)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when the command executor returns true" do
|
100
|
+
|
101
|
+
before(:each) { allow(command_executor).to receive(:execute).and_return(true) }
|
102
|
+
|
103
|
+
it "returns true" do
|
104
|
+
expect(xbuild.run(action)).to be_truthy
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when the command executor returns false" do
|
110
|
+
|
111
|
+
before(:each) { allow(command_executor).to receive(:execute).and_return(false) }
|
112
|
+
|
113
|
+
it "returns false" do
|
114
|
+
expect(xbuild.run(action)).to be_falsy
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
context "when XBuild's option 'dry_run' is true" do
|
120
|
+
|
121
|
+
let(:dry_run) { true }
|
122
|
+
|
123
|
+
it "does not call the command executor" do
|
124
|
+
expect(command_executor).not_to receive(:execute)
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
context "when the action is invalid" do
|
132
|
+
|
133
|
+
it "raises an error" do
|
134
|
+
expect { xbuild.run("foo") }.to raise_error("Invalid action foo")
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
context "when using xctool as the build tool" do
|
144
|
+
|
145
|
+
let(:build_tool) { "xctool" }
|
146
|
+
it_behaves_like "a build tool runner"
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
context "when using xcodebuild as the build tool" do
|
151
|
+
|
152
|
+
let(:build_tool) { "xcodebuild" }
|
153
|
+
it_behaves_like "a build tool runner"
|
154
|
+
|
155
|
+
describe "#run" do
|
156
|
+
|
157
|
+
context "when XBuild's option 'pretty' is true" do
|
158
|
+
|
159
|
+
let(:pretty) { true }
|
160
|
+
|
161
|
+
it "uses xcpretty to format the output" do
|
162
|
+
expect(command_executor).to receive(:execute).with(match(/^set -o pipefail && xcodebuild .* | xcpretty -c$/))
|
163
|
+
xbuild.run(action)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/xbuild.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'xbuild/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "xbuild"
|
8
|
+
spec.version = Xbuild::VERSION
|
9
|
+
spec.authors = ["Guido Marucci Blas"]
|
10
|
+
spec.email = ["guidomb@gmail.com"]
|
11
|
+
spec.summary = %q{A wrapper over xcodebuild and xctool }
|
12
|
+
spec.description = %q{XBuild is a thin wrapper on top of xcodebuild and xctool that allows you to configure your favorite iOS & Mac build tool for your project.}
|
13
|
+
spec.homepage = "https://github.com/guidomb/xbuild"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
24
|
+
spec.add_development_dependency "byebug", "~> 3.5.1"
|
25
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
26
|
+
|
27
|
+
spec.add_dependency "clamp", "~>0.6.3"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xbuild
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guido Marucci Blas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-07 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.5.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.5.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: clamp
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.6.3
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.6.3
|
97
|
+
description: XBuild is a thin wrapper on top of xcodebuild and xctool that allows
|
98
|
+
you to configure your favorite iOS & Mac build tool for your project.
|
99
|
+
email:
|
100
|
+
- guidomb@gmail.com
|
101
|
+
executables:
|
102
|
+
- xbuild
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".ruby-version"
|
109
|
+
- ".travis.yml"
|
110
|
+
- Gemfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/xbuild
|
115
|
+
- lib/xbuild.rb
|
116
|
+
- lib/xbuild/cli.rb
|
117
|
+
- lib/xbuild/runner.rb
|
118
|
+
- lib/xbuild/version.rb
|
119
|
+
- spec/runner_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- xbuild.gemspec
|
122
|
+
homepage: https://github.com/guidomb/xbuild
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.2.2
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: A wrapper over xcodebuild and xctool
|
146
|
+
test_files:
|
147
|
+
- spec/runner_spec.rb
|
148
|
+
- spec/spec_helper.rb
|