Module: Opal::CliRunners
- Defined in:
- opal/lib/opal/cli_runners.rb,
 opal/lib/opal/cli_runners/gjs.rb,
 opal/lib/opal/cli_runners/chrome.rb,
 opal/lib/opal/cli_runners/nodejs.rb,
 opal/lib/opal/cli_runners/server.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- #writeand- #puts
- argv: is the arguments vector coming from the CLI that is being forwarded to the program
- builder: the current instance of Opal::Builder
Runners can be registered using #register_runner(name, runner).
Defined Under Namespace
Classes: Applescript, Chrome, Gjs, MiniRacer, Nashorn, Nodejs, Quickjs, RunnerError, Server
Constant Summary collapse
- Compiler =
          The compiler runner will just output the compiled JavaScript 
- ->(data) { = data[:options] || {} builder = data.fetch(:builder) map_file = [:map_file] output = data.fetch(:output) compiled_source = builder.to_s compiled_source += "\n" + builder.source_map.to_data_uri_comment unless [:no_source_map] output.puts compiled_source File.write(map_file, builder.source_map.to_json) if map_file 0 } 
Class Method Summary collapse
- .[](name) ⇒ Object
- .[]=(name, runner) ⇒ Object
- 
  
    
      .alias_runner(new_name, old_name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Alias a runner name. 
- .register_runner(name, runner, path = nil) ⇒ Object
- .to_h ⇒ Object
Class Method Details
.[](name) ⇒ Object
| 23 24 25 | # File 'opal/lib/opal/cli_runners.rb', line 23 def self.[](name) @register[name.to_sym] end | 
.[]=(name, runner) ⇒ Object
| 28 29 30 31 32 | # File 'opal/lib/opal/cli_runners.rb', line 28 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
Alias a runner name
| 57 58 59 60 61 | # File 'opal/lib/opal/cli_runners.rb', line 57 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
| 44 45 46 47 48 49 50 51 52 53 54 | # File 'opal/lib/opal/cli_runners.rb', line 44 def self.register_runner(name, runner, path = nil) autoload runner, path if path if runner.respond_to?(:call) self[name] = runner else self[name] = ->(data) { const_get(runner).call(data) } end nil end | 
.to_h ⇒ Object
| 35 36 37 | # File 'opal/lib/opal/cli_runners.rb', line 35 def self.to_h @register end |