Class: FluentCommandBuilder::ExecutionContext
- Inherits:
-
Object
- Object
- FluentCommandBuilder::ExecutionContext
- Defined in:
- lib/fluent_command_builder/execution_context.rb
Instance Attribute Summary collapse
-
#executor ⇒ Object
Returns the value of attribute executor.
-
#printer ⇒ Object
Returns the value of attribute printer.
-
#should_fail_on_error ⇒ Object
Returns the value of attribute should_fail_on_error.
-
#should_print_on_execute ⇒ Object
Returns the value of attribute should_print_on_execute.
Instance Method Summary collapse
- #execute(command, visible_command = command) ⇒ Object
-
#initialize(executor) ⇒ ExecutionContext
constructor
A new instance of ExecutionContext.
Constructor Details
#initialize(executor) ⇒ ExecutionContext
Returns a new instance of ExecutionContext.
9 10 11 12 13 14 |
# File 'lib/fluent_command_builder/execution_context.rb', line 9 def initialize(executor) @executor = executor @should_print_on_execute = true @should_fail_on_error = true @printer = FluentCommandBuilder::Printer.new end |
Instance Attribute Details
#executor ⇒ Object
Returns the value of attribute executor.
7 8 9 |
# File 'lib/fluent_command_builder/execution_context.rb', line 7 def executor @executor end |
#printer ⇒ Object
Returns the value of attribute printer.
7 8 9 |
# File 'lib/fluent_command_builder/execution_context.rb', line 7 def printer @printer end |
#should_fail_on_error ⇒ Object
Returns the value of attribute should_fail_on_error.
7 8 9 |
# File 'lib/fluent_command_builder/execution_context.rb', line 7 def should_fail_on_error @should_fail_on_error end |
#should_print_on_execute ⇒ Object
Returns the value of attribute should_print_on_execute.
7 8 9 |
# File 'lib/fluent_command_builder/execution_context.rb', line 7 def should_print_on_execute @should_print_on_execute end |
Instance Method Details
#execute(command, visible_command = command) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/fluent_command_builder/execution_context.rb', line 16 def execute(command, visible_command=command) validate_should_print_on_execute validate_should_fail_on_error print_command visible_command @executor.execute(command) do |status| raise "Command failed with status (#{status.exitstatus}): [#{visible_command}]" if @should_fail_on_error && !status.success? end end |