Class: Arver::SSHCommandWrapper

Inherits:
CommandWrapper show all
Defined in:
lib/arver/ssh_command_wrapper.rb

Instance Attribute Summary collapse

Attributes inherited from CommandWrapper

#arguments_array, #command, #output, #return_value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CommandWrapper

#execute, #run, #shellescape, #success?

Instance Attribute Details

#as_rootObject

Returns the value of attribute as_root.



4
5
6
# File 'lib/arver/ssh_command_wrapper.rb', line 4

def as_root
  @as_root
end

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/arver/ssh_command_wrapper.rb', line 4

def host
  @host
end

#portObject

Returns the value of attribute port.



4
5
6
# File 'lib/arver/ssh_command_wrapper.rb', line 4

def port
  @port
end

#userObject

Returns the value of attribute user.



4
5
6
# File 'lib/arver/ssh_command_wrapper.rb', line 4

def user
  @user
end

Class Method Details

.create(cmd, args, host, as_root = false) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/arver/ssh_command_wrapper.rb', line 6

def self.create( cmd, args, host, as_root = false )
  c = SSHCommandWrapper.new
  c.host= host
  c.as_root= as_root
  c.command= cmd
  c.arguments_array= args
  c
end

Instance Method Details

#escaped_commandObject



15
16
17
18
# File 'lib/arver/ssh_command_wrapper.rb', line 15

def escaped_command
  sudo = if as_root && host.username != "root" then "sudo" else "" end
  "ssh -p #{shellescape(host.port)} #{shellescape(host.username)}@#{shellescape(host.address)} #{sudo} #{super}" 
end