producer-core 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/producer/core/cli.rb +10 -14
- data/lib/producer/core/version.rb +1 -1
- data/spec/fixtures/recipes/some_recipe.rb +5 -0
- data/spec/producer/core/cli_spec.rb +22 -36
- 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: 890c789a5de327b39836f468441f8c75b890faeb
|
4
|
+
data.tar.gz: c524443e3b5882f32346b144a237bebdc60a477f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a21fe320fa3ac8c89c92c7def97284413ad31afd620784a255daeeb38fa8db1b005fc1f5db02cd55d801d4ba159985845a87e23addea989ce6a25aa42135629
|
7
|
+
data.tar.gz: d4d1389cfe3de827c45d2d6c0982644827d5356352699e2d41d8424772c17abb3d602c04e6b3d8aeacfee599de391c9fc33ddc1c2d245b71f70a63e66bb155f7
|
data/lib/producer/core/cli.rb
CHANGED
@@ -5,19 +5,22 @@ module Producer
|
|
5
5
|
|
6
6
|
USAGE = "Usage: #{File.basename $0} recipe_file"
|
7
7
|
|
8
|
+
EX_USAGE = 64
|
9
|
+
|
8
10
|
class << self
|
9
11
|
def run!(arguments, output: $stderr)
|
10
12
|
begin
|
11
13
|
cli = new(arguments)
|
12
14
|
rescue ArgumentError
|
13
15
|
output.puts USAGE
|
14
|
-
exit
|
16
|
+
exit EX_USAGE
|
15
17
|
end
|
16
|
-
cli.run
|
18
|
+
cli.run
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
22
|
attr_reader :arguments, :stdout
|
23
|
+
attr_accessor :recipe
|
21
24
|
|
22
25
|
def initialize(arguments, stdout: $stdout)
|
23
26
|
raise ArgumentError unless arguments.any?
|
@@ -25,20 +28,13 @@ module Producer
|
|
25
28
|
@stdout = stdout
|
26
29
|
end
|
27
30
|
|
28
|
-
def run
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def env
|
33
|
-
@env ||= Env.new
|
34
|
-
end
|
35
|
-
|
36
|
-
def recipe
|
37
|
-
@recipe ||= Recipe.evaluate_from_file(@arguments.first, env)
|
31
|
+
def run(worker: Interpreter.new)
|
32
|
+
load_recipe
|
33
|
+
worker.process recipe.tasks
|
38
34
|
end
|
39
35
|
|
40
|
-
def
|
41
|
-
@
|
36
|
+
def load_recipe
|
37
|
+
@recipe = Recipe.evaluate_from_file(@arguments.first, Env.new)
|
42
38
|
end
|
43
39
|
end
|
44
40
|
end
|
@@ -5,7 +5,7 @@ module Producer::Core
|
|
5
5
|
include ExitHelpers
|
6
6
|
include FixturesHelpers
|
7
7
|
|
8
|
-
let(:recipe_file) { fixture_path_for 'recipes/
|
8
|
+
let(:recipe_file) { fixture_path_for 'recipes/some_recipe.rb' }
|
9
9
|
let(:arguments) { [recipe_file] }
|
10
10
|
let(:stdout) { StringIO.new }
|
11
11
|
|
@@ -23,7 +23,7 @@ module Producer::Core
|
|
23
23
|
it 'runs the CLI' do
|
24
24
|
cli = double 'cli'
|
25
25
|
allow(CLI).to receive(:new) { cli }
|
26
|
-
expect(cli).to receive :run
|
26
|
+
expect(cli).to receive :run
|
27
27
|
run
|
28
28
|
end
|
29
29
|
|
@@ -69,51 +69,37 @@ module Producer::Core
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
describe '#
|
73
|
-
it '
|
74
|
-
|
75
|
-
|
76
|
-
cli.
|
72
|
+
describe '#recipe' do
|
73
|
+
it 'returns the assigned recipe' do
|
74
|
+
recipe = double 'recipe'
|
75
|
+
cli.recipe = recipe
|
76
|
+
expect(cli.recipe).to be recipe
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
describe '#
|
81
|
-
it '
|
82
|
-
|
83
|
-
cli.
|
80
|
+
describe '#run' do
|
81
|
+
it 'loads the recipe' do
|
82
|
+
cli.run
|
83
|
+
expect(cli.recipe).to be_a Recipe
|
84
84
|
end
|
85
85
|
|
86
|
-
it '
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
it 'process recipe tasks with given worker' do
|
87
|
+
worker = double 'worker'
|
88
|
+
expect(worker).to receive(:process).with [kind_of(Task), kind_of(Task)]
|
89
|
+
cli.run worker: worker
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
describe '#
|
94
|
-
it '
|
93
|
+
describe '#load_recipe' do
|
94
|
+
it 'evaluates the recipe file with an env' do
|
95
95
|
expect(Recipe)
|
96
|
-
.to receive(:evaluate_from_file).with(recipe_file,
|
97
|
-
cli.
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'returns the recipe' do
|
101
|
-
recipe = double('recipe').as_null_object
|
102
|
-
allow(Recipe).to receive(:new) { recipe }
|
103
|
-
expect(cli.recipe).to be recipe
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe '#interpreter' do
|
108
|
-
it 'builds a interpreter' do
|
109
|
-
expect(Interpreter).to receive :new
|
110
|
-
cli.interpreter
|
96
|
+
.to receive(:evaluate_from_file).with(recipe_file, kind_of(Env))
|
97
|
+
cli.load_recipe
|
111
98
|
end
|
112
99
|
|
113
|
-
it '
|
114
|
-
|
115
|
-
|
116
|
-
expect(cli.interpreter).to be interpreter
|
100
|
+
it 'assigns the evaluated recipe' do
|
101
|
+
cli.load_recipe
|
102
|
+
expect(cli.recipe.tasks.count).to be 2
|
117
103
|
end
|
118
104
|
end
|
119
105
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: producer-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- lib/producer/core/version.rb
|
155
155
|
- producer-core.gemspec
|
156
156
|
- spec/fixtures/recipes/empty.rb
|
157
|
+
- spec/fixtures/recipes/some_recipe.rb
|
157
158
|
- spec/fixtures/recipes/throw.rb
|
158
159
|
- spec/producer/core/action_spec.rb
|
159
160
|
- spec/producer/core/actions/echo_spec.rb
|
@@ -226,6 +227,7 @@ test_files:
|
|
226
227
|
- features/tests/has_file.feature
|
227
228
|
- features/tests/negated_test.feature
|
228
229
|
- spec/fixtures/recipes/empty.rb
|
230
|
+
- spec/fixtures/recipes/some_recipe.rb
|
229
231
|
- spec/fixtures/recipes/throw.rb
|
230
232
|
- spec/producer/core/action_spec.rb
|
231
233
|
- spec/producer/core/actions/echo_spec.rb
|