Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 51 lines (42 sloc) 1.283 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
module ExecJS
  module Runtimes
    RubyRacer = RubyRacerRuntime.new

    RubyRhino = RubyRhinoRuntime.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/basic_runner.js",
      :conversion => { :from => "ISO8859-1", :to => "UTF-8" }
    )

    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"
    )


    def self.best_available
      runtimes.find(&:available?)
    end

    def self.runtimes
      @runtimes ||= [
        RubyRacer,
        RubyRhino,
        Mustang,
        Node,
        JavaScriptCore,
        Spidermonkey,
        JScript
      ]
    end
  end
end
Something went wrong with that request. Please try again.