itamae 1.9.7.pre → 1.9.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 063ccd6fdae32d852d450265017ede39586ea176
4
- data.tar.gz: e4456e84fc2421e01c86247f926aa6625f6921c5
3
+ metadata.gz: 328f99ca3c77bdfb7dd735eaa16c740f42dbf8d8
4
+ data.tar.gz: b5c102ee7950c954c7b56bc146ebdfdf89512f16
5
5
  SHA512:
6
- metadata.gz: b88477096228dfad7451b746f41ccf727ee5ddf0b0da023d019e348467cd591e4f014cb4cd1417317599dbeb6e288e67657c775490db98b9064865e109d30191
7
- data.tar.gz: e73bfa3cf90a183b5e6ef4931679d56bf88d420d0c946c591fda609a167c3fb4d8cb9298565b5d0cd142f09badc8226e3d697d73c8c68bb4a64c01fd955d3206
6
+ metadata.gz: 81b4df62bf844dba2fba5b76b9126650cdc81666583c112bf6fb0fb14aeeb9dc054b0d920ae7289c2cb4e983219110e42448b4b5fa6a877a0cd904e27df18ff2
7
+ data.tar.gz: d9391e3125d6d7257f1819aa7a4afbab53d07573a3d786f894fcb8bbedf01be3a8dc00a7fb37d1276400c9bc3023463976b2d0beda8b09439e0e05ac3dd0228b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v1.9.8
2
+
3
+ Bugfixes
4
+
5
+ - [edit action of file resource: Keep mtime if no change](https://github.com/itamae-kitchen/itamae/pull/212)
6
+
1
7
  ## v1.9.7 (pre)
2
8
 
3
9
  Bugfixes
@@ -84,23 +84,22 @@ module Itamae
84
84
  end
85
85
 
86
86
  def action_edit(options)
87
- if attributes.mode
88
- run_specinfra(:change_file_mode, @temppath, attributes.mode)
89
- else
90
- mode = run_specinfra(:get_file_mode, attributes.path).stdout.chomp
91
- run_specinfra(:change_file_mode, @temppath, 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
- run_specinfra(:change_file_owner, @temppath, attributes.owner, attributes.group)
96
- else
97
- owner = run_specinfra(:get_file_owner_user, attributes.path).stdout.chomp
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
- run_specinfra(:move_file, @temppath, attributes.path)
100
+ if attributes.modified
101
+ run_specinfra(:move_file, @temppath, attributes.path)
102
+ end
104
103
  end
105
104
 
106
105
  private
@@ -1,3 +1,3 @@
1
1
  module Itamae
2
- VERSION = "1.9.7.pre"
2
+ VERSION = "1.9.8"
3
3
  end
@@ -17,6 +17,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
17
17
  mv /tmp/sources.list /etc/apt/sources.list
18
18
  apt-get update
19
19
  fi
20
+ echo America/New_York > /etc/timezone
21
+ dpkg-reconfigure --frontend noninteractive tzdata
20
22
  EOC
21
23
  end
22
24
 
@@ -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.7.pre
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-04-12 00:00:00.000000000 Z
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: 1.3.1
313
+ version: '0'
314
314
  requirements: []
315
315
  rubyforge_project:
316
316
  rubygems_version: 2.5.1