bowler 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bowler.rb +3 -1
- data/lib/bowler/cli.rb +39 -8
- data/lib/bowler/dependency_tree.rb +0 -4
- data/lib/bowler/version.rb +1 -1
- data/spec/cli_spec.rb +35 -0
- data/spec/dependency_tree_spec.rb +0 -8
- data/spec/helpers/cli_helper.rb +14 -0
- data/spec/spec_helper.rb +3 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34dce92fc34665431104d25780c2ee924d7798bf
|
4
|
+
data.tar.gz: 30fb9e9a5d122d746f1aec3dec9d5f96f5dce6c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f50128ef53e016098215488f39bec12caa1fadf6c6d8ef9dbb9038de687ffdca1b5f604ca2214294fa1ec85341ca9d154f0d1a159550a8da96af24a00e386bea
|
7
|
+
data.tar.gz: d2d92d904c36456adaf7889acf16d17abe72aeb2a84f68861c0d2c000cedbe8fc849daf8b04356ae3eb0aab9b410dd4a13f83d41804b24556921990c21a47cbd
|
data/lib/bowler.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'ostruct'
|
2
|
+
require 'bowler/version'
|
2
3
|
|
3
4
|
module Bowler
|
4
5
|
|
6
|
+
autoload :CLI, 'bowler/cli'
|
5
7
|
autoload :DependencyTree, 'bowler/dependency_tree'
|
6
8
|
autoload :DSL, 'bowler/dsl'
|
7
9
|
|
8
10
|
class PinfileNotFound < Exception; end
|
9
11
|
class PinfileError < Exception; end
|
10
12
|
|
11
|
-
end
|
13
|
+
end
|
data/lib/bowler/cli.rb
CHANGED
@@ -1,17 +1,38 @@
|
|
1
1
|
require 'logger'
|
2
|
+
require 'optparse'
|
2
3
|
|
3
4
|
module Bowler
|
4
5
|
class CLI
|
5
6
|
|
6
|
-
def self.start(
|
7
|
-
|
8
|
-
|
7
|
+
def self.start(args)
|
8
|
+
options = {
|
9
|
+
without: []
|
10
|
+
}
|
11
|
+
OptionParser.new {|opts|
|
12
|
+
opts.banner = "Usage: bowl [options] <process>..."
|
13
|
+
|
14
|
+
opts.on('-w', '--without <process>', 'Exclude a process from being launched') do |process|
|
15
|
+
options[:without] << process.to_sym
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
19
|
+
puts opts
|
20
|
+
exit
|
21
|
+
end
|
9
22
|
|
10
|
-
|
23
|
+
opts.on_tail('-v', '--version', 'Show the gem version') do
|
24
|
+
puts "Bowler #{Bowler::VERSION}"
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
}.parse!(args)
|
11
28
|
|
12
|
-
|
29
|
+
processes = args.map(&:to_sym)
|
30
|
+
|
31
|
+
tree = Bowler::DependencyTree.load
|
32
|
+
to_launch = tree.dependencies_for(processes) - options[:without]
|
33
|
+
logger.info "Starting #{to_launch.join(', ')}.."
|
13
34
|
|
14
|
-
start_foreman_with launch_string
|
35
|
+
start_foreman_with( launch_string(to_launch) )
|
15
36
|
rescue PinfileNotFound
|
16
37
|
logger.error "Bowler could not find a Pinfile in the current directory."
|
17
38
|
rescue PinfileError => e
|
@@ -19,14 +40,24 @@ module Bowler
|
|
19
40
|
end
|
20
41
|
|
21
42
|
def self.logger
|
22
|
-
|
43
|
+
@@logger ||= Logger.new(STDOUT)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.logger=(logger)
|
47
|
+
@@logger = logger
|
23
48
|
end
|
24
49
|
|
25
50
|
def self.build_command(launch_string)
|
26
51
|
"#{self.foreman_exec} start -c #{launch_string}"
|
27
52
|
end
|
28
53
|
|
29
|
-
|
54
|
+
private
|
55
|
+
def self.launch_string(processes)
|
56
|
+
processes.map {|process|
|
57
|
+
"#{process}=1"
|
58
|
+
}.sort.join(',')
|
59
|
+
end
|
60
|
+
|
30
61
|
def self.start_foreman_with(launch_string)
|
31
62
|
exec ( self.build_command launch_string )
|
32
63
|
end
|
data/lib/bowler/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -5,6 +5,8 @@ module Bowler
|
|
5
5
|
|
6
6
|
describe CLI do
|
7
7
|
|
8
|
+
include CLIHelper
|
9
|
+
|
8
10
|
context "build_command" do
|
9
11
|
it "should build a command from the launch string and the executable" do
|
10
12
|
CLI.expects(:foreman_exec).returns("fort")
|
@@ -33,6 +35,39 @@ module Bowler
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
38
|
+
context 'excluding an app' do
|
39
|
+
it 'removes a given app from the list of apps passed to Foreman' do
|
40
|
+
stub_dependency_tree(:myapp, :myapp2)
|
41
|
+
|
42
|
+
CLI.expects(:start_foreman_with).with('myapp2=1')
|
43
|
+
|
44
|
+
CLI.start(['myapp', 'myapp2', '--without', 'myapp'])
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'excludes more than one app from the list of apps passed to Foreman' do
|
48
|
+
stub_dependency_tree(:myapp, :myapp2, :myapp3)
|
49
|
+
|
50
|
+
CLI.expects(:start_foreman_with).with('myapp3=1')
|
51
|
+
|
52
|
+
CLI.start(['myapp', 'myapp2', 'myapp3', '--without', 'myapp', '--without', 'myapp2'])
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'supports the short-hand argument form Foreman' do
|
56
|
+
stub_dependency_tree(:myapp, :myapp2)
|
57
|
+
|
58
|
+
CLI.expects(:start_foreman_with).with('myapp2=1')
|
59
|
+
|
60
|
+
CLI.start(['myapp', 'myapp2', '-w', 'myapp'])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'starts foreman with the provided processes' do
|
65
|
+
stub_dependency_tree(:a, :b)
|
66
|
+
|
67
|
+
CLI.expects(:start_foreman_with).with('a=1,b=1')
|
68
|
+
|
69
|
+
CLI.start(['a', 'b'])
|
70
|
+
end
|
36
71
|
end
|
37
72
|
|
38
73
|
end
|
@@ -37,10 +37,6 @@ module Bowler
|
|
37
37
|
it "should find the correct dependencies" do
|
38
38
|
@tree.dependencies_for([:app1]).should =~ [:app2, :app3, :app1]
|
39
39
|
end
|
40
|
-
|
41
|
-
it "should give a correct process list" do
|
42
|
-
@tree.process_list_for([:app2]).should == "app2=1,app3=1"
|
43
|
-
end
|
44
40
|
end
|
45
41
|
|
46
42
|
context "given an array of multiple processes" do
|
@@ -51,10 +47,6 @@ module Bowler
|
|
51
47
|
it "should find the correct dependencies" do
|
52
48
|
@tree.dependencies_for([:app1, :other]).should =~ [:app2, :app3, :app1, :a, :b, :c, :other]
|
53
49
|
end
|
54
|
-
|
55
|
-
it "should give a correct process list" do
|
56
|
-
@tree.process_list_for([:app2, :other]).should == "a=1,app2=1,app3=1,b=1,c=1,other=1"
|
57
|
-
end
|
58
50
|
end
|
59
51
|
|
60
52
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Bowler
|
2
|
+
module CLIHelper
|
3
|
+
|
4
|
+
# stubs the behaviour of a tree with no dependencies, but stubs out all
|
5
|
+
# the dependency-lookup behaviour and Pinfile parsing
|
6
|
+
def stub_dependency_tree(*processes)
|
7
|
+
mock_tree = mock('Bowler::DependencyTree')
|
8
|
+
Bowler::DependencyTree.expects(:load).returns(mock_tree)
|
9
|
+
|
10
|
+
mock_tree.expects(:dependencies_for).with(processes).returns(processes)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bowler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hatch
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- spec/fixtures/dependency_tree_pinfile
|
103
103
|
- spec/fixtures/dsl_invalid_pinfile
|
104
104
|
- spec/fixtures/dsl_valid_pinfile
|
105
|
+
- spec/helpers/cli_helper.rb
|
105
106
|
- spec/helpers/definition_helper.rb
|
106
107
|
- spec/spec_helper.rb
|
107
108
|
homepage:
|
@@ -134,5 +135,6 @@ test_files:
|
|
134
135
|
- spec/fixtures/dependency_tree_pinfile
|
135
136
|
- spec/fixtures/dsl_invalid_pinfile
|
136
137
|
- spec/fixtures/dsl_valid_pinfile
|
138
|
+
- spec/helpers/cli_helper.rb
|
137
139
|
- spec/helpers/definition_helper.rb
|
138
140
|
- spec/spec_helper.rb
|