Class: Bcome::Command::Local
- Inherits:
-
Object
- Object
- Bcome::Command::Local
- Defined in:
- lib/objects/command/local.rb
Instance Attribute Summary collapse
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Class Method Summary collapse
Instance Method Summary collapse
- #exit_code ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(command, success_exit_codes = [0]) ⇒ Local
constructor
A new instance of Local.
- #is_success? ⇒ Boolean
- #pretty_result ⇒ Object
- #syscall ⇒ Object
Constructor Details
#initialize(command, success_exit_codes = [0]) ⇒ Local
Returns a new instance of Local.
13 14 15 16 |
# File 'lib/objects/command/local.rb', line 13 def initialize(command, success_exit_codes = [0]) @command = command @success_exit_codes = success_exit_codes end |
Instance Attribute Details
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
11 12 13 |
# File 'lib/objects/command/local.rb', line 11 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
11 12 13 |
# File 'lib/objects/command/local.rb', line 11 def stdout @stdout end |
Class Method Details
.run(raw_command, _success_exit_codes = [0]) ⇒ Object
5 6 7 8 9 |
# File 'lib/objects/command/local.rb', line 5 def self.run(raw_command, _success_exit_codes = [0]) command = new(raw_command) command.syscall command end |
Instance Method Details
#exit_code ⇒ Object
24 25 26 |
# File 'lib/objects/command/local.rb', line 24 def exit_code @process_status ? @process_status.exitstatus : 1 end |
#failed? ⇒ Boolean
32 33 34 |
# File 'lib/objects/command/local.rb', line 32 def failed? !is_success? end |
#is_success? ⇒ Boolean
28 29 30 |
# File 'lib/objects/command/local.rb', line 28 def is_success? @success_exit_codes.include?(exit_code) end |
#pretty_result ⇒ Object
36 37 38 |
# File 'lib/objects/command/local.rb', line 36 def pretty_result is_success? ? "success / exit code: #{exit_code}".success : "failure / exit code: #{exit_code}".error end |
#syscall ⇒ Object
18 19 20 21 22 |
# File 'lib/objects/command/local.rb', line 18 def syscall @stdout, @stderr, @process_status = Open3.capture3(@command) rescue Exception => e @stderr = e. end |