class Remotus::Result
Class to standardize remote output from WinRM and SSH connections
Attributes
@return [String] executed command
@return [Integer] exit code
@return [String] all output (stdout and stderr interleaved)
@return [String] standard error output
@return [String] standard output
Public Class Methods
Creates a new Result
@param [String] command command executed @param [String] stdout standard output @param [String] stderr standard error output @param [String] output all output (stdout and stderr interleaved) @param [Integer] exit_code
exit code
# File lib/remotus/result.rb, line 32 def initialize(command, stdout, stderr, output, exit_code = nil) @command = command @stdout = stdout @stderr = stderr @output = output @exit_code = exit_code end
Public Instance Methods
Raises an exception if an error was encountered
@param [Array] accepted_exit_codes integer array of acceptable exit codes
# File lib/remotus/result.rb, line 65 def error!(accepted_exit_codes = [0]) return unless error?(accepted_exit_codes) raise Remotus::ResultError, "Error encountered executing #{@command}! Exit code #{@exit_code} was returned "\ "while a value in #{accepted_exit_codes} was expected.\n#{output}" end
Whether an error was encountered
@param [Array] accepted_exit_codes integer array of acceptable exit codes
@return [Boolean] Whether an error was encountered
# File lib/remotus/result.rb, line 56 def error?(accepted_exit_codes = [0]) !Array(accepted_exit_codes).include?(@exit_code) end
Whether the command was successful
@param [Array] accepted_exit_codes integer array of acceptable exit codes
@return [Boolean] Whether the command was successful
# File lib/remotus/result.rb, line 79 def success?(accepted_exit_codes = [0]) !error?(accepted_exit_codes) end
Alias for all interleaved stdout and stderr output
@return [String] interleaved output
# File lib/remotus/result.rb, line 45 def to_s output end