configmonkey_cli 1.0.4 → 1.0.5

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
  SHA256:
3
- metadata.gz: 99ff31b49f67bac7cc9d0e1695fbf7fa21e33d288301994b47c8e4b7ab6742ab
4
- data.tar.gz: 12aa92f2207ed7d6c748c04dedf8ce58d979e0c635e022b0aae6686f912b140b
3
+ metadata.gz: 391f6c9bbafb6e640823708c4cff1f0b5955436a65b986f4254c916784ad6816
4
+ data.tar.gz: eec65f85b8b493b2b7230905fa374de3652f1390124ed03feca376814200f38d
5
5
  SHA512:
6
- metadata.gz: c500d71590fac066406dc47b6544ee0de098e881e7c6c5ac440b45d38fd48d2696ff886fa1d6da065b1e0fc6d78dd3b8ee052106149ad3e13dacb4e153a1d02e
7
- data.tar.gz: 3200b1469a198e9dc067dd4d96d8fec97e2c0e4aa6bcf3ae9f6f4dc313bb788ae87f9d2fcbffa95106f67161a32fdc98756b7c7ff272d8ce23a8c65d0f12f5f6
6
+ metadata.gz: 41fae277325b89e41e69295403e6128a69a401f070a20ee4ca536a9a55bbcfd937268883b550617083aa5e21f6458213cba961fba5ddbd4dd7e26c07875be117
7
+ data.tar.gz: ee4cf475e8415e90ec9afe0177cc6e7ec3c2d17eacb28c681cbf389816eadd60202e5cfb23634b27c92400b6545b716ff5293021a56016bfbdd07a16be8ef0a8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
@@ -206,7 +206,8 @@ module ConfigmonkeyCli
206
206
 
207
207
  def push_action *args
208
208
  if $cm_current_action_index
209
- @actions.insert $cm_current_action_index + 1, [@host_constraint.dup] + args
209
+ $cm_current_action_index += 1
210
+ @actions.insert $cm_current_action_index, [@host_constraint.dup] + args
210
211
  else
211
212
  @actions.push [@host_constraint.dup] + args
212
213
  end
@@ -22,15 +22,31 @@ module ConfigmonkeyCli
22
22
 
23
23
  def destructive
24
24
  absolute_source = File.join(thor.source_paths[0], @source)
25
+ has_changed = !File.exist?(@destination)
26
+
27
+ if @opts[:after_change] && File.exist?(@destination)
28
+ has_changed = File.binread(absolute_source) != File.binread(@destination)
29
+ end
30
+
25
31
  if FileTest.directory?(absolute_source)
26
- thor.directory(@source, @destination, @opts)
32
+ _perform_directory(@source, @destination, @opts)
27
33
  else
28
- thor.copy_file(@source, @destination, @opts)
34
+ _perform_file(@source, @destination, @opts)
29
35
  if @opts[:chmod] && File.exist?(absolute_source) && File.exist?(@destination)
30
36
  mode = @opts[:chmod] == true ? File.stat(absolute_source).mode - 0100000 : @opts[:chmod]
31
37
  thor.chmod(@destination, mode) unless mode == File.stat(@destination).mode - 0100000
32
38
  end
33
39
  end
40
+
41
+ @opts[:after_change].call if has_changed && @opts[:after_change]
42
+ end
43
+
44
+ def _perform_directory(source, destination, opts)
45
+ thor.directory(source, destination, opts)
46
+ end
47
+
48
+ def _perform_file(source, destination, opts)
49
+ thor.copy_file(source, destination, opts)
34
50
  end
35
51
  end
36
52
  end
@@ -23,10 +23,10 @@ module ConfigmonkeyCli
23
23
  lines = res.split("\n")
24
24
  if code.exitstatus.zero?
25
25
  say padded("#{c "[OK]", :green} #{lines[0]}", :black)
26
- lines[1..-1].each{|l| say padded(" #{l}") }
26
+ lines[1..-1].each{|l| say padded(" #{l}") } if lines.length > 1
27
27
  else
28
28
  say padded("[#{code.exitstatus}] #{lines[0]}", :red)
29
- lines[1..-1].each{|l| say padded(" #{l}") }
29
+ lines[1..-1].each{|l| say padded(" #{l}") } if lines.length > 1
30
30
  raise "Invoked process exited with status #{code.exitstatus}: #{res}" if opts[:fail]
31
31
  end
32
32
  end
@@ -1,7 +1,7 @@
1
1
  module ConfigmonkeyCli
2
2
  class Application
3
3
  module ManifestAction
4
- class Template < Base
4
+ class Template < Copy
5
5
  def init hargs_and_opts = {}
6
6
  @args, @opts = args_and_opts(hargs_and_opts)
7
7
  end
@@ -20,17 +20,13 @@ module ConfigmonkeyCli
20
20
  end
21
21
  end
22
22
 
23
- def destructive
24
- absolute_source = File.join(thor.source_paths[0], @source)
25
- if FileTest.directory?(absolute_source)
26
- status :invalid, :red, "directory not allowed for template", :red
27
- else
28
- thor.template(@source, @destination, @opts.merge(context: binding))
29
- if @opts[:chmod] && File.exist?(absolute_source) && File.exist?(@destination)
30
- mode = @opts[:chmod] == true ? File.stat(absolute_source).mode - 0100000 : @opts[:chmod]
31
- thor.chmod(@destination, mode) unless mode == File.stat(@destination).mode - 0100000
32
- end
33
- end
23
+ def _perform_directory(source, destination, opts)
24
+ status :invalid, :red, "directory not allowed for template", :red
25
+ end
26
+
27
+ def _perform_file(source, destination, opts)
28
+ hostname = app.opts[:hostname]
29
+ thor.template(@source, @destination, @opts.merge(context: binding))
34
30
  end
35
31
  end
36
32
  end
@@ -1,4 +1,4 @@
1
1
  module ConfigmonkeyCli
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  UPDATE_URL = "https://raw.githubusercontent.com/2called-chaos/configmonkey_cli/master/VERSION"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configmonkey_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Pachnit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-31 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport