Class: ShellHelpers::ProcessStatus
- Inherits:
-
Object
- Object
- ShellHelpers::ProcessStatus
- Defined in:
- lib/shell_helpers/run.rb
Overview
ProcessStatus {{{ from methadone (process_status.rb; last import v1.3.1-2-g9be3b5a)
A wrapper/enhancement of Process::Status that handles coercion and expected nonzero statuses
Instance Attribute Summary collapse
-
#exitstatus ⇒ Object
readonly
The exit status, either directly from a Process::Status, from the exit code, or derived from a non-Int value.
-
#status ⇒ Object
readonly
The exit status, either directly from a Process::Status, from the exit code, or derived from a non-Int value.
Instance Method Summary collapse
-
#initialize(status, expected = nil) ⇒ ProcessStatus
constructor
Create the ProcessStatus with the given status.
-
#success? ⇒ Boolean
True if the exit status was a successul (i.e. expected) one.
Constructor Details
#initialize(status, expected = nil) ⇒ ProcessStatus
Create the ProcessStatus with the given status. respond to success?,exitstatus,status
status:: if this responds to #exitstatus, that method is used to extract the exit code. If it's an Int, that is used as the exit code. Otherwise, it's truthiness is used: 0 for truthy, 1 for falsey. expected:: an Int or Array of Int representing the expected exit status, other than zero, that represent "success". Ex usage: stdout,stderr,status = DR::Run.run_command(command,*opts) process_status = DR::ProcessStatus.new(status,expected)
225 226 227 228 229 |
# File 'lib/shell_helpers/run.rb', line 225 def initialize(status,expected=nil) @status=status @exitstatus = derive_exitstatus(status) @success = ([0] + Array(expected)).include?(@exitstatus) end |
Instance Attribute Details
#exitstatus ⇒ Object (readonly)
The exit status, either directly from a Process::Status, from the exit code, or derived from a non-Int value.
216 217 218 |
# File 'lib/shell_helpers/run.rb', line 216 def exitstatus @exitstatus end |
#status ⇒ Object (readonly)
The exit status, either directly from a Process::Status, from the exit code, or derived from a non-Int value.
216 217 218 |
# File 'lib/shell_helpers/run.rb', line 216 def status @status end |
Instance Method Details
#success? ⇒ Boolean
True if the exit status was a successul (i.e. expected) one.
232 233 234 |
# File 'lib/shell_helpers/run.rb', line 232 def success? @success end |