Class: Spatula::SshCommand
- Inherits:
-
Object
- Object
- Spatula::SshCommand
- Defined in:
- lib/spatula/ssh_command.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(server, port = nil, login = nil, identity = nil, upload_key = nil, key_file = nil, ruby_version = nil) ⇒ SshCommand
constructor
A new instance of SshCommand.
- #ssh(command) ⇒ Object
- #ssh_command(command) ⇒ Object
- #ssh_opts ⇒ Object
Constructor Details
#initialize(server, port = nil, login = nil, identity = nil, upload_key = nil, key_file = nil, ruby_version = nil) ⇒ SshCommand
Returns a new instance of SshCommand.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/spatula/ssh_command.rb', line 7 def initialize(server, port=nil, login=nil, identity=nil, upload_key=nil, key_file=nil, ruby_version=nil) @server = server @port = port @port_switch = port ? " -p #{port}" : '' @login_switch = login ? "-l #{login}" : '' @identity_switch = identity ? %Q|-i "#{identity}"| : '' @upload_key = upload_key @key_file = key_file @ruby_version = ruby_version end |
Class Method Details
.run(*args) ⇒ Object
3 4 5 |
# File 'lib/spatula/ssh_command.rb', line 3 def self.run(*args) new(*args).run end |
Instance Method Details
#ssh(command) ⇒ Object
18 19 20 |
# File 'lib/spatula/ssh_command.rb', line 18 def ssh(command) sh ssh_command(command) end |
#ssh_command(command) ⇒ Object
22 23 24 |
# File 'lib/spatula/ssh_command.rb', line 22 def ssh_command(command) %Q|ssh -t#{ssh_opts} #@server "#{command.gsub('"', '\\"')}"| end |
#ssh_opts ⇒ Object
26 27 28 |
# File 'lib/spatula/ssh_command.rb', line 26 def ssh_opts "#@port_switch #@login_switch #@identity_switch" end |