Module: EacRubyUtils::Envs::BaseCommand::Execution
- Defined in:
- lib/eac_ruby_utils/envs/base_command/execution.rb
Instance Method Summary collapse
- #execute(options = {}) ⇒ Object
- #execute!(options = {}) ⇒ Object
- #spawn(options = {}) ⇒ Object
- #system(options = {}) ⇒ Object
- #system!(options = {}) ⇒ Object
Instance Method Details
#execute(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 28 def execute( = {}) c = command() debug_print("BEFORE: #{c}") t1 = Time.now r = run_callbacks :any_execution, :execute do ::EacRubyUtils::Envs::Process.new(c).to_h end i = Time.now - t1 debug_print("AFTER [#{i}]: #{c}") r end |
#execute!(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 19 def execute!( = {}) [:exit_outputs] = status_results.merge([:exit_outputs].presence || {}) er = ::EacRubyUtils::Envs::ExecutionResult.new(execute(), ) return er.result if er.success? raise ::EacRubyUtils::Envs::ExecutionError, "execute! command failed: #{self}\n#{er.r.pretty_inspect}" end |
#spawn(options = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 40 def spawn( = {}) c = command() debug_print("SPAWN: #{c}") run_callbacks :any_execution, :spawn do ::EacRubyUtils::Envs::Spawn.new(c) end end |
#system(options = {}) ⇒ Object
54 55 56 57 58 |
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 54 def system( = {}) c = command() debug_print(c) run_callbacks(:any_execution, :system) { Kernel.system(c) } end |
#system!(options = {}) ⇒ Object
48 49 50 51 52 |
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 48 def system!( = {}) return if system() raise ::EacRubyUtils::Envs::ExecutionError, "system! command failed: #{self}" end |