Class: ProcessExecuter::Command::Runner
- Inherits:
-
Object
- Object
- ProcessExecuter::Command::Runner
- Defined in:
- lib/process_executer/command/runner.rb
Overview
The Runner class executes subprocess commands and captures their status and output.
It does the following:
- Run commands (
call) with options for capturing output, handling timeouts, and merging stdout/stderr. - Process command results, including logging and error handling.
- Raise detailed exceptions for common command failures, such as timeouts or subprocess errors.
This class is used internally by ProcessExecuter.run.
Instance Attribute Summary collapse
-
#logger ⇒ Logger
readonly
The logger to use.
Instance Method Summary collapse
-
#call(*command, out: nil, err: nil, merge: false, raise_errors: true, **options_hash) ⇒ ProcessExecuter::Command::Result
Run a command and return the status including stdout and stderr output.
-
#initialize(logger) ⇒ Runner
constructor
Create a new RunCommand instance.
Constructor Details
#initialize(logger) ⇒ Runner
Create a new RunCommand instance
28 29 30 |
# File 'lib/process_executer/command/runner.rb', line 28 def initialize(logger) @logger = logger || Logger.new(nil) end |
Instance Attribute Details
#logger ⇒ Logger (readonly)
The logger to use
36 37 38 |
# File 'lib/process_executer/command/runner.rb', line 36 def logger @logger end |
Instance Method Details
#call(*command, out: nil, err: nil, merge: false, raise_errors: true, **options_hash) ⇒ ProcessExecuter::Command::Result
Run a command and return the status including stdout and stderr output
61 62 63 64 65 66 67 68 |
# File 'lib/process_executer/command/runner.rb', line 61 def call(*command, out: nil, err: nil, merge: false, raise_errors: true, **) out ||= StringIO.new err ||= (merge ? out : StringIO.new) status = spawn(command, out:, err:, **) process_result(command, status, out, err, [:timeout], raise_errors) end |