Module: Opal::CliRunners
- Defined in:
- lib/opal/cli_runners.rb,
lib/opal/cli_runners/gjs.rb,
lib/opal/cli_runners/deno.rb,
lib/opal/cli_runners/chrome.rb,
lib/opal/cli_runners/nodejs.rb,
lib/opal/cli_runners/safari.rb,
lib/opal/cli_runners/server.rb,
lib/opal/cli_runners/firefox.rb,
lib/opal/cli_runners/nashorn.rb,
lib/opal/cli_runners/quickjs.rb,
lib/opal/cli_runners/mini_racer.rb,
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 '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 '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 '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 '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 'lib/opal/cli_runners.rb', line 26
def self.registered_runners
@runners
end
|
.to_h ⇒ Object
44
45
46
|
# File 'lib/opal/cli_runners.rb', line 44
def self.to_h
@register
end
|