Sha256: 4cb38b1856abc7081074849735a942c40756fa34259d41ff77deeffa607818d8

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 Bytes

Contents

require 'forwardable'
require 'shellwords'

module Taketo
  module Commands
    class SSHCommand
      extend Forwardable
      include Shellwords

      def initialize(server, options = {})
        @server = server
        @environment = @server.environment
      end

      def render(command)
        %Q[ssh -t #{port} #{username}#{host} "#{command.render(@server)}"].squeeze(" ")
      end

      def host
        unless @server.host
          raise ArgumentError, "host for server #{@server.name} in #{@environment.name} is not defined!"
        end
        shellescape @server.host
      end

      def port
        %Q[-p #{@server.port}] if @server.port
      end

      def username
        %Q[#{shellescape @server.username}@] if @server.username
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
taketo-0.0.4 lib/taketo/commands/ssh_command.rb
taketo-0.0.3 lib/taketo/commands/ssh_command.rb
taketo-0.0.2 lib/taketo/commands/ssh_command.rb