Sha256: ca7c50c6e1bc111e12852d2b4b38417e1acf3023080e2c93d29011aad4759cff

Contents?: true

Size: 942 Bytes

Versions: 5

Compression:

Stored size: 942 Bytes

Contents

require 'mattock/command-task'
module Mattock
  class RemoteCommandTask < CommandTask
    setting(:remote_server, nested(
      :address => nil,
      :user => nil
    ))
    setting(:ssh_options, [])
    nil_fields(:id_file, :free_arguments)

    def decorated(command_on_remote)
      fail "Need remote server for #{self.class.name}" unless remote_server.address

      raise "Empty remote command" if command_on_remote.nil?
      Mattock::WrappingChain.new do |cmd|
        cmd.add Mattock::CommandLine.new("ssh") do |cmd|
          cmd.options << "-u #{remote_server.user}" if remote_server.user
          cmd.options << "-i #{id_file}" if id_file
          unless ssh_options.empty?
            ssh_options.each do |opt|
              cmd.options "-o #{opt}"
            end
          end
          cmd.options << remote_server.address
        end
        cmd.add Mattock::ShellEscaped.new(command_on_remote)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mattock-0.1.3 lib/mattock/remote-command-task.rb
mattock-0.1.2 lib/mattock/remote-command-task.rb
mattock-0.1.1 lib/mattock/remote-command-task.rb
mattock-0.1.0 lib/mattock/remote-command-task.rb
mattock-0.0.1 lib/mattock/remote-command-task.rb