Class: Polytrix::Runners::MixlibShellOutExecutor

Inherits:
Object
  • Object
show all
Includes:
DefaultLogger
Defined in:
lib/polytrix/runners/mixlib_shellout_executor.rb

Defined Under Namespace

Classes: OutputDecorator

Instance Method Summary collapse

Methods included from DefaultLogger

included

Methods included from DefaultLogger::ClassMethods

#logger

Instance Method Details

#execute(command, opts) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/polytrix/runners/mixlib_shellout_executor.rb', line 32

def execute(command, opts)
  prefix = opts.delete :prefix
  shell = Mixlib::ShellOut.new(command, opts)
  shell.live_stream = log_decorator $stdout, prefix
  shell.run_command
  execution_result = ExecutionResult.new exitstatus: shell.exitstatus, stdout: shell.stdout, stderr: shell.stderr
  begin
    shell.error!
  rescue Mixlib::ShellOut::ShellCommandFailed => e
    execution_error = ExecutionError.new(e)
    execution_error.execution_result = execution_result
    raise execution_error
  end

  execution_result
end

#log_decorator(io, prefix) ⇒ Object



26
27
28
29
30
# File 'lib/polytrix/runners/mixlib_shellout_executor.rb', line 26

def log_decorator(io, prefix)
  # OutputDecorator.new(io, prefix) unless Polytrix.configuration.suppress_output
  # logger = Logging.logger['polytrix::exec']
  IOToLog.new(logger)
end