Class: Spatula::SshCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/spatula/ssh_command.rb

Direct Known Subclasses

Cook, Prepare

Class Method Summary collapse

Instance Method Summary collapse

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, =nil, identity=nil, upload_key=nil, key_file=nil, ruby_version=nil)
  @server = server
  @port   = port
  @port_switch = port ? " -p #{port}" : '' 
  @login_switch =  ? "-l #{}" : ''
  @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_optsObject



26
27
28
# File 'lib/spatula/ssh_command.rb', line 26

def ssh_opts
  "#@port_switch #@login_switch #@identity_switch"
end