producer-core 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/cli_target.feature +15 -0
- data/features/steps/recipe_steps.rb +1 -1
- data/features/support/env.rb +5 -1
- data/lib/producer/core/cli.rb +4 -2
- data/lib/producer/core/recipe/dsl.rb +1 -1
- data/lib/producer/core/remote.rb +1 -1
- data/lib/producer/core/testing/mock_remote.rb +3 -3
- data/lib/producer/core/version.rb +1 -1
- data/spec/producer/core/cli_spec.rb +11 -1
- data/spec/producer/core/recipe/dsl_spec.rb +13 -3
- data/spec/support/shared_test.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 558adf1eb44b9065788d910cc92c133894612fd1
|
4
|
+
data.tar.gz: 97b0bbc77826a98b81e854f2a7034ff8ca544557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d4ffe253ba82de174a3064bc015e188c4d6e1715705cf211a03708695980daf66b3a6299973757fad6d236ab06a48e457d89db694682e9535f4533b6ad312aa
|
7
|
+
data.tar.gz: a5402e095dd72ba88a69ec602d99eb137c7a5821c3adecf95657a3c4e340231be42be593d84bee7307c217e723905d9cf6df57b07e9fe38a5a0af3d63643aaad
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: CLI target option
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a recipe with:
|
5
|
+
"""
|
6
|
+
target 'some_host.example'
|
7
|
+
|
8
|
+
task :some_task do
|
9
|
+
echo env.target
|
10
|
+
end
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: prints tasks name
|
14
|
+
When I successfully execute the recipe with option -t other_host.example
|
15
|
+
Then the output must contain exactly "other_host.example\n"
|
@@ -11,7 +11,7 @@ When /^I successfully execute the recipe$/ do
|
|
11
11
|
assert_exit_status 0
|
12
12
|
end
|
13
13
|
|
14
|
-
When /^I successfully execute the recipe with option (
|
14
|
+
When /^I successfully execute the recipe with option (-.+)$/ do |option|
|
15
15
|
run_simple "producer #{option} recipe.rb", false
|
16
16
|
assert_exit_status 0
|
17
17
|
end
|
data/features/support/env.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'aruba/cucumber'
|
2
2
|
require 'aruba/in_process'
|
3
|
-
require 'cucumber/sshd/cucumber'
|
4
3
|
require 'producer/core'
|
5
4
|
|
6
5
|
|
@@ -24,6 +23,11 @@ class ArubaProgramWrapper
|
|
24
23
|
end
|
25
24
|
|
26
25
|
|
26
|
+
Before do
|
27
|
+
@_sshd_fast = true
|
28
|
+
end
|
29
|
+
require 'cucumber/sshd/cucumber'
|
30
|
+
|
27
31
|
Before('@exec') do
|
28
32
|
Aruba.process = Aruba::SpawnProcess
|
29
33
|
end
|
data/lib/producer/core/cli.rb
CHANGED
@@ -34,19 +34,21 @@ module Producer
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def parse_arguments!
|
37
|
-
@arguments = arguments.inject([]) do |m, e|
|
37
|
+
@arguments = arguments.each_with_index.inject([]) do |m, (e, i)|
|
38
38
|
case e
|
39
39
|
when '-v'
|
40
40
|
env.verbose = true
|
41
41
|
when '-n'
|
42
42
|
env.dry_run = true
|
43
|
+
when '-t'
|
44
|
+
env.target = arguments.delete_at i + 1
|
43
45
|
else
|
44
46
|
m << e
|
45
47
|
end
|
46
48
|
m
|
47
49
|
end
|
48
50
|
|
49
|
-
|
51
|
+
fail ArgumentError unless arguments.any?
|
50
52
|
end
|
51
53
|
|
52
54
|
def run
|
data/lib/producer/core/remote.rb
CHANGED
@@ -3,7 +3,7 @@ module Producer
|
|
3
3
|
module Testing
|
4
4
|
class MockRemote < Remote
|
5
5
|
def session
|
6
|
-
|
6
|
+
fail 'no session for mock remote!'
|
7
7
|
end
|
8
8
|
|
9
9
|
def execute(command, output = '')
|
@@ -16,9 +16,9 @@ module Producer
|
|
16
16
|
when 'true'
|
17
17
|
output << ''
|
18
18
|
when 'false'
|
19
|
-
|
19
|
+
fail RemoteCommandExecutionError
|
20
20
|
when 'type'
|
21
|
-
|
21
|
+
fail RemoteCommandExecutionError unless %w[
|
22
22
|
echo
|
23
23
|
true
|
24
24
|
false
|
@@ -122,7 +122,7 @@ module Producer::Core
|
|
122
122
|
|
123
123
|
describe '#parse_arguments!' do
|
124
124
|
context 'with options' do
|
125
|
-
let(:options) { %w[-v] }
|
125
|
+
let(:options) { %w[-v -t some_host.example] }
|
126
126
|
|
127
127
|
before { cli.parse_arguments! }
|
128
128
|
|
@@ -131,6 +131,8 @@ module Producer::Core
|
|
131
131
|
end
|
132
132
|
|
133
133
|
context 'verbose' do
|
134
|
+
let(:options) { %w[-v] }
|
135
|
+
|
134
136
|
it 'enables env verbose mode' do
|
135
137
|
expect(cli.env).to be_verbose
|
136
138
|
end
|
@@ -143,6 +145,14 @@ module Producer::Core
|
|
143
145
|
expect(cli.env).to be_dry_run
|
144
146
|
end
|
145
147
|
end
|
148
|
+
|
149
|
+
context 'target' do
|
150
|
+
let(:options) { %w[-t some_host.example] }
|
151
|
+
|
152
|
+
it 'assigns the given target to the env' do
|
153
|
+
expect(cli.env.target).to eq 'some_host.example'
|
154
|
+
end
|
155
|
+
end
|
146
156
|
end
|
147
157
|
|
148
158
|
context 'without arguments' do
|
@@ -65,9 +65,19 @@ module Producer::Core
|
|
65
65
|
describe '#target' do
|
66
66
|
let(:host) { 'some_host.example' }
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
context 'when env has no assigned target' do
|
69
|
+
it 'registers the target host in the env' do
|
70
|
+
dsl.target host
|
71
|
+
expect(env.target).to eq host
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when env has an assigned target' do
|
76
|
+
before { env.target = 'already_assigned_host.example' }
|
77
|
+
|
78
|
+
it 'does not change env target' do
|
79
|
+
expect { dsl.target host }.not_to change { env.target }
|
80
|
+
end
|
71
81
|
end
|
72
82
|
end
|
73
83
|
|
data/spec/support/shared_test.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- features/action_mkdir.feature
|
130
130
|
- features/action_sh.feature
|
131
131
|
- features/cli_dry_run.feature
|
132
|
+
- features/cli_target.feature
|
132
133
|
- features/cli_usage.feature
|
133
134
|
- features/cli_verbose.feature
|
134
135
|
- features/recipe_ask.feature
|
@@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
251
|
version: '0'
|
251
252
|
requirements: []
|
252
253
|
rubyforge_project:
|
253
|
-
rubygems_version: 2.
|
254
|
+
rubygems_version: 2.2.2
|
254
255
|
signing_key:
|
255
256
|
specification_version: 4
|
256
257
|
summary: Provisioning tool
|
@@ -262,6 +263,7 @@ test_files:
|
|
262
263
|
- features/action_mkdir.feature
|
263
264
|
- features/action_sh.feature
|
264
265
|
- features/cli_dry_run.feature
|
266
|
+
- features/cli_target.feature
|
265
267
|
- features/cli_usage.feature
|
266
268
|
- features/cli_verbose.feature
|
267
269
|
- features/recipe_ask.feature
|