Sha256: 4ae1f81552cf39e9f4abe8694730777f7ca189132bd846fea8a9365be5247200

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

module ConfigmonkeyCli
  class Application
    module ManifestAction
      class Template < 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 = File.join(thor.destination_root, @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)
            status :invalid, :red, "directory not allowed for template", :red
          else
            thor.template(@source, @destination, @opts.merge(context: binding))
            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/template.rb
configmonkey_cli-1.0.3 lib/configmonkey_cli/application/manifest_actions/template.rb
configmonkey_cli-1.0.2 lib/configmonkey_cli/application/manifest_actions/template.rb
configmonkey_cli-1.0.1 lib/configmonkey_cli/application/manifest_actions/template.rb
configmonkey_cli-1.0.0 lib/configmonkey_cli/application/manifest_actions/template.rb