Class: Chagall::Ssh
- Inherits:
-
Object
- Object
- Chagall::Ssh
- Defined in:
- lib/chagall/ssh.rb
Constant Summary collapse
- DEFAULT_SSH_ARGS =
"-o StrictHostKeyChecking=no -o ServerAliveInterval=60".freeze
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#ssh_args ⇒ Object
readonly
Returns the value of attribute ssh_args.
Instance Method Summary collapse
- #command(command, directory: nil, tty: false) ⇒ Object
- #execute(command, directory: nil, tty: false) ⇒ Object
-
#initialize(server: Settings.instance.options[:server], ssh_args: DEFAULT_SSH_ARGS, logger:) ⇒ Ssh
constructor
A new instance of Ssh.
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.[:server], ssh_args: DEFAULT_SSH_ARGS, logger:) @server = server @ssh_args = ssh_args @logger = logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/chagall/ssh.rb', line 5 def logger @logger end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
5 6 7 |
# File 'lib/chagall/ssh.rb', line 5 def server @server end |
#ssh_args ⇒ Object (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 |