Module: ExecJS::Runtimes
- Defined in:
- lib/execjs/runtimes.rb
Constant Summary collapse
- RubyRacer =
RubyRacerRuntime.new
- RubyRhino =
RubyRhinoRuntime.new
- Johnson =
JohnsonRuntime.new
- Mustang =
MustangRuntime.new
- Node =
ExternalRuntime.new( :name => "Node.js (V8)", :command => ["nodejs", "node"], :runner_path => ExecJS.root + "/support/node_runner.js" )
- JavaScriptCore =
ExternalRuntime.new( :name => "JavaScriptCore", :command => "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", :runner_path => ExecJS.root + "/support/jsc_runner.js" )
- SpiderMonkey =
Spidermonkey = ExternalRuntime.new( :name => "SpiderMonkey", :command => "js", :runner_path => ExecJS.root + "/support/basic_runner.js" )
- JScript =
ExternalRuntime.new( :name => "JScript", :command => "cscript //E:jscript //Nologo", :runner_path => ExecJS.root + "/support/jscript_runner.js" )
Class Method Summary collapse
- .autodetect ⇒ Object
- .best_available ⇒ Object
- .from_environment ⇒ Object
- .names ⇒ Object
- .runtimes ⇒ Object
Class Method Details
.autodetect ⇒ Object
43 44 45 46 47 |
# File 'lib/execjs/runtimes.rb', line 43 def self.autodetect from_environment || best_available || raise(RuntimeUnavailable, "Could not find a JavaScript runtime. " + "See https://github.com/sstephenson/execjs for a list of available runtimes.") end |
.best_available ⇒ Object
49 50 51 |
# File 'lib/execjs/runtimes.rb', line 49 def self.best_available runtimes.find(&:available?) end |
.from_environment ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/execjs/runtimes.rb', line 53 def self.from_environment if name = ENV["EXECJS_RUNTIME"] if runtime = const_get(name) if runtime.available? runtime if runtime.available? else raise RuntimeUnavailable, "#{runtime.name} runtime is not available on this system" end elsif !name.empty? raise RuntimeUnavailable, "#{name} runtime is not defined" end end end |
.names ⇒ Object
67 68 69 |
# File 'lib/execjs/runtimes.rb', line 67 def self.names @names ||= constants.inject({}) { |h, name| h.merge(const_get(name) => name) }.values end |
.runtimes ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/execjs/runtimes.rb', line 71 def self.runtimes @runtimes ||= [ RubyRacer, RubyRhino, Johnson, Mustang, Node, JavaScriptCore, SpiderMonkey, JScript ] end |