Class: Toys::Helpers::Exec::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/toys/helpers/exec.rb

Instance Method Summary collapse

Constructor Details

#initialize(context, opts, config) ⇒ Utils

Returns a new instance of Utils.



30
31
32
33
# File 'lib/toys/helpers/exec.rb', line 30

def initialize(context, opts, config)
  @context = context
  @config = config ? config.merge(opts) : opts
end

Instance Method Details

#handle_status(status) ⇒ Object



41
42
43
44
45
46
# File 'lib/toys/helpers/exec.rb', line 41

def handle_status(status)
  if status != 0 && @config[:report_subprocess_errors]
    @context.exit_with_code(status)
  end
  status
end

#log(cmd) ⇒ Object



35
36
37
38
39
# File 'lib/toys/helpers/exec.rb', line 35

def log(cmd)
  unless @config[:log_level] == false
    @context.logger.add(@config[:log_level] || Logger::INFO, cmd)
  end
end