Sha256: ec2ee5a79dbce3ed4f6c96b3ca37d74c1b47d0acddf13a91ce19a867034145dc

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module Hookit
  module Resource
    class Scp < Base

      field :source
      field :destination
      field :port
      field :recursive
      field :config
      field :cipher
      field :identity
      field :ssh_options
      field :compression
      field :preserve

      actions :copy
      default_action :copy

      def initialize(name)
        source(name) unless source
        preserve(true) unless preserve
        recursive(true) unless recursive
        super
      end

      def run(action)
        case action
        when :copy
          copy!
        end
      end

      def copy!
        run_command! "scp -q#{preserve!}#{recursive!}B#{compression!} #{config!} #{port!} #{cipher!} #{identity!} #{ssh_options!} #{source} #{destination}"
      end

      def cipher!
        (return "-c #{cipher}") if cipher
        ""
      end

      def compression!
        (return "C") if compression
        ""
      end

      def config!
        (return "-F #{config}") if config
        ""
      end

      def identity!
        (return "-i #{identity}") if identity
        ""
      end

      def port!
        (return "-P #{port}") if port
        ""
      end

      def preserve!
        (return "p") if preserve
        ""
      end

      def recursive!
        (return "r") if recursive
        ""
      end

      def ssh_options!
        (return "-o #{ssh_options}") if ssh_options
        ""
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
micro-hookit-0.12.13 lib/hookit/resource/scp.rb
micro-hookit-0.12.12 lib/hookit/resource/scp.rb
micro-hookit-0.12.11 lib/hookit/resource/scp.rb