Module: ProcessHelper
Overview
Makes it easy to spawn Ruby sub-processes with guaranteed exit status handling, capturing and/or suppressing combined STDOUT and STDERR streams, providing STDIN input, timeouts, and running via a pseudo terminal.
Full documentation at github.com/thewoolleyman/process_helper
Defined Under Namespace
Classes: EmptyCommandError, InvalidOptionsError, TimeoutError, UnexpectedExitStatusError, UnprocessedInputError
Constant Summary collapse
- VERSION =
Don’t forget to keep version in sync with gemspec
'0.1.1'.freeze
Instance Method Summary collapse
Instance Method Details
#process(cmd, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/process_helper.rb', line 18 def process(cmd, = {}) cmd = cmd.to_s fail ProcessHelper::EmptyCommandError, 'command must not be empty' if cmd.empty? = .dup () puts cmd if [:log_cmd] output, process_status = if [:pseudo_terminal] process_with_pseudo_terminal(cmd, ) else process_with_popen(cmd, ) end handle_exit_status(cmd, , output, process_status) output end |