Class: Arver::SSHCommandWrapper
- Inherits:
-
CommandWrapper
- Object
- CommandWrapper
- Arver::SSHCommandWrapper
- Defined in:
- lib/arver/ssh_command_wrapper.rb
Instance Attribute Summary collapse
-
#as_root ⇒ Object
Returns the value of attribute as_root.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
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_root ⇒ Object
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 |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/arver/ssh_command_wrapper.rb', line 4 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
4 5 6 |
# File 'lib/arver/ssh_command_wrapper.rb', line 4 def port @port end |
#user ⇒ Object
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_command ⇒ Object
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 |