Sha256: 13d0034750e97f7824b67ccb9d19eef1ac94bd7f00a183c4f976c4d9568c019c

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

module ConfigmonkeyCli
  class Application
    module ManifestAction
      class Copy < Base
        def init hargs_and_opts = {}
          @args, @opts = args_and_opts(hargs_and_opts)
        end

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

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

        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
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
configmonkey_cli-1.0.4 lib/configmonkey_cli/application/manifest_actions/copy.rb
configmonkey_cli-1.0.3 lib/configmonkey_cli/application/manifest_actions/copy.rb
configmonkey_cli-1.0.2 lib/configmonkey_cli/application/manifest_actions/copy.rb
configmonkey_cli-1.0.1 lib/configmonkey_cli/application/manifest_actions/copy.rb
configmonkey_cli-1.0.0 lib/configmonkey_cli/application/manifest_actions/copy.rb