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 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.
4 5 6 7 8 9 10 |
# File 'lib/brut/cli/execute_result.rb', line 4 def initialize(&block) @actual_result = begin block.() rescue Brut::CLI::Error => ex ex end 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.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/brut/cli/execute_result.rb', line 24 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
13 |
# File 'lib/brut/cli/execute_result.rb', line 13 def failed? = !self.success? |
#success? ⇒ Boolean
12 |
# File 'lib/brut/cli/execute_result.rb', line 12 def success? = self.exit_status == 0 |