Module: EacRubyUtils::Envs::BaseCommand::Execution

Defined in:
lib/eac_ruby_utils/envs/base_command/execution.rb

Instance Method Summary collapse

Instance Method Details

#execute(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 22

def execute(options = {})
  c = command(options)
  debug_print("BEFORE: #{c}")
  t1 = Time.now
  r = ::EacRubyUtils::Envs::Process.new(c).to_h
  i = Time.now - t1
  debug_print("AFTER [#{i}]: #{c}")
  r
end

#execute!(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 13

def execute!(options = {})
  options[:exit_outputs] = status_results.merge(options[:exit_outputs].presence || {})
  er = ::EacRubyUtils::Envs::ExecutionResult.new(execute(options), options)
  return er.result if er.success?

  raise ::EacRubyUtils::Envs::ExecutionError,
        "execute! command failed: #{self}\n#{er.r.pretty_inspect}"
end

#spawn(options = {}) ⇒ Object



32
33
34
35
36
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 32

def spawn(options = {})
  c = command(options)
  debug_print("SPAWN: #{c}")
  ::EacRubyUtils::Envs::Spawn.new(c)
end

#system(options = {}) ⇒ Object



44
45
46
47
48
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 44

def system(options = {})
  c = command(options)
  debug_print(c)
  Kernel.system(c)
end

#system!(options = {}) ⇒ Object



38
39
40
41
42
# File 'lib/eac_ruby_utils/envs/base_command/execution.rb', line 38

def system!(options = {})
  return if system(options)

  raise ::EacRubyUtils::Envs::ExecutionError, "system! command failed: #{self}"
end