Class: Binaryen::Command
- Inherits:
-
Object
- Object
- Binaryen::Command
- Includes:
- POSIX::Spawn
- Defined in:
- lib/binaryen/command.rb
Constant Summary collapse
- DEFAULT_MAX_OUTPUT_SIZE =
256 MiB
256 * 1024 * 1024 * 1024
- DEFAULT_TIMEOUT =
10
- DEFAULT_ARGS_FOR_COMMAND =
{}.freeze
Instance Method Summary collapse
-
#initialize(cmd, timeout: DEFAULT_TIMEOUT, max_output_size: DEFAULT_MAX_OUTPUT_SIZE, ignore_missing: false) ⇒ Command
constructor
A new instance of Command.
- #run(*arguments, stdin: nil, stderr: nil) ⇒ Object
Constructor Details
#initialize(cmd, timeout: DEFAULT_TIMEOUT, max_output_size: DEFAULT_MAX_OUTPUT_SIZE, ignore_missing: false) ⇒ Command
Returns a new instance of Command.
14 15 16 17 18 19 |
# File 'lib/binaryen/command.rb', line 14 def initialize(cmd, timeout: DEFAULT_TIMEOUT, max_output_size: DEFAULT_MAX_OUTPUT_SIZE, ignore_missing: false) @cmd = command_path(cmd, ignore_missing) || raise(ArgumentError, "command not found: #{cmd}") @timeout = timeout @default_args = DEFAULT_ARGS_FOR_COMMAND.fetch(cmd, []) @max_output_size = max_output_size end |
Instance Method Details
#run(*arguments, stdin: nil, stderr: nil) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/binaryen/command.rb', line 21 def run(*arguments, stdin: nil, stderr: nil) args = [@cmd] + arguments + @default_args Timeout.timeout(@timeout) do spawn_command(*args, stderr: stderr, stdin: stdin) end end |