itamae 1.9.7.pre → 1.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/itamae/resource/file.rb +12 -13
- data/lib/itamae/version.rb +1 -1
- data/spec/integration/Vagrantfile +2 -0
- data/spec/integration/default_spec.rb +15 -0
- data/spec/integration/recipes/default.rb +38 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 328f99ca3c77bdfb7dd735eaa16c740f42dbf8d8
|
4
|
+
data.tar.gz: b5c102ee7950c954c7b56bc146ebdfdf89512f16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81b4df62bf844dba2fba5b76b9126650cdc81666583c112bf6fb0fb14aeeb9dc054b0d920ae7289c2cb4e983219110e42448b4b5fa6a877a0cd904e27df18ff2
|
7
|
+
data.tar.gz: d9391e3125d6d7257f1819aa7a4afbab53d07573a3d786f894fcb8bbedf01be3a8dc00a7fb37d1276400c9bc3023463976b2d0beda8b09439e0e05ac3dd0228b
|
data/CHANGELOG.md
CHANGED
data/lib/itamae/resource/file.rb
CHANGED
@@ -84,23 +84,22 @@ module Itamae
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def action_edit(options)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
mode = run_specinfra(:get_file_mode, attributes.path).stdout.chomp
|
91
|
-
run_specinfra(:change_file_mode,
|
87
|
+
change_target = attributes.modified ? @temppath : attributes.path
|
88
|
+
|
89
|
+
if attributes.mode || attributes.modified
|
90
|
+
mode = attributes.mode || run_specinfra(:get_file_mode, attributes.path).stdout.chomp
|
91
|
+
run_specinfra(:change_file_mode, change_target, mode)
|
92
92
|
end
|
93
93
|
|
94
|
-
if attributes.owner || attributes.group
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
group = run_specinfra(:get_file_owner_group, attributes.path).stdout.chomp
|
99
|
-
run_specinfra(:change_file_owner, @temppath, owner)
|
100
|
-
run_specinfra(:change_file_group, @temppath, group)
|
94
|
+
if attributes.owner || attributes.group || attributes.modified
|
95
|
+
owner = attributes.owner || run_specinfra(:get_file_owner_user, attributes.path).stdout.chomp
|
96
|
+
group = attributes.group || run_specinfra(:get_file_owner_group, attributes.path).stdout.chomp
|
97
|
+
run_specinfra(:change_file_owner, change_target, owner, group)
|
101
98
|
end
|
102
99
|
|
103
|
-
|
100
|
+
if attributes.modified
|
101
|
+
run_specinfra(:move_file, @temppath, attributes.path)
|
102
|
+
end
|
104
103
|
end
|
105
104
|
|
106
105
|
private
|
data/lib/itamae/version.rb
CHANGED
@@ -216,6 +216,14 @@ describe file('/tmp/file_edit_keeping_mode_owner') do
|
|
216
216
|
it { should be_grouped_into "itamae" }
|
217
217
|
end
|
218
218
|
|
219
|
+
describe file('/tmp/file_edit_with_content_change_updates_timestamp') do
|
220
|
+
its(:mtime) { should be > DateTime.iso8601("2016-05-02T01:23:45Z") }
|
221
|
+
end
|
222
|
+
|
223
|
+
describe file('/tmp/file_edit_without_content_change_keeping_timestamp') do
|
224
|
+
its(:mtime) { should eq(DateTime.iso8601("2016-05-02T12:34:56Z")) }
|
225
|
+
end
|
226
|
+
|
219
227
|
describe file('/home/itamae2') do
|
220
228
|
it { should be_directory }
|
221
229
|
it { should be_owned_by "itamae2" }
|
@@ -240,3 +248,10 @@ describe file('/tmp/file_without_content_change_updates_mode_and_owner') do
|
|
240
248
|
it { should be_grouped_into "itamae2" }
|
241
249
|
end
|
242
250
|
|
251
|
+
describe file('/tmp/file_with_content_change_updates_timestamp') do
|
252
|
+
its(:mtime) { should be > DateTime.iso8601("2016-05-01T01:23:45Z") }
|
253
|
+
end
|
254
|
+
|
255
|
+
describe file('/tmp/file_without_content_change_keeping_timestamp') do
|
256
|
+
its(:mtime) { should eq(DateTime.iso8601("2016-05-01T12:34:56Z")) }
|
257
|
+
end
|
@@ -402,6 +402,28 @@ end
|
|
402
402
|
|
403
403
|
###
|
404
404
|
|
405
|
+
execute "f=/tmp/file_edit_with_content_change_updates_timestamp && echo 'Hello, world' > $f && touch -d 2016-05-02T01:23:45Z $f"
|
406
|
+
|
407
|
+
file "/tmp/file_edit_with_content_change_updates_timestamp" do
|
408
|
+
action :edit
|
409
|
+
block do |content|
|
410
|
+
content.gsub!('world', 'Itamae')
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
###
|
415
|
+
|
416
|
+
execute "touch -d 2016-05-02T12:34:56Z /tmp/file_edit_without_content_change_keeping_timestamp"
|
417
|
+
|
418
|
+
file "/tmp/file_edit_without_content_change_keeping_timestamp" do
|
419
|
+
action :edit
|
420
|
+
block do |content|
|
421
|
+
# no change
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
###
|
426
|
+
|
405
427
|
file '/tmp/file_without_content_change_updates_mode_and_owner' do
|
406
428
|
action :create
|
407
429
|
content 'Hello, world'
|
@@ -420,6 +442,22 @@ end
|
|
420
442
|
|
421
443
|
###
|
422
444
|
|
445
|
+
execute "touch -d 2016-05-01T01:23:45Z /tmp/file_with_content_change_updates_timestamp"
|
446
|
+
|
447
|
+
file "/tmp/file_with_content_change_updates_timestamp" do
|
448
|
+
content "Hello, world"
|
449
|
+
end
|
450
|
+
|
451
|
+
###
|
452
|
+
|
453
|
+
execute "f=/tmp/file_without_content_change_keeping_timestamp && echo 'Hello, world' > $f && touch -d 2016-05-01T12:34:56Z $f"
|
454
|
+
|
455
|
+
file "/tmp/file_without_content_change_keeping_timestamp" do
|
456
|
+
content "Hello, world\n"
|
457
|
+
end
|
458
|
+
|
459
|
+
###
|
460
|
+
|
423
461
|
unless run_command("echo -n Hello").stdout == "Hello"
|
424
462
|
raise "run_command in a recipe failed"
|
425
463
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -308,9 +308,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
308
308
|
version: '0'
|
309
309
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
310
310
|
requirements:
|
311
|
-
- - "
|
311
|
+
- - ">="
|
312
312
|
- !ruby/object:Gem::Version
|
313
|
-
version:
|
313
|
+
version: '0'
|
314
314
|
requirements: []
|
315
315
|
rubyforge_project:
|
316
316
|
rubygems_version: 2.5.1
|