Class: Chagall::Ssh

Inherits:
Object
  • Object
show all
Defined in:
lib/chagall/ssh.rb

Constant Summary collapse

DEFAULT_SSH_ARGS =
"-o StrictHostKeyChecking=no -o ServerAliveInterval=60".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server: Settings.instance.options[:server], ssh_args: DEFAULT_SSH_ARGS, logger:) ⇒ Ssh

Returns a new instance of Ssh.



9
10
11
12
13
# File 'lib/chagall/ssh.rb', line 9

def initialize(server: Settings.instance.options[:server], ssh_args: DEFAULT_SSH_ARGS, logger:)
  @server = server
  @ssh_args = ssh_args
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/chagall/ssh.rb', line 5

def logger
  @logger
end

#serverObject (readonly)

Returns the value of attribute server.



5
6
7
# File 'lib/chagall/ssh.rb', line 5

def server
  @server
end

#ssh_argsObject (readonly)

Returns the value of attribute ssh_args.



5
6
7
# File 'lib/chagall/ssh.rb', line 5

def ssh_args
  @ssh_args
end

Instance Method Details

#command(command, directory: nil, tty: false) ⇒ Object



22
23
24
# File 'lib/chagall/ssh.rb', line 22

def command(command, directory: nil, tty: false)
  build_command(command, directory, tty)
end

#execute(command, directory: nil, tty: false) ⇒ Object



15
16
17
18
19
20
# File 'lib/chagall/ssh.rb', line 15

def execute(command, directory: nil, tty: false)
  cmd = build_command(command, directory, tty)
  logger.debug "SSH: #{cmd}" if logger.debug?
  system(cmd)
  $CHILD_STATUS.success?
end