Sha256: ad746218c21e3e8634a6cef1e7bb993aaefc6d580a6b609859d12e4788bd36b6
Contents?: true
Size: 860 Bytes
Versions: 2
Compression:
Stored size: 860 Bytes
Contents
require 'open3' module Hillary module Shellable class ExecutionError < StandardError attr_reader :command, :output, :status def initialize(command, output, status) message = "#{command}\n"\ "#{output}\n"\ "status: #{status}" super(message) @command = command @output = output @status = status end end def shell(command, options = {}) options = {ignore_errors: false, logger: Logger.new($stdout)}.merge(options) logger = options[:logger] logger.info(command) output = `#{command} 2>1` status = $? unless status.success? if options[:ignore_errors] logger.error(output) else raise ExecutionError.new(command, output, status.exitstatus) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hillary-0.0.3 | lib/hillary/shellable.rb |
hillary-0.0.2 | lib/hillary/shellable.rb |