module ExecJS::Runtimes

Constants

Disabled
Duktape
JScript
JavaScriptCore
Node
RubyRacer
RubyRhino
SpiderMonkey

Public Class Methods

autodetect() click to toggle source
# File lib/execjs/runtimes.rb, line 46
def self.autodetect
  from_environment || best_available ||
    raise(RuntimeUnavailable, "Could not find a JavaScript runtime. " +
      "See https://github.com/rails/execjs for a list of available runtimes.")
end
best_available() click to toggle source
# File lib/execjs/runtimes.rb, line 52
def self.best_available
  runtimes.reject(&:deprecated?).find(&:available?)
end
from_environment() click to toggle source
# File lib/execjs/runtimes.rb, line 56
def self.from_environment
  if name = ENV["EXECJS_RUNTIME"]
    raise RuntimeUnavailable, "#{name} runtime is not defined" unless const_defined?(name)
    runtime = const_get(name)
    
    raise RuntimeUnavailable, "#{runtime.name} runtime is not available on this system" unless runtime.available?
    runtime
  end
end
names() click to toggle source
# File lib/execjs/runtimes.rb, line 66
def self.names
  @names ||= constants.inject({}) { |h, name| h.merge(const_get(name) => name) }.values
end
runtimes() click to toggle source
# File lib/execjs/runtimes.rb, line 70
def self.runtimes
  @runtimes ||= [
    RubyRacer,
    RubyRhino,
    Duktape,
    JavaScriptCore,
    Node,
    SpiderMonkey,
    JScript
  ]
end