Class: Brut::CLI::ExecuteResult
- Inherits:
-
Object
- Object
- Brut::CLI::ExecuteResult
- Defined in:
- lib/brut/cli/execute_result.rb
Overview
Wraps the result of calling Brut::CLI::Commands::BaseCommand#execute and
interpreting it as an exit code
Instance Attribute Summary collapse
-
#actual_result ⇒ Object
readonly
Returns the value of attribute actual_result.
Instance Method Summary collapse
-
#exit_status {|error_message| ... } ⇒ Integer
Get the exit status for the given result.
-
#failed? ⇒ Boolean
-
#initialize(&block) ⇒ ExecuteResult
constructor
A new instance of ExecuteResult.
-
#success? ⇒ Boolean
Constructor Details
#initialize(&block) ⇒ ExecuteResult
Returns a new instance of ExecuteResult.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/brut/cli/execute_result.rb', line 5 def initialize(&block) @actual_result = begin block.() rescue Brut::CLI::Error => ex ex rescue => ex2 raise end end |
Instance Attribute Details
#actual_result ⇒ Object (readonly)
Returns the value of attribute actual_result.
4 5 6 |
# File 'lib/brut/cli/execute_result.rb', line 4 def actual_result @actual_result end |
Instance Method Details
#exit_status {|error_message| ... } ⇒ Integer
Get the exit status for the given result. This will call the block given with an error message if there is one.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/brut/cli/execute_result.rb', line 28 def exit_status(&) ||= ->(*){} case @actual_result in Integer @actual_result in Brut::CLI::SystemExecError .(@actual_result.) @actual_result.exit_status in Brut::CLI::Error .(@actual_result.) 1 else 0 end end |
#failed? ⇒ Boolean
17 |
# File 'lib/brut/cli/execute_result.rb', line 17 def failed? = !self.success? |
#success? ⇒ Boolean
16 |
# File 'lib/brut/cli/execute_result.rb', line 16 def success? = self.exit_status == 0 |