class SSHClient::ConfigItem
Constants
- DEFAULT_NAME
- READ_TIMEOUT
Attributes
debug[W]
hostname[RW]
logger[W]
name[R]
password[RW]
read_timeout[W]
transport[W]
username[RW]
Public Class Methods
new(name = nil)
click to toggle source
# File lib/ssh_client/config_item.rb, line 12 def initialize(name = nil) @name = name || DEFAULT_NAME @listeners = { stdout: Set.new, stderr: Set.new } add_listener { |data| logger.info "<< #{data}" } if default? end
Public Instance Methods
add_listener(*args, &blk)
click to toggle source
# File lib/ssh_client/config_item.rb, line 27 def add_listener(*args, &blk) Array(args || @listeners.keys).each do |k| @listeners[k] << blk end @cached_listeners = nil blk end
debug?()
click to toggle source
# File lib/ssh_client/config_item.rb, line 68 def debug? @debug || (default? ? false : SSHClient.config.debug?) end
default?()
click to toggle source
# File lib/ssh_client/config_item.rb, line 72 def default? name == DEFAULT_NAME end
listeners()
click to toggle source
# File lib/ssh_client/config_item.rb, line 19 def listeners @cached_listeners ||= if default? @listeners else @listeners.each { |k, l| l += SSHClient.config.listeners[k] } end end
logger()
click to toggle source
# File lib/ssh_client/config_item.rb, line 64 def logger @logger || (default? ? Logger.new(STDOUT) : SSHClient.config.logger) end
raise_on_errors=(value)
click to toggle source
# File lib/ssh_client/config_item.rb, line 54 def raise_on_errors=(value) if value @errors_listener = add_listener(:stderr) do |data| Thread.main.raise CommandExitWithError.new(data) if data end else remove_listener(@errors_listener, :stderr) if @errors_listener end end
read_timeout()
click to toggle source
# File lib/ssh_client/config_item.rb, line 42 def read_timeout @read_timeout || (default? ? READ_TIMEOUT : SSHClient.config.read_timeout) end
remove_listener(listener, io_type = nil)
click to toggle source
# File lib/ssh_client/config_item.rb, line 35 def remove_listener(listener, io_type = nil) Array(io_type || @listeners.keys).each do |k| @listeners[k].delete listener end @cached_listeners = nil end
transport()
click to toggle source
# File lib/ssh_client/config_item.rb, line 46 def transport transport_klass.new self end
transport_klass()
click to toggle source
# File lib/ssh_client/config_item.rb, line 50 def transport_klass @transport || (default? ? Transport::NetSSH : SSHClient.config.transport_klass) end