module Unravel
TODO: don't allow replacing the error
Constants
- VERSION
Public Class Methods
Capture(args)
click to toggle source
# File lib/unravel/exec.rb, line 56 def Capture(args) Unravel.logger.debug " -> Running: #{args.inspect}" out, error, status = Open3.capture3(*args) return out if status.success? Unravel.logger.debug "Errors from #{args.inspect}: -----" Unravel.logger.debug "#{error}" error = out if error.strip.empty? raise Exec::Error::Standard, error rescue Errno::ENOENT => e raise Exec::Error::ENOENT, e.message end
Exec(args)
click to toggle source
# File lib/unravel/exec.rb, line 40 def Exec(args) Unravel.logger.debug " -> Running: #{args.inspect}" out, error, status = Open3.capture3(*args) Unravel.logger.debug "Output from #{args.inspect}: -----" Unravel.logger.debug "#{out}" return true if status.success? Unravel.logger.debug "Errors from #{args.inspect}: -----" Unravel.logger.debug "#{error}" # TODO: is strip a good idea? raise Exec::Error::Silent.new(status.exitstatus, out) if error.strip.empty? raise Exec::Error::Standard, error rescue Errno::ENOENT => e raise Exec::Error::ENOENT, e.message end
logger()
click to toggle source
# File lib/unravel.rb, line 11 def self.logger @@logger ||= Logger.new(STDOUT).tap do |logger| logger.level = Logger::DEBUG logger.formatter = proc do |severity, datetime, progname, msg| "#{severity}: #{msg}\n" end end end
run(*args)
click to toggle source
# File lib/unravel/exec.rb, line 36 def run(*args) Exec(args) end