Class: ConfigmonkeyCli::Application::ManifestAction::Copy

Inherits:
Base
  • Object
show all
Defined in:
lib/configmonkey_cli/application/manifest_actions/copy.rb

Instance Attribute Summary

Attributes inherited from Base

#app, #args, #manifest, #opts, #thor

Instance Method Summary collapse

Methods inherited from Base

#args_and_opts, #exists?, #expand_dst, #expand_src, #initialize, #rel, #to_s

Constructor Details

This class inherits a constructor from ConfigmonkeyCli::Application::ManifestAction::Base

Instance Method Details

#destructiveObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/configmonkey_cli/application/manifest_actions/copy.rb', line 23

def destructive
  absolute_source = File.join(thor.source_paths[0], @source)
  if FileTest.directory?(absolute_source)
    thor.directory(@source, @destination, @opts)
  else
    thor.copy_file(@source, @destination, @opts)
    if @opts[:chmod] && File.exist?(absolute_source) && File.exist?(@destination)
      mode = @opts[:chmod] == true ? File.stat(absolute_source).mode - 0100000 : @opts[:chmod]
      thor.chmod(@destination, mode) unless mode == File.stat(@destination).mode - 0100000
    end
  end
end

#init(hargs_and_opts = {}) ⇒ Object



5
6
7
# File 'lib/configmonkey_cli/application/manifest_actions/copy.rb', line 5

def init hargs_and_opts = {}
  @args, @opts = args_and_opts(hargs_and_opts)
end

#prepareObject



9
10
11
12
13
# File 'lib/configmonkey_cli/application/manifest_actions/copy.rb', line 9

def prepare
  @opts[:force] = app.opts[:default_yes]
  @source = @args[0]
  @destination = expand_dst(@args[1])
end

#simulateObject



15
16
17
18
19
20
21
# File 'lib/configmonkey_cli/application/manifest_actions/copy.rb', line 15

def simulate
  if thor.options[:pretend]
    destructive
  else
    status :fake, :black, rel(@destination)
  end
end