Class: ProcessExecuter::Commands::Run Private
- Inherits:
-
SpawnWithTimeout
- Object
- SpawnWithTimeout
- ProcessExecuter::Commands::Run
- Defined in:
- lib/process_executer/commands/run.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Run a command and return the Result
Extends SpawnWithTimeout to provide the core functionality for ProcessExecuter.run.
It accepts all Process.spawn execution
options
plus the additional options timeout_after, raise_errors and logger.
This class wraps any stdout or stderr redirection destinations in a MonitoredPipe.
This allows any class that implements #write to be used as an output redirection
destination. This means that you can redirect to a StringIO which is not possible
with Process.spawn.
The wrapper pipes are kept in an internal hash that is combined with the
user's options only when Process.spawn is called. The options object the
caller gave is never modified, so it can be reused for another run and
result.options returns the destinations as the user configured them.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from SpawnWithTimeout
#command, #elapsed_time, #options, #pid, #result, #status, #timed_out
Instance Method Summary collapse
-
#call ⇒ ProcessExecuter::Result
private
Run a command and return the result.
-
#initialize(command, options) ⇒ Run
constructor
private
Create a new Run instance.
Constructor Details
#initialize(command, options) ⇒ Run
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new Run instance
42 43 44 45 |
# File 'lib/process_executer/commands/run.rb', line 42 def initialize(command, ) super @redirection_overrides = {} end |
Instance Method Details
#call ⇒ ProcessExecuter::Result
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run a command and return the result
Wrap the stdout and stderr redirection destinations in pipes and then execute the command.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/process_executer/commands/run.rb', line 74 def call opened_pipes = {} wrap_stdout_stderr(opened_pipes) super.tap do log_result raise_errors if .raise_errors end ensure close_pipes_and_check_errors(opened_pipes, $ERROR_INFO) end |