Module: Ask::Sandbox

Defined in:
lib/ask/sandbox/base.rb,
lib/ask/sandbox/local.rb,
lib/ask/sandbox/docker.rb,
lib/ask/sandbox/daytona.rb,
lib/ask/sandbox/version.rb,
lib/ask-sandbox-providers.rb,
lib/ask/sandbox/cloudflare.rb

Defined Under Namespace

Classes: Base, Cloudflare, ConfigurationError, Daytona, Docker, Error, ExecutionError, Local, ProviderUnavailable, Result

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#exit_codeInteger? (readonly)

Returns process exit code (nil if killed by signal).

Returns:

  • (Integer, nil)

    process exit code (nil if killed by signal)



31
32
33
34
35
36
# File 'lib/ask/sandbox/base.rb', line 31

Result = Data.define(:stdout, :stderr, :exit_code, :timed_out) do
  # @return [Boolean] true if the command exited successfully (exit code 0)
  def success?
    exit_code == 0
  end
end

#stderrString (readonly)

Returns captured standard error.

Returns:

  • (String)

    captured standard error



31
32
33
34
35
36
# File 'lib/ask/sandbox/base.rb', line 31

Result = Data.define(:stdout, :stderr, :exit_code, :timed_out) do
  # @return [Boolean] true if the command exited successfully (exit code 0)
  def success?
    exit_code == 0
  end
end

#stdoutString (readonly)

Returns captured standard output.

Returns:

  • (String)

    captured standard output



31
32
33
34
35
36
# File 'lib/ask/sandbox/base.rb', line 31

Result = Data.define(:stdout, :stderr, :exit_code, :timed_out) do
  # @return [Boolean] true if the command exited successfully (exit code 0)
  def success?
    exit_code == 0
  end
end

#timed_outBoolean (readonly)

Returns whether execution was terminated due to timeout.

Returns:

  • (Boolean)

    whether execution was terminated due to timeout



31
32
33
34
35
36
# File 'lib/ask/sandbox/base.rb', line 31

Result = Data.define(:stdout, :stderr, :exit_code, :timed_out) do
  # @return [Boolean] true if the command exited successfully (exit code 0)
  def success?
    exit_code == 0
  end
end

Class Method Details

.providerAsk::Sandbox::Base

The currently configured sandbox provider. Defaults to Local (subprocess + rlimits).

Returns:



17
18
19
# File 'lib/ask-sandbox-providers.rb', line 17

def provider
  @provider ||= Ask::Sandbox::Local.new
end

.provider=(provider) ⇒ Object

Set the sandbox provider.

Parameters:

  • provider (Ask::Sandbox::Base, Symbol)

    Pass a provider instance, or :local/:docker/:daytona/:cloudflare to use a default instance of that provider.



26
27
28
29
30
31
# File 'lib/ask-sandbox-providers.rb', line 26

def provider=(provider)
  @provider = case provider
  when Symbol then resolve_provider(provider)
  else provider
  end
end