Sha256: 567201bc9019f35aa7fb0cc27e8f826996ba08c237fccbe7eb3df156bcb894bd
Contents?: true
Size: 644 Bytes
Versions: 2
Compression:
Stored size: 644 Bytes
Contents
module Gorillib::CheckedPopen module_function def checked_popen(command, mode, fail_action, io_class=IO) check_child_exit_status do io_class.popen(command, mode) do |process| yield(process) end end rescue Errno::EPIPE fail_action.call end # @private NO_EXIT_STATUS = OpenStruct.new(:exitstatus => 0) def check_child_exit_status result = yield status = $? || NO_EXIT_STATUS unless [0, 172].include?(status.exitstatus) raise ArgumentError, "Command exited with status '#{status.exitstatus}'" end result end end ::IO.class_eval do include Gorillib::CheckedPopen end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gorillib-0.4.0pre | lib/gorillib/io/system_helpers.rb |
gorillib-0.4.1pre | lib/gorillib/io/system_helpers.rb |