producer-core 0.3.6 → 0.3.7
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 +4 -4
- data/features/action_mkdir.feature +10 -0
- data/features/recipe_target.feature +11 -1
- data/lib/producer/core/actions/mkdir.rb +7 -5
- data/lib/producer/core/recipe.rb +2 -2
- data/lib/producer/core/remote/fs.rb +4 -0
- data/lib/producer/core/version.rb +1 -1
- data/lib/producer/core.rb +2 -1
- data/spec/producer/core/actions/mkdir_spec.rb +16 -15
- data/spec/producer/core/recipe_spec.rb +7 -0
- data/spec/support/test_env_helpers.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b765ca3e62a5f6d52c70023568a7ff479eb90fb4
|
4
|
+
data.tar.gz: c742add987d14bc54d14933bf560d236e89f3be0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a59aea6fc1ea7fc7ce56b0ce33adbd53095d895945f2a036a2057b2b9f9b5460047d92b94a5f20866b20756d39511ab38e032dca792f85e5b786d73995028792
|
7
|
+
data.tar.gz: dd3ef0d2f879a4d9e1dd4b1bd3cb2747c390070f9d7544db077d044aa76dda67e11883ff08b45e79042fba471a6ca2bf351e625f7ee67457b4d9272f74f0b959
|
@@ -19,3 +19,13 @@ Feature: `mkdir' task action
|
|
19
19
|
When I successfully execute the recipe on remote target
|
20
20
|
Then the remote directory "some_directory_0700" must have 0700 mode
|
21
21
|
And the remote directory "some_directory_0500" must have 0500 mode
|
22
|
+
|
23
|
+
Scenario: creates directories recursively
|
24
|
+
Given a recipe with:
|
25
|
+
"""
|
26
|
+
task :mkdir_action do
|
27
|
+
mkdir 'some/directory'
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I successfully execute the recipe on remote target
|
31
|
+
Then the remote directory "some/directory" must exists
|
@@ -10,4 +10,14 @@ Feature: `target' recipe keyword
|
|
10
10
|
end
|
11
11
|
"""
|
12
12
|
When I successfully execute the recipe
|
13
|
-
Then the output must contain
|
13
|
+
Then the output must contain "some_host.example"
|
14
|
+
|
15
|
+
Scenario: returns current target when no arguments are provided
|
16
|
+
Given a recipe with:
|
17
|
+
"""
|
18
|
+
target 'some_host.example'
|
19
|
+
|
20
|
+
env.output.puts target
|
21
|
+
"""
|
22
|
+
When I successfully execute the recipe
|
23
|
+
Then the output must contain "some_host.example"
|
@@ -7,14 +7,16 @@ module Producer
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def apply
|
10
|
-
|
11
|
-
|
12
|
-
fs.mkdir
|
13
|
-
|
14
|
-
fs.mkdir path, mode
|
10
|
+
Pathname.new(path).descend do |p|
|
11
|
+
next if fs.dir? p
|
12
|
+
fs.mkdir p.to_s
|
13
|
+
fs.chmod p.to_s, mode if mode
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
17
|
+
|
18
|
+
private
|
19
|
+
|
18
20
|
def path
|
19
21
|
arguments.first
|
20
22
|
end
|
data/lib/producer/core/recipe.rb
CHANGED
@@ -26,8 +26,8 @@ module Producer
|
|
26
26
|
instance_eval File.read("./#{filepath}.rb"), "#{filepath}.rb"
|
27
27
|
end
|
28
28
|
|
29
|
-
def target(hostname)
|
30
|
-
env.target ||= hostname
|
29
|
+
def target(hostname = nil)
|
30
|
+
if hostname then env.target ||= hostname else env.target end
|
31
31
|
end
|
32
32
|
|
33
33
|
def task(name, *args, &block)
|
data/lib/producer/core.rb
CHANGED
@@ -9,6 +9,8 @@ module Producer::Core
|
|
9
9
|
it_behaves_like 'action'
|
10
10
|
|
11
11
|
describe '#apply' do
|
12
|
+
before { allow(remote_fs).to receive(:dir?) { false } }
|
13
|
+
|
12
14
|
it 'creates directory on remote filesystem' do
|
13
15
|
expect(remote_fs).to receive(:mkdir).with(path)
|
14
16
|
mkdir.apply
|
@@ -17,29 +19,28 @@ module Producer::Core
|
|
17
19
|
context 'when a mode was given' do
|
18
20
|
subject(:mkdir) { Mkdir.new(env, path, 0700) }
|
19
21
|
|
20
|
-
it '
|
21
|
-
expect(remote_fs).to receive(:
|
22
|
+
it 'changes the directory with given mode' do
|
23
|
+
expect(remote_fs).to receive(:chmod).with(path, 0700)
|
22
24
|
mkdir.apply
|
23
25
|
end
|
24
26
|
end
|
25
|
-
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
expect(mkdir.path).to eq path
|
30
|
-
end
|
31
|
-
end
|
28
|
+
context 'when parent directories does not exists' do
|
29
|
+
let(:path) { 'some/path' }
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
it 'creates parent directories' do
|
32
|
+
expect(remote_fs).to receive(:mkdir).with('some').ordered
|
33
|
+
expect(remote_fs).to receive(:mkdir).with('some/path').ordered
|
34
|
+
mkdir.apply
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
|
-
context 'when
|
39
|
-
|
38
|
+
context 'when directory already exists' do
|
39
|
+
before { allow(remote_fs).to receive(:dir?) { true } }
|
40
40
|
|
41
|
-
it '
|
42
|
-
expect(
|
41
|
+
it 'creates directory on remote filesystem' do
|
42
|
+
expect(remote_fs).not_to receive(:mkdir)
|
43
|
+
mkdir.apply
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
@@ -38,6 +38,13 @@ module Producer::Core
|
|
38
38
|
expect { recipe.target host }.not_to change { env.target }
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
context 'when no arguments are provided' do
|
43
|
+
it 'returns current target' do
|
44
|
+
recipe.target host
|
45
|
+
expect(recipe.target).to eq host
|
46
|
+
end
|
47
|
+
end
|
41
48
|
end
|
42
49
|
|
43
50
|
describe '#task' do
|
@@ -36,7 +36,7 @@ module TestEnvHelpers
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def build_remote
|
39
|
-
fs =
|
39
|
+
fs = instance_spy Producer::Core::Remote::FS
|
40
40
|
remote = Producer::Core::Testing::MockRemote.new('some_host.test')
|
41
41
|
remote.define_singleton_method(:fs) { fs }
|
42
42
|
remote
|