Module: Opal::CliRunners
- Defined in:
- opal/lib/opal/cli_runners.rb,
opal/lib/opal/cli_runners/gjs.rb,
opal/lib/opal/cli_runners/deno.rb,
opal/lib/opal/cli_runners/chrome.rb,
opal/lib/opal/cli_runners/nodejs.rb,
opal/lib/opal/cli_runners/safari.rb,
opal/lib/opal/cli_runners/server.rb,
opal/lib/opal/cli_runners/firefox.rb,
opal/lib/opal/cli_runners/nashorn.rb,
opal/lib/opal/cli_runners/quickjs.rb,
opal/lib/opal/cli_runners/mini_racer.rb,
opal/lib/opal/cli_runners/applescript.rb
Overview
Opal::CliRunners
is the register in which JavaScript runners can be
defined for use by Opal::CLI
. Runners will be called via the #call
method and passed a Hash containing the following keys:
options
: a hash of options for the runner
output
: an IO-like object responding to #write
and #puts
argv
: is the arguments vector coming from the CLI that is being
forwarded to the program
builder
: a proc returning a new instance of Opal::Builder so it
can be re-created and pick up the most up-to-date sources
Runners can be registered using #register_runner(name, runner)
.
Defined Under Namespace
Classes: Applescript, Chrome, Compiler, Deno, Firefox, Gjs, MiniRacer, Nashorn, Nodejs, Quickjs, RunnerError, Safari, Server
Class Method Summary
collapse
Class Method Details
.[](name) ⇒ Object
32
33
34
|
# File 'opal/lib/opal/cli_runners.rb', line 32
def self.[](name)
@register[name.to_sym]&.call
end
|
.[]=(name, runner) ⇒ Object
37
38
39
40
41
|
# File 'opal/lib/opal/cli_runners.rb', line 37
def self.[]=(name, runner)
warn "Overwriting Opal CLI runner: #{name}" if @register.key? name.to_sym
@register[name.to_sym] = runner
end
|
.alias_runner(new_name, old_name) ⇒ Object
68
69
70
71
72
|
# File 'opal/lib/opal/cli_runners.rb', line 68
def self.alias_runner(new_name, old_name)
self[new_name.to_sym] = -> { self[old_name.to_sym] }
nil
end
|
.register_runner(name, runner, path = nil) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'opal/lib/opal/cli_runners.rb', line 53
def self.register_runner(name, runner, path = nil)
autoload runner, path if path
@runners.push(runner.to_s)
if runner.respond_to? :call
self[name] = -> { runner }
else
self[name] = -> { const_get(runner) }
end
nil
end
|
.registered_runners ⇒ Object
26
27
28
|
# File 'opal/lib/opal/cli_runners.rb', line 26
def self.registered_runners
@runners
end
|
.to_h ⇒ Object
44
45
46
|
# File 'opal/lib/opal/cli_runners.rb', line 44
def self.to_h
@register
end
|