producer-core 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/features/action_file_write.feature +2 -2
- data/features/action_mkdir.feature +4 -4
- data/lib/producer/core/action.rb +10 -2
- data/lib/producer/core/actions/echo.rb +1 -1
- data/lib/producer/core/actions/file_append.rb +9 -12
- data/lib/producer/core/actions/file_replace_content.rb +7 -14
- data/lib/producer/core/actions/file_writer.rb +9 -18
- data/lib/producer/core/actions/mkdir.rb +9 -13
- data/lib/producer/core/actions/shell_command.rb +6 -1
- data/lib/producer/core/errors.rb +1 -0
- data/lib/producer/core/remote/fs.rb +9 -6
- data/lib/producer/core/version.rb +1 -1
- data/spec/producer/core/action_spec.rb +33 -2
- data/spec/producer/core/actions/echo_spec.rb +2 -1
- data/spec/producer/core/actions/file_append_spec.rb +12 -13
- data/spec/producer/core/actions/file_replace_content_spec.rb +12 -19
- data/spec/producer/core/actions/file_writer_spec.rb +25 -29
- data/spec/producer/core/actions/mkdir_spec.rb +28 -6
- data/spec/producer/core/actions/shell_command_spec.rb +12 -1
- data/spec/producer/core/remote/fs_spec.rb +5 -16
- data/spec/support/shared_action.rb +2 -32
- metadata +21 -5
- checksums.yaml +0 -7
@@ -6,8 +6,8 @@ Feature: `file_write' task action
|
|
6
6
|
"""
|
7
7
|
task :file_write_action do
|
8
8
|
file_write 'some_file', 'some_content'
|
9
|
-
file_write 'some_file_0600', 'some_content', 0600
|
10
|
-
file_write 'some_file_0700', 'some_content', 0700
|
9
|
+
file_write 'some_file_0600', 'some_content', mode: 0600
|
10
|
+
file_write 'some_file_0700', 'some_content', mode: 0700
|
11
11
|
end
|
12
12
|
"""
|
13
13
|
|
@@ -6,8 +6,8 @@ Feature: `mkdir' task action
|
|
6
6
|
"""
|
7
7
|
task :mkdir_action do
|
8
8
|
mkdir 'some_directory'
|
9
|
-
mkdir 'some_directory_0700', 0700
|
10
|
-
mkdir '
|
9
|
+
mkdir 'some_directory_0700', mode: 0700
|
10
|
+
mkdir 'some_directory_0711', mode: 0711
|
11
11
|
end
|
12
12
|
"""
|
13
13
|
|
@@ -15,10 +15,10 @@ Feature: `mkdir' task action
|
|
15
15
|
When I successfully execute the recipe on remote target
|
16
16
|
Then the remote directory "some_directory" must exists
|
17
17
|
|
18
|
-
Scenario: creates directory with given
|
18
|
+
Scenario: creates directory with given attributes
|
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
|
-
And the remote directory "
|
21
|
+
And the remote directory "some_directory_0711" must have 0711 mode
|
22
22
|
|
23
23
|
Scenario: creates directories recursively
|
24
24
|
Given a recipe with:
|
data/lib/producer/core/action.rb
CHANGED
@@ -7,11 +7,13 @@ module Producer
|
|
7
7
|
def_delegators :@env, :input, :output, :error_output, :remote
|
8
8
|
def_delegators :remote, :fs
|
9
9
|
|
10
|
-
attr_reader :env, :arguments
|
10
|
+
attr_reader :env, :arguments, :options
|
11
11
|
|
12
|
-
def initialize(env, *args)
|
12
|
+
def initialize(env, *args, **options)
|
13
13
|
@env = env
|
14
14
|
@arguments = args
|
15
|
+
@options = options
|
16
|
+
setup if respond_to? :setup
|
15
17
|
end
|
16
18
|
|
17
19
|
def name
|
@@ -28,6 +30,12 @@ module Producer
|
|
28
30
|
def inspect_arguments
|
29
31
|
@arguments.inspect[0, INSPECT_ARGUMENTS_SUM_LEN - name.length]
|
30
32
|
end
|
33
|
+
|
34
|
+
def check_arguments_size!(size)
|
35
|
+
if arguments.compact.size != size
|
36
|
+
fail ArgumentError, '`%s\' action requires %d arguments' % [name, size]
|
37
|
+
end
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
33
41
|
end
|
@@ -2,27 +2,24 @@ module Producer
|
|
2
2
|
module Core
|
3
3
|
module Actions
|
4
4
|
class FileAppend < Action
|
5
|
+
def setup
|
6
|
+
check_arguments_size! 2
|
7
|
+
@path, @content = arguments
|
8
|
+
end
|
9
|
+
|
5
10
|
def name
|
6
11
|
'file_append'
|
7
12
|
end
|
8
13
|
|
9
14
|
def apply
|
10
|
-
fs.file_write path, combined_content
|
11
|
-
end
|
12
|
-
|
13
|
-
def path
|
14
|
-
arguments[0]
|
15
|
-
end
|
16
|
-
|
17
|
-
def content
|
18
|
-
arguments[1]
|
15
|
+
fs.file_write @path, combined_content
|
19
16
|
end
|
20
17
|
|
21
18
|
def combined_content
|
22
|
-
original_content = fs.file_read(path)
|
19
|
+
original_content = fs.file_read(@path)
|
23
20
|
|
24
|
-
return content unless original_content
|
25
|
-
original_content + content
|
21
|
+
return @content unless original_content
|
22
|
+
original_content + @content
|
26
23
|
end
|
27
24
|
end
|
28
25
|
end
|
@@ -2,28 +2,21 @@ module Producer
|
|
2
2
|
module Core
|
3
3
|
module Actions
|
4
4
|
class FileReplaceContent < Action
|
5
|
+
def setup
|
6
|
+
check_arguments_size! 3
|
7
|
+
@path, @pattern, @replacement = arguments
|
8
|
+
end
|
9
|
+
|
5
10
|
def name
|
6
11
|
'file_replace_content'
|
7
12
|
end
|
8
13
|
|
9
14
|
def apply
|
10
|
-
fs.file_write path, replaced_content
|
11
|
-
end
|
12
|
-
|
13
|
-
def path
|
14
|
-
arguments[0]
|
15
|
-
end
|
16
|
-
|
17
|
-
def pattern
|
18
|
-
arguments[1]
|
19
|
-
end
|
20
|
-
|
21
|
-
def replacement
|
22
|
-
arguments[2]
|
15
|
+
fs.file_write @path, replaced_content
|
23
16
|
end
|
24
17
|
|
25
18
|
def replaced_content
|
26
|
-
fs.file_read(path).gsub pattern, replacement
|
19
|
+
fs.file_read(@path).gsub @pattern, @replacement
|
27
20
|
end
|
28
21
|
end
|
29
22
|
end
|
@@ -2,29 +2,20 @@ module Producer
|
|
2
2
|
module Core
|
3
3
|
module Actions
|
4
4
|
class FileWriter < Action
|
5
|
+
def setup
|
6
|
+
check_arguments_size! 2
|
7
|
+
@path, @content = arguments
|
8
|
+
@options[:permissions] = @options.delete :mode if options.key? :mode
|
9
|
+
@options[:owner] = @options.delete :user if options.key? :user
|
10
|
+
end
|
11
|
+
|
5
12
|
def name
|
6
13
|
'file_write'
|
7
14
|
end
|
8
15
|
|
9
16
|
def apply
|
10
|
-
|
11
|
-
|
12
|
-
fs.file_write path, content
|
13
|
-
when 3
|
14
|
-
fs.file_write path, content, mode
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def path
|
19
|
-
arguments[0]
|
20
|
-
end
|
21
|
-
|
22
|
-
def content
|
23
|
-
arguments[1]
|
24
|
-
end
|
25
|
-
|
26
|
-
def mode
|
27
|
-
arguments[2]
|
17
|
+
fs.file_write @path, @content
|
18
|
+
fs.setstat @path, @options unless @options.empty?
|
28
19
|
end
|
29
20
|
end
|
30
21
|
end
|
@@ -2,28 +2,24 @@ module Producer
|
|
2
2
|
module Core
|
3
3
|
module Actions
|
4
4
|
class Mkdir < Action
|
5
|
+
def setup
|
6
|
+
check_arguments_size! 1
|
7
|
+
@path = Pathname.new(arguments.first)
|
8
|
+
@options[:permissions] = @options.delete :mode if @options.key? :mode
|
9
|
+
@options[:owner] = @options.delete :user if @options.key? :user
|
10
|
+
end
|
11
|
+
|
5
12
|
def name
|
6
13
|
'mkdir'
|
7
14
|
end
|
8
15
|
|
9
16
|
def apply
|
10
|
-
path.descend do |p|
|
17
|
+
@path.descend do |p|
|
11
18
|
next if fs.dir? p
|
12
19
|
fs.mkdir p.to_s
|
13
|
-
fs.
|
20
|
+
fs.setstat p.to_s, @options unless @options.empty?
|
14
21
|
end
|
15
22
|
end
|
16
|
-
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def path
|
21
|
-
Pathname.new(arguments.first)
|
22
|
-
end
|
23
|
-
|
24
|
-
def mode
|
25
|
-
arguments[1]
|
26
|
-
end
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
@@ -2,12 +2,17 @@ module Producer
|
|
2
2
|
module Core
|
3
3
|
module Actions
|
4
4
|
class ShellCommand < Action
|
5
|
+
def setup
|
6
|
+
check_arguments_size! 1
|
7
|
+
@command = arguments.first
|
8
|
+
end
|
9
|
+
|
5
10
|
def name
|
6
11
|
'sh'
|
7
12
|
end
|
8
13
|
|
9
14
|
def apply
|
10
|
-
remote.execute(
|
15
|
+
remote.execute(@command, output, error_output)
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
data/lib/producer/core/errors.rb
CHANGED
@@ -2,6 +2,7 @@ module Producer
|
|
2
2
|
module Core
|
3
3
|
Error = Class.new(StandardError)
|
4
4
|
RuntimeError = Class.new(RuntimeError)
|
5
|
+
ArgumentError = Class.new(Error)
|
5
6
|
ConditionNotMetError = Class.new(Error)
|
6
7
|
RemoteCommandExecutionError = Class.new(RuntimeError)
|
7
8
|
RegistryKeyError = Class.new(RuntimeError)
|
@@ -20,13 +20,16 @@ module Producer
|
|
20
20
|
false
|
21
21
|
end
|
22
22
|
|
23
|
+
def setstat(path, attributes)
|
24
|
+
sftp.setstat! path, attributes
|
25
|
+
end
|
26
|
+
|
23
27
|
def chmod(path, mode)
|
24
|
-
|
28
|
+
setstat path, permissions: mode
|
25
29
|
end
|
26
30
|
|
27
|
-
def mkdir(path,
|
28
|
-
|
29
|
-
sftp.mkdir! path, options
|
31
|
+
def mkdir(path, attributes = {})
|
32
|
+
ret = sftp.mkdir! path, attributes
|
30
33
|
end
|
31
34
|
|
32
35
|
def file_read(path)
|
@@ -35,8 +38,8 @@ module Producer
|
|
35
38
|
nil
|
36
39
|
end
|
37
40
|
|
38
|
-
def file_write(path, content
|
39
|
-
sftp.file.open path, 'w'
|
41
|
+
def file_write(path, content)
|
42
|
+
sftp.file.open path, 'w' do |f|
|
40
43
|
f.write content
|
41
44
|
end
|
42
45
|
end
|
@@ -2,14 +2,45 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Producer::Core
|
4
4
|
describe Action do
|
5
|
+
let(:env) { double 'env'}
|
6
|
+
let(:arguments) { [:some, :arguments] }
|
7
|
+
let(:options) { { foo: :bar } }
|
8
|
+
subject(:action) { described_class.new(env, *arguments, options) }
|
9
|
+
|
5
10
|
it_behaves_like 'action'
|
6
11
|
|
7
|
-
describe '#
|
8
|
-
|
12
|
+
describe '#initialize' do
|
13
|
+
it 'calls #setup when defined' do
|
14
|
+
action_class = Class.new(described_class)
|
15
|
+
action_class.class_eval do
|
16
|
+
define_method(:setup) { @arguments = :other_arguments }
|
17
|
+
end
|
18
|
+
expect(action_class.new(env).arguments).to eq :other_arguments
|
19
|
+
end
|
20
|
+
end
|
9
21
|
|
22
|
+
describe '#name' do
|
10
23
|
it 'infers action name from class name' do
|
11
24
|
expect(action.name).to eq 'action'
|
12
25
|
end
|
13
26
|
end
|
27
|
+
|
28
|
+
describe '#to_s' do
|
29
|
+
it 'includes action name' do
|
30
|
+
expect(action.to_s).to match /\A#{action.name}/
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'includes arguments inspection' do
|
34
|
+
expect(action.to_s).to match /#{Regexp.quote(arguments.inspect)}\z/
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when arguments inspection is very long' do
|
38
|
+
let(:arguments) { [:some, :arguments] * 32 }
|
39
|
+
|
40
|
+
it 'summarizes arguments inspection' do
|
41
|
+
expect(action.to_s.length).to be < 70
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
14
45
|
end
|
15
46
|
end
|
@@ -6,12 +6,23 @@ module Producer::Core
|
|
6
6
|
let(:path) { 'some_path' }
|
7
7
|
let(:content) { 'some content' }
|
8
8
|
let(:added_content) { ' added' }
|
9
|
-
|
9
|
+
let(:arguments) { [path, added_content] }
|
10
|
+
subject(:action) { described_class.new(env, *arguments) }
|
10
11
|
|
11
12
|
it_behaves_like 'action'
|
12
13
|
|
13
14
|
before { allow(remote_fs).to receive(:file_read).with(path) { content } }
|
14
15
|
|
16
|
+
describe '#setup' do
|
17
|
+
context 'when content is missing' do
|
18
|
+
let(:added_content) { nil }
|
19
|
+
|
20
|
+
it 'raises ArgumentError' do
|
21
|
+
expect { action }.to raise_error ArgumentError
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
15
26
|
describe '#apply' do
|
16
27
|
it 'appends given content to requested file on remote filesystem' do
|
17
28
|
expect(remote_fs)
|
@@ -20,18 +31,6 @@ module Producer::Core
|
|
20
31
|
end
|
21
32
|
end
|
22
33
|
|
23
|
-
describe '#path' do
|
24
|
-
it 'returns the file path' do
|
25
|
-
expect(action.path).to eq path
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#content' do
|
30
|
-
it 'returns the content to append' do
|
31
|
-
expect(action.content).to eq added_content
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
34
|
describe '#combined_content' do
|
36
35
|
it 'returns original content and added content combined' do
|
37
36
|
expect(action.combined_content).to eq 'some content added'
|
@@ -7,12 +7,23 @@ module Producer::Core
|
|
7
7
|
let(:pattern) { 'content' }
|
8
8
|
let(:replacement) { 'other content' }
|
9
9
|
let(:content) { 'some content' }
|
10
|
-
|
10
|
+
let(:arguments) { [path, pattern, replacement] }
|
11
|
+
subject(:action) { described_class.new(env, *arguments) }
|
11
12
|
|
12
13
|
it_behaves_like 'action'
|
13
14
|
|
14
15
|
before { allow(remote_fs).to receive(:file_read).with(path) { content } }
|
15
16
|
|
17
|
+
describe '#setup' do
|
18
|
+
context 'when replacement is missing' do
|
19
|
+
let(:replacement) { nil }
|
20
|
+
|
21
|
+
it 'raises ArgumentError' do
|
22
|
+
expect { action }.to raise_error ArgumentError
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
16
27
|
describe '#apply' do
|
17
28
|
it 'writes replaced content to file on remote filesystem' do
|
18
29
|
expect(remote_fs)
|
@@ -21,24 +32,6 @@ module Producer::Core
|
|
21
32
|
end
|
22
33
|
end
|
23
34
|
|
24
|
-
describe '#path' do
|
25
|
-
it 'returns the file path' do
|
26
|
-
expect(action.path).to eq path
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#pattern' do
|
31
|
-
it 'returns the pattern' do
|
32
|
-
expect(action.pattern).to eq pattern
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#replacement' do
|
37
|
-
it 'returns the replacement' do
|
38
|
-
expect(action.replacement).to eq replacement
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
35
|
describe '#replaced_content' do
|
43
36
|
it 'returns content with pattern occurrences pattern replaced' do
|
44
37
|
expect(action.replaced_content).to eq 'some other content'
|
@@ -5,49 +5,45 @@ module Producer::Core
|
|
5
5
|
describe FileWriter, :env do
|
6
6
|
let(:path) { 'some_path' }
|
7
7
|
let(:content) { 'some_content' }
|
8
|
-
|
8
|
+
let(:arguments) { [path, content] }
|
9
|
+
let(:options) { { } }
|
10
|
+
subject(:writer) { described_class.new(env, *arguments, options) }
|
9
11
|
|
10
12
|
it_behaves_like 'action'
|
11
13
|
|
12
|
-
describe '#
|
13
|
-
|
14
|
-
expect(remote_fs).to receive(:file_write).with(path, content)
|
15
|
-
writer.apply
|
16
|
-
end
|
14
|
+
describe '#setup' do
|
15
|
+
let(:options) { { mode: 0700, user: 'root' } }
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
it 'specifies the given mode' do
|
22
|
-
expect(remote_fs)
|
23
|
-
.to receive(:file_write).with(anything, anything, 0600)
|
24
|
-
writer.apply
|
25
|
-
end
|
17
|
+
it 'translates mode option as permissions' do
|
18
|
+
expect(writer.options[:permissions]).to eq 0700
|
26
19
|
end
|
27
|
-
end
|
28
20
|
|
29
|
-
|
30
|
-
|
31
|
-
expect(writer.path).to eq path
|
21
|
+
it 'translates user option as owner' do
|
22
|
+
expect(writer.options[:owner]).to eq 'root'
|
32
23
|
end
|
33
|
-
end
|
34
24
|
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
context 'when content is missing' do
|
26
|
+
let(:content) { nil }
|
27
|
+
|
28
|
+
it 'raises ArgumentError' do
|
29
|
+
expect { writer }.to raise_error ArgumentError
|
30
|
+
end
|
38
31
|
end
|
39
32
|
end
|
40
33
|
|
41
|
-
describe '#
|
42
|
-
it '
|
43
|
-
expect(
|
34
|
+
describe '#apply' do
|
35
|
+
it 'writes content to file on remote filesystem' do
|
36
|
+
expect(remote_fs)
|
37
|
+
.to receive(:file_write).with(path, content)
|
38
|
+
writer.apply
|
44
39
|
end
|
45
40
|
|
46
|
-
context 'when
|
47
|
-
|
41
|
+
context 'when status options are given' do
|
42
|
+
let(:options) { { group: 'wheel' } }
|
48
43
|
|
49
|
-
it '
|
50
|
-
expect(
|
44
|
+
it 'changes the directory status with given options' do
|
45
|
+
expect(remote_fs).to receive(:setstat).with(path, options)
|
46
|
+
writer.apply
|
51
47
|
end
|
52
48
|
end
|
53
49
|
end
|
@@ -4,10 +4,32 @@ module Producer::Core
|
|
4
4
|
module Actions
|
5
5
|
describe Mkdir, :env do
|
6
6
|
let(:path) { 'some_path' }
|
7
|
-
|
7
|
+
let(:options) { { } }
|
8
|
+
let(:arguments) { [path] }
|
9
|
+
subject(:mkdir) { described_class.new(env, *arguments, options) }
|
8
10
|
|
9
11
|
it_behaves_like 'action'
|
10
12
|
|
13
|
+
describe '#setup' do
|
14
|
+
let(:options) { { mode: 0700, user: 'root' } }
|
15
|
+
|
16
|
+
it 'translates mode option as permissions' do
|
17
|
+
expect(mkdir.options[:permissions]).to eq 0700
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'translates user option as owner' do
|
21
|
+
expect(mkdir.options[:owner]).to eq 'root'
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when path is missing' do
|
25
|
+
let(:path) { nil }
|
26
|
+
|
27
|
+
it 'raises ArgumentError' do
|
28
|
+
expect { mkdir }.to raise_error ArgumentError
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
11
33
|
describe '#apply' do
|
12
34
|
before { allow(remote_fs).to receive(:dir?) { false } }
|
13
35
|
|
@@ -16,11 +38,11 @@ module Producer::Core
|
|
16
38
|
mkdir.apply
|
17
39
|
end
|
18
40
|
|
19
|
-
context 'when
|
20
|
-
|
41
|
+
context 'when status options are given' do
|
42
|
+
let(:options) { { group: 'wheel' } }
|
21
43
|
|
22
|
-
it 'changes the directory with given
|
23
|
-
expect(remote_fs).to receive(:
|
44
|
+
it 'changes the directory status with given options' do
|
45
|
+
expect(remote_fs).to receive(:setstat).with(path, options)
|
24
46
|
mkdir.apply
|
25
47
|
end
|
26
48
|
end
|
@@ -38,7 +60,7 @@ module Producer::Core
|
|
38
60
|
context 'when directory already exists' do
|
39
61
|
before { allow(remote_fs).to receive(:dir?) { true } }
|
40
62
|
|
41
|
-
it '
|
63
|
+
it 'does not create any directory' do
|
42
64
|
expect(remote_fs).not_to receive(:mkdir)
|
43
65
|
mkdir.apply
|
44
66
|
end
|
@@ -5,10 +5,21 @@ module Producer::Core
|
|
5
5
|
describe ShellCommand, :env do
|
6
6
|
let(:command_args) { 'hello from remote host' }
|
7
7
|
let(:command) { "echo #{command_args}" }
|
8
|
-
|
8
|
+
let(:arguments) { [command] }
|
9
|
+
subject(:sh) { described_class.new(env, *arguments) }
|
9
10
|
|
10
11
|
it_behaves_like 'action'
|
11
12
|
|
13
|
+
describe '#setup' do
|
14
|
+
context 'when command is missing' do
|
15
|
+
let(:command) { nil }
|
16
|
+
|
17
|
+
it 'raises ArgumentError' do
|
18
|
+
expect { sh }.to raise_error ArgumentError
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
12
23
|
describe '#apply' do
|
13
24
|
it 'executes the remote command' do
|
14
25
|
expect_execution(command)
|
@@ -86,18 +86,12 @@ module Producer::Core
|
|
86
86
|
end
|
87
87
|
|
88
88
|
describe '#mkdir' do
|
89
|
-
let(:path)
|
89
|
+
let(:path) { 'some_directory_path' }
|
90
|
+
let(:attributes) { { foo: :bar } }
|
90
91
|
|
91
92
|
it 'creates the directory' do
|
92
|
-
expect(sftp).to receive(:mkdir!).with(path,
|
93
|
-
fs.mkdir path
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'specifies permissions from optional mode argument' do
|
97
|
-
expect(sftp).to receive(:mkdir!) do |_, options|
|
98
|
-
expect(options[:permissions]).to eq 0700
|
99
|
-
end
|
100
|
-
fs.mkdir path, 0700
|
93
|
+
expect(sftp).to receive(:mkdir!).with(path, attributes)
|
94
|
+
fs.mkdir path, attributes
|
101
95
|
end
|
102
96
|
end
|
103
97
|
|
@@ -133,7 +127,7 @@ module Producer::Core
|
|
133
127
|
let(:content) { 'some_content' }
|
134
128
|
|
135
129
|
it 'opens the file' do
|
136
|
-
expect(sftp_file).to receive(:open).with(path, 'w'
|
130
|
+
expect(sftp_file).to receive(:open).with(path, 'w')
|
137
131
|
fs.file_write path, content
|
138
132
|
end
|
139
133
|
|
@@ -144,11 +138,6 @@ module Producer::Core
|
|
144
138
|
end
|
145
139
|
fs.file_write path, content
|
146
140
|
end
|
147
|
-
|
148
|
-
it 'accepts an optional mode argument' do
|
149
|
-
expect(sftp_file).to receive(:open).with(anything, anything, 0600)
|
150
|
-
fs.file_write path, content, 0600
|
151
|
-
end
|
152
141
|
end
|
153
142
|
end
|
154
143
|
end
|
@@ -2,20 +2,8 @@ module Producer::Core
|
|
2
2
|
shared_examples 'action' do
|
3
3
|
include TestEnvHelpers
|
4
4
|
|
5
|
-
let(:
|
6
|
-
subject(:action) { described_class.new(env, *arguments) }
|
7
|
-
|
8
|
-
describe '#env' do
|
9
|
-
it 'returns the assigned env' do
|
10
|
-
expect(action.env).to be env
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#arguments' do
|
15
|
-
it 'returns the assigned arguments' do
|
16
|
-
expect(action.arguments).to eq arguments
|
17
|
-
end
|
18
|
-
end
|
5
|
+
let(:options) { { foo: :bar } }
|
6
|
+
subject(:action) { described_class.new(env, *arguments, options) }
|
19
7
|
|
20
8
|
describe '#input' do
|
21
9
|
it 'returns env input' do
|
@@ -52,23 +40,5 @@ module Producer::Core
|
|
52
40
|
expect(action.name).to match /\A\w+\z/
|
53
41
|
end
|
54
42
|
end
|
55
|
-
|
56
|
-
describe '#to_s' do
|
57
|
-
it 'includes action name' do
|
58
|
-
expect(action.to_s).to match /\A#{action.name}/
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'includes arguments inspection' do
|
62
|
-
expect(action.to_s).to match /#{Regexp.quote(arguments.inspect)}\z/
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when arguments inspection is very long' do
|
66
|
-
let(:arguments) { [:some, :arguments] * 32 }
|
67
|
-
|
68
|
-
it 'summarizes arguments inspection' do
|
69
|
-
expect(action.to_s.length).to be < 70
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
43
|
end
|
74
44
|
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: producer-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Thibault Jouan
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: net-ssh
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - "~>"
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: net-sftp
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - "~>"
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - "~>"
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rspec
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - "~>"
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: cucumber
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - "~>"
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - "~>"
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: aruba
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - "~>"
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :development
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - "~>"
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -83,6 +94,7 @@ dependencies:
|
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: cucumber-sshd
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - "~>"
|
88
100
|
- !ruby/object:Gem::Version
|
@@ -90,6 +102,7 @@ dependencies:
|
|
90
102
|
type: :development
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
107
|
- - "~>"
|
95
108
|
- !ruby/object:Gem::Version
|
@@ -97,6 +110,7 @@ dependencies:
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: rake
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
@@ -104,6 +118,7 @@ dependencies:
|
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
123
|
- - "~>"
|
109
124
|
- !ruby/object:Gem::Version
|
@@ -242,26 +257,27 @@ files:
|
|
242
257
|
- spec/support/test_env_helpers.rb
|
243
258
|
homepage: https://rubygems.org/gems/producer-core
|
244
259
|
licenses: []
|
245
|
-
metadata: {}
|
246
260
|
post_install_message:
|
247
261
|
rdoc_options: []
|
248
262
|
require_paths:
|
249
263
|
- lib
|
250
264
|
required_ruby_version: !ruby/object:Gem::Requirement
|
265
|
+
none: false
|
251
266
|
requirements:
|
252
267
|
- - ">="
|
253
268
|
- !ruby/object:Gem::Version
|
254
269
|
version: '0'
|
255
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
|
+
none: false
|
256
272
|
requirements:
|
257
273
|
- - ">="
|
258
274
|
- !ruby/object:Gem::Version
|
259
275
|
version: '0'
|
260
276
|
requirements: []
|
261
277
|
rubyforge_project:
|
262
|
-
rubygems_version:
|
278
|
+
rubygems_version: 1.8.29
|
263
279
|
signing_key:
|
264
|
-
specification_version:
|
280
|
+
specification_version: 3
|
265
281
|
summary: Provisioning tool
|
266
282
|
test_files:
|
267
283
|
- features/action_echo.feature
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 8ace21fcdc6845673cc6f94b6210ba2cec34afbb
|
4
|
-
data.tar.gz: 2766db0d025a2ced6386cd803ddd3f938fd29459
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 5e8d2371facb4acceecc19e3306ad543c0e84bdb1a7b4fc4f503322a5060c10e7d962f68eb9fb3921623a90aee34f19235c7ad030e6bbc9eacd5d88041ded545
|
7
|
-
data.tar.gz: fa8acb5e15fe715877c63bf24852fac5a45ff5705a295d94c4a5b381f5c62fe33816c4ecbc41037aa5beaa136dd4f430c9f8fc8b4e0b2133d64e689e2475ffb6
|