producer-core 0.2.2 → 0.2.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.
@@ -11,4 +11,18 @@ Feature: `file_write' task action
11
11
  end
12
12
  """
13
13
  When I successfully execute the recipe
14
- And the remote file "some_file" must contain "some_content"
14
+ Then the remote file "some_file" must contain "some_content"
15
+
16
+ Scenario: creates file with given permissions
17
+ Given a recipe with:
18
+ """
19
+ target 'some_host.test'
20
+
21
+ task :write_some_data do
22
+ file_write 'some_file_0600', 'some_content', 0600
23
+ file_write 'some_file_0700', 'some_content', 0700
24
+ end
25
+ """
26
+ When I successfully execute the recipe
27
+ Then the remote file "some_file_0600" must have 0600 mode
28
+ And the remote file "some_file_0700" must have 0700 mode
@@ -12,3 +12,17 @@ Feature: `mkdir' task action
12
12
  """
13
13
  When I successfully execute the recipe
14
14
  Then the remote directory "some_directory" must exists
15
+
16
+ Scenario: creates directory with given permissions
17
+ Given a recipe with:
18
+ """
19
+ target 'some_host.test'
20
+
21
+ task :create_some_dir do
22
+ mkdir '0700_directory', 0700
23
+ mkdir '0500_directory', 0500
24
+ end
25
+ """
26
+ When I successfully execute the recipe
27
+ Then the remote directory "0700_directory" must have 0700 mode
28
+ And the remote directory "0500_directory" must have 0500 mode
@@ -21,3 +21,17 @@ end
21
21
  Then /^the remote file "([^"]+)" must contain exactly "([^"]+)"$/ do |path, content|
22
22
  check_exact_file_content path, content
23
23
  end
24
+
25
+ def stat_mode(path)
26
+ in_current_dir do
27
+ ('%o' % [File::Stat.new(path).mode])[-4, 4]
28
+ end
29
+ end
30
+
31
+ Then /^the remote file "([^"]+)" must have (\d+) mode$/ do |path, mode|
32
+ expect(stat_mode path).to eq mode
33
+ end
34
+
35
+ Then /^the remote directory "([^"]+)" must have (\d+) mode$/ do |path, mode|
36
+ expect(stat_mode path).to eq mode
37
+ end
@@ -3,7 +3,12 @@ module Producer
3
3
  module Actions
4
4
  class FileWriter < Action
5
5
  def apply
6
- fs.file_write path, content
6
+ case arguments.size
7
+ when 2
8
+ fs.file_write path, content
9
+ when 3
10
+ fs.file_write path, content, mode
11
+ end
7
12
  end
8
13
 
9
14
  def path
@@ -13,6 +18,10 @@ module Producer
13
18
  def content
14
19
  arguments[1]
15
20
  end
21
+
22
+ def mode
23
+ arguments[2]
24
+ end
16
25
  end
17
26
  end
18
27
  end
@@ -3,12 +3,21 @@ module Producer
3
3
  module Actions
4
4
  class Mkdir < Action
5
5
  def apply
6
- fs.mkdir path
6
+ case arguments.size
7
+ when 1
8
+ fs.mkdir path
9
+ when 2
10
+ fs.mkdir path, mode
11
+ end
7
12
  end
8
13
 
9
14
  def path
10
15
  arguments.first
11
16
  end
17
+
18
+ def mode
19
+ arguments[1]
20
+ end
12
21
  end
13
22
  end
14
23
  end
@@ -20,8 +20,9 @@ module Producer
20
20
  false
21
21
  end
22
22
 
23
- def mkdir(path)
24
- sftp.mkdir! path
23
+ def mkdir(path, mode = nil)
24
+ options = mode ? { permissions: mode } : {}
25
+ sftp.mkdir! path, options
25
26
  end
26
27
 
27
28
  def file_read(path)
@@ -30,8 +31,8 @@ module Producer
30
31
  nil
31
32
  end
32
33
 
33
- def file_write(path, content)
34
- sftp.file.open path, 'w' do |f|
34
+ def file_write(path, content, mode = nil)
35
+ sftp.file.open path, 'w', mode do |f|
35
36
  f.write content
36
37
  end
37
38
  end
@@ -1,5 +1,5 @@
1
1
  module Producer
2
2
  module Core
3
- VERSION = '0.2.2'
3
+ VERSION = '0.2.3'
4
4
  end
5
5
  end
@@ -14,6 +14,16 @@ module Producer::Core
14
14
  expect(remote_fs).to receive(:file_write).with(path, content)
15
15
  writer.apply
16
16
  end
17
+
18
+ context 'when a mode was given' do
19
+ subject(:writer) { FileWriter.new(env, path, content, 0600) }
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
26
+ end
17
27
  end
18
28
 
19
29
  describe '#path' do
@@ -27,6 +37,20 @@ module Producer::Core
27
37
  expect(writer.content).to eq content
28
38
  end
29
39
  end
40
+
41
+ describe '#mode' do
42
+ it 'returns nil' do
43
+ expect(writer.mode).to be nil
44
+ end
45
+
46
+ context 'when a mode was given' do
47
+ subject(:writer) { FileWriter.new(env, path, content, 0600) }
48
+
49
+ it 'returns the mode' do
50
+ expect(writer.mode).to eq 0600
51
+ end
52
+ end
53
+ end
30
54
  end
31
55
  end
32
56
  end
@@ -13,6 +13,15 @@ module Producer::Core
13
13
  expect(remote_fs).to receive(:mkdir).with(path)
14
14
  mkdir.apply
15
15
  end
16
+
17
+ context 'when a mode was given' do
18
+ subject(:mkdir) { Mkdir.new(env, path, 0700) }
19
+
20
+ it 'creates the directory with given mode' do
21
+ expect(remote_fs).to receive(:mkdir).with(anything, 0700)
22
+ mkdir.apply
23
+ end
24
+ end
16
25
  end
17
26
 
18
27
  describe '#path' do
@@ -20,6 +29,20 @@ module Producer::Core
20
29
  expect(mkdir.path).to eq path
21
30
  end
22
31
  end
32
+
33
+ describe '#mode' do
34
+ it 'returns nil' do
35
+ expect(mkdir.mode).to be nil
36
+ end
37
+
38
+ context 'when a mode was given' do
39
+ subject(:mkdir) { Mkdir.new(env, path, 0700) }
40
+
41
+ it 'returns the mode' do
42
+ expect(mkdir.mode).to be 0700
43
+ end
44
+ end
45
+ end
23
46
  end
24
47
  end
25
48
  end
@@ -89,9 +89,16 @@ module Producer::Core
89
89
  let(:path) { 'some_directory_path' }
90
90
 
91
91
  it 'creates the directory' do
92
- expect(sftp).to receive(:mkdir!).with(path)
92
+ expect(sftp).to receive(:mkdir!).with(path, anything)
93
93
  fs.mkdir path
94
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
101
+ end
95
102
  end
96
103
 
97
104
  describe '#file_read' do
@@ -126,7 +133,7 @@ module Producer::Core
126
133
  let(:content) { 'some_content' }
127
134
 
128
135
  it 'opens the file' do
129
- expect(sftp_file).to receive(:open).with(path, 'w')
136
+ expect(sftp_file).to receive(:open).with(path, 'w', anything)
130
137
  fs.file_write path, content
131
138
  end
132
139
 
@@ -137,6 +144,11 @@ module Producer::Core
137
144
  end
138
145
  fs.file_write path, content
139
146
  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
140
152
  end
141
153
  end
142
154
  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.2.2
4
+ version: 0.2.3
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: 2015-04-03 00:00:00.000000000 Z
12
+ date: 2014-05-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
@@ -228,26 +243,27 @@ files:
228
243
  - spec/support/test_env_helpers.rb
229
244
  homepage: https://rubygems.org/gems/producer-core
230
245
  licenses: []
231
- metadata: {}
232
246
  post_install_message:
233
247
  rdoc_options: []
234
248
  require_paths:
235
249
  - lib
236
250
  required_ruby_version: !ruby/object:Gem::Requirement
251
+ none: false
237
252
  requirements:
238
253
  - - ">="
239
254
  - !ruby/object:Gem::Version
240
255
  version: '0'
241
256
  required_rubygems_version: !ruby/object:Gem::Requirement
257
+ none: false
242
258
  requirements:
243
259
  - - ">="
244
260
  - !ruby/object:Gem::Version
245
261
  version: '0'
246
262
  requirements: []
247
263
  rubyforge_project:
248
- rubygems_version: 2.4.5
264
+ rubygems_version: 1.8.29
249
265
  signing_key:
250
- specification_version: 4
266
+ specification_version: 3
251
267
  summary: Provisioning tool
252
268
  test_files:
253
269
  - features/actions/echo.feature
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: b0948086dee94e6a1363c83af78cbc8fdec0c6d8
4
- data.tar.gz: 6994469ae9fce4b8c7184545b453b3304555f648
5
- SHA512:
6
- metadata.gz: e783aa0c29560a4c5f6f13c6ea5ab4367ca5031c2f5b766d351b8087bd64b0815deea04d355c0eb70a86a95db0b68076e2a9fb1aae405ca8e5a630635c547d90
7
- data.tar.gz: c38e3b3445bbd59f58c0b8467fabf64c2a14c79b20aa9cbc6ca9586e1ba69d41bf84e3dc3e6bebb63d07e46ba5a8d301612318c7c93ae8443ee36d03e8793f22