Class: Kward::Sandbox::CommandRunner
- Inherits:
-
Object
- Object
- Kward::Sandbox::CommandRunner
- Defined in:
- lib/kward/sandbox/command_runner.rb
Overview
Base command runner. Platform runners provide an argv that is then executed through LocalCommandRunner, preserving Kward's timeout and cancellation behavior.
Direct Known Subclasses
LinuxBubblewrapRunner, MacOSSeatbeltRunner, PassthroughRunner, UnavailableRunner
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
Instance Method Summary collapse
- #command_argv(command, cwd:) ⇒ Object
-
#initialize(policy:, capabilities:) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
- #run(command, cwd:, timeout_seconds:, max_output_bytes:, cancellation: nil, &block) ⇒ Object
Constructor Details
#initialize(policy:, capabilities:) ⇒ CommandRunner
Returns a new instance of CommandRunner.
9 10 11 12 |
# File 'lib/kward/sandbox/command_runner.rb', line 9 def initialize(policy:, capabilities:) @policy = policy @capabilities = capabilities end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
14 15 16 |
# File 'lib/kward/sandbox/command_runner.rb', line 14 def capabilities @capabilities end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
14 15 16 |
# File 'lib/kward/sandbox/command_runner.rb', line 14 def policy @policy end |
Instance Method Details
#command_argv(command, cwd:) ⇒ Object
23 24 25 |
# File 'lib/kward/sandbox/command_runner.rb', line 23 def command_argv(command, cwd:) raise NotImplementedError, "#{self.class} must implement #command_argv" end |
#run(command, cwd:, timeout_seconds:, max_output_bytes:, cancellation: nil, &block) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/kward/sandbox/command_runner.rb', line 16 def run(command, cwd:, timeout_seconds:, max_output_bytes:, cancellation: nil, &block) LocalCommandRunner.new( timeout_seconds: timeout_seconds, max_output_bytes: max_output_bytes ).run(*command_argv(command, cwd: cwd), cwd: cwd, cancellation: cancellation, &block) end |