Class: Microsandbox::SshOutput
- Inherits:
-
Object
- Object
- Microsandbox::SshOutput
- Defined in:
- lib/microsandbox/ssh.rb
Overview
The result of an Microsandbox::SshClient#exec call. Like ExecOutput, ‘stdout`/`stderr` are the captured bytes decoded as UTF-8 (lenient); use `stdout_bytes`/ `stderr_bytes` for the raw ASCII-8BIT bytes.
Instance Attribute Summary collapse
-
#status ⇒ Integer
readonly
The remote command’s exit status.
-
#stderr_bytes ⇒ String
readonly
Raw stderr bytes (ASCII-8BIT).
-
#stdout_bytes ⇒ String
readonly
Raw stdout bytes (ASCII-8BIT).
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Whether the command exited non-zero.
-
#initialize(data) ⇒ SshOutput
constructor
A new instance of SshOutput.
- #inspect ⇒ Object
-
#stderr ⇒ String
Stderr decoded as UTF-8.
-
#stdout ⇒ String
Stdout decoded as UTF-8.
-
#success? ⇒ Boolean
Whether the command exited with status 0.
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ SshOutput
Returns a new instance of SshOutput.
15 16 17 18 19 20 |
# File 'lib/microsandbox/ssh.rb', line 15 def initialize(data) @status = data["status"] @success = data["success"] @stdout_bytes = data["stdout"] @stderr_bytes = data["stderr"] end |
Instance Attribute Details
#status ⇒ Integer (readonly)
Returns the remote command’s exit status.
9 10 11 |
# File 'lib/microsandbox/ssh.rb', line 9 def status @status end |
#stderr_bytes ⇒ String (readonly)
Returns raw stderr bytes (ASCII-8BIT).
13 14 15 |
# File 'lib/microsandbox/ssh.rb', line 13 def stderr_bytes @stderr_bytes end |
#stdout_bytes ⇒ String (readonly)
Returns raw stdout bytes (ASCII-8BIT).
11 12 13 |
# File 'lib/microsandbox/ssh.rb', line 11 def stdout_bytes @stdout_bytes end |
Instance Method Details
#failure? ⇒ Boolean
Returns whether the command exited non-zero.
26 |
# File 'lib/microsandbox/ssh.rb', line 26 def failure? = !@success |
#inspect ⇒ Object
40 41 42 43 |
# File 'lib/microsandbox/ssh.rb', line 40 def inspect "#<Microsandbox::SshOutput status=#{@status} success=#{@success} " \ "stdout=#{stdout.bytesize}B stderr=#{stderr.bytesize}B>" end |
#stderr ⇒ String
Returns stderr decoded as UTF-8.
34 35 36 |
# File 'lib/microsandbox/ssh.rb', line 34 def stderr @stderr ||= @stderr_bytes.dup.force_encoding(Encoding::UTF_8) end |
#stdout ⇒ String
Returns stdout decoded as UTF-8.
29 30 31 |
# File 'lib/microsandbox/ssh.rb', line 29 def stdout @stdout ||= @stdout_bytes.dup.force_encoding(Encoding::UTF_8) end |
#success? ⇒ Boolean
Returns whether the command exited with status 0.
23 |
# File 'lib/microsandbox/ssh.rb', line 23 def success? = @success |
#to_s ⇒ Object
38 |
# File 'lib/microsandbox/ssh.rb', line 38 def to_s = stdout |