Class: Kobako::Execution
- Inherits:
-
Object
- Object
- Kobako::Execution
- Defined in:
- lib/kobako/execution.rb,
sig/kobako/execution.rbs
Overview
Kobako::Execution — the frozen result of one Sandbox#eval / #run: the
decoded #value plus the run's output captures and #usage. A successful
run returns it; a failed run raises an error carrying the same frozen
Execution on the error's #execution, so a rescue reads the captures and
usage exactly as a successful caller reads them off the return value. On a
failed run #value is nil — only the captures and usage are meaningful.
#failed? tells the returned Execution from the carried one even when both
#value are nil (a run whose last expression was nil versus a failed
one). It holds no reference to the raising error, so the error carries the
Execution but not the reverse.
Instance Attribute Summary collapse
-
#usage ⇒ Kobako::Usage
readonly
The
Kobako::Usageresource accounting for this run. -
#value ⇒ Object
readonly
The deserialized guest value the run produced;
nilon a failed run.
Instance Method Summary collapse
-
#failed? ⇒ Boolean
Returns
trueiff the run failed —falseon the Execution#eval/#runreturned,trueon the one a raised error carries. -
#initialize(value:, usage:, stdout:, stderr:, failed:) ⇒ Execution
constructor
A new instance of Execution.
-
#stderr ⇒ String
Bytes the guest wrote to stderr during this run.
-
#stderr_truncated? ⇒ Boolean
Returns
trueiff stderr capture reachedstderr_limitduring this run. -
#stdout ⇒ String
Bytes the guest wrote to stdout during this run as a UTF-8 String, clipped at
stdout_limit; the content carries no truncation sentinel, so use#stdout_truncated?to observe overflow. -
#stdout_truncated? ⇒ Boolean
Returns
trueiff stdout capture reachedstdout_limitduring this run.
Constructor Details
#initialize(value:, usage:, stdout:, stderr:, failed:) ⇒ Execution
Returns a new instance of Execution.
25 26 27 28 29 30 31 32 |
# File 'lib/kobako/execution.rb', line 25 def initialize(value:, usage:, stdout:, stderr:, failed:) @value = value @usage = usage @stdout_capture = stdout @stderr_capture = stderr @failed = failed freeze end |
Instance Attribute Details
#usage ⇒ Kobako::Usage (readonly)
The Kobako::Usage resource accounting for this run.
23 24 25 |
# File 'lib/kobako/execution.rb', line 23 def usage @usage end |
#value ⇒ Object (readonly)
The deserialized guest value the run produced; nil on a failed run.
20 21 22 |
# File 'lib/kobako/execution.rb', line 20 def value @value end |
Instance Method Details
#failed? ⇒ Boolean
Returns true iff the run failed — false on the Execution #eval /
#run returned, true on the one a raised error carries.
36 |
# File 'lib/kobako/execution.rb', line 36 def failed? = @failed |
#stderr ⇒ String
Bytes the guest wrote to stderr during this run. Mirror of #stdout.
44 |
# File 'lib/kobako/execution.rb', line 44 def stderr = @stderr_capture.bytes |
#stderr_truncated? ⇒ Boolean
Returns true iff stderr capture reached stderr_limit during this run.
50 |
# File 'lib/kobako/execution.rb', line 50 def stderr_truncated? = @stderr_capture.truncated? |
#stdout ⇒ String
Bytes the guest wrote to stdout during this run as a UTF-8 String,
clipped at stdout_limit; the content carries no truncation sentinel,
so use #stdout_truncated? to observe overflow.
41 |
# File 'lib/kobako/execution.rb', line 41 def stdout = @stdout_capture.bytes |
#stdout_truncated? ⇒ Boolean
Returns true iff stdout capture reached stdout_limit during this run.
47 |
# File 'lib/kobako/execution.rb', line 47 def stdout_truncated? = @stdout_capture.truncated? |