Class: Tomo::SSH::ConnectionValidator
- Inherits:
-
Object
- Object
- Tomo::SSH::ConnectionValidator
- Extended by:
- Forwardable
- Defined in:
- lib/tomo/ssh/connection_validator.rb
Instance Method Summary collapse
- #assert_valid_connection! ⇒ Object
- #assert_valid_executable! ⇒ Object
- #dump_env ⇒ Object
-
#initialize(executable, connection) ⇒ ConnectionValidator
constructor
A new instance of ConnectionValidator.
Constructor Details
#initialize(executable, connection) ⇒ ConnectionValidator
Returns a new instance of ConnectionValidator.
13 14 15 16 |
# File 'lib/tomo/ssh/connection_validator.rb', line 13 def initialize(executable, connection) @executable = executable @connection = connection end |
Instance Method Details
#assert_valid_connection! ⇒ Object
31 32 33 34 35 36 |
# File 'lib/tomo/ssh/connection_validator.rb', line 31 def assert_valid_connection! script = Script.new("echo hi", silent: !Tomo.debug?, echo: false, raise_on_error: false) res = connection.ssh_subprocess(script, verbose: Tomo.debug?) raise_connection_failure(res) if res.exit_status == 255 raise_unknown_error(res) if res.failure? || res.stdout.chomp != "hi" end |
#assert_valid_executable! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tomo/ssh/connection_validator.rb', line 18 def assert_valid_executable! result = begin ChildProcess.execute(executable, "-V") rescue StandardError => e handle_bad_executable(e) end Tomo.logger.debug(result.output) return if result.success? && supported?(result.output) raise_unsupported_version(result.output) end |