producer-core 0.3.2 → 0.3.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48c7af413fbd8bac4796f6789db5e1fe2ebc1717
|
4
|
+
data.tar.gz: 41c1543b1d8c4f7e529191a91c974a18d660e488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8d9d8a3b36801b7fe46f4655bdf3eab4a61bcd090ba40806911463ae704d4a8fd7a01951fb18545ab82913d63c71dd1ecb5151cad63880d0f9c145f0ba6372c
|
7
|
+
data.tar.gz: f52db474d584f3c6f23e7f6f9cbc88d21e400515ba624d092862190146d33bc062eb791637fb6105d8fb5e25d6bfb3282e510f57b582a529f3bb2df0ec6261f8
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: nested tasks
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a recipe with:
|
5
|
+
"""
|
6
|
+
task :outer_task do
|
7
|
+
task :inner_task do
|
8
|
+
echo 'OK'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: applies nested tasks
|
14
|
+
When I successfully execute the recipe
|
15
|
+
Then the output must match /\AOK/
|
data/lib/producer/core/task.rb
CHANGED
@@ -43,6 +43,10 @@ module Producer
|
|
43
43
|
@condition
|
44
44
|
end
|
45
45
|
|
46
|
+
def task(name, *args, &block)
|
47
|
+
@actions << self.class.evaluate(@env, name, *args, &block)
|
48
|
+
end
|
49
|
+
|
46
50
|
def ask(question, choices, prompter: Prompter.new(@env.input, @env.output))
|
47
51
|
prompter.prompt(question, choices)
|
48
52
|
end
|
data/lib/producer/core/worker.rb
CHANGED
@@ -18,8 +18,12 @@ module Producer
|
|
18
18
|
if task.condition_met?
|
19
19
|
@env.log "Task: `#{task}' applying..."
|
20
20
|
task.actions.each do |e|
|
21
|
-
|
22
|
-
|
21
|
+
case e
|
22
|
+
when Task then process_task e
|
23
|
+
else
|
24
|
+
@env.log " action: #{e}"
|
25
|
+
e.apply unless @env.dry_run?
|
26
|
+
end
|
23
27
|
end
|
24
28
|
else
|
25
29
|
@env.log "Task: `#{task}' skipped"
|
@@ -126,6 +126,15 @@ module Producer::Core
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
describe '#task' do
|
130
|
+
before { described_class.define_action(:some_action, SomeAction) }
|
131
|
+
|
132
|
+
it 'registers a nested task as an action' do
|
133
|
+
task.task(:nested_task) { some_action }
|
134
|
+
expect(task.actions).to match [an_instance_of(Task)]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
129
138
|
describe '#ask' do
|
130
139
|
let(:question) { 'Which letter?' }
|
131
140
|
let(:choices) { [[:a, ?A], [:b, ?B]] }
|
@@ -25,9 +25,9 @@ module Producer::Core
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#process_task' do
|
28
|
-
let(:env)
|
29
|
-
let(:action)
|
30
|
-
let(:task)
|
28
|
+
let(:env) { instance_spy Env, dry_run?: false }
|
29
|
+
let(:action) { double('action', to_s: 'echo').as_null_object }
|
30
|
+
let(:task) { Task.new(env, :some_task, [action]) }
|
31
31
|
|
32
32
|
it 'logs task info' do
|
33
33
|
expect(env).to receive(:log).with /\ATask: `some_task'/
|
@@ -68,11 +68,21 @@ module Producer::Core
|
|
68
68
|
worker.process_task task
|
69
69
|
end
|
70
70
|
|
71
|
-
it 'logs the task as
|
71
|
+
it 'logs the task as being skipped' do
|
72
72
|
expect(env).to receive(:log).with /some_task.+skipped\z/
|
73
73
|
worker.process_task task
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
context 'when a task contains nested tasks' do
|
78
|
+
let(:inner_task) { Task.new(env, :inner, [action]) }
|
79
|
+
let(:outer_task) { Task.new(env, :outer, [inner_task]) }
|
80
|
+
|
81
|
+
it 'processes nested tasks' do
|
82
|
+
expect(action).to receive :apply
|
83
|
+
worker.process [outer_task]
|
84
|
+
end
|
85
|
+
end
|
76
86
|
end
|
77
87
|
end
|
78
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: producer-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- features/support/env_fake_home.rb
|
153
153
|
- features/task_ask.feature
|
154
154
|
- features/task_condition.feature
|
155
|
+
- features/task_nested_tasks.feature
|
155
156
|
- features/test_dir.feature
|
156
157
|
- features/test_env.feature
|
157
158
|
- features/test_executable.feature
|
@@ -287,6 +288,7 @@ test_files:
|
|
287
288
|
- features/support/env_fake_home.rb
|
288
289
|
- features/task_ask.feature
|
289
290
|
- features/task_condition.feature
|
291
|
+
- features/task_nested_tasks.feature
|
290
292
|
- features/test_dir.feature
|
291
293
|
- features/test_env.feature
|
292
294
|
- features/test_executable.feature
|