2011-02-07 13:48:15 -05:00
|
|
|
require "rbconfig"
|
|
|
|
|
2011-02-06 15:22:40 -05:00
|
|
|
module ExecJS
|
2011-02-06 19:59:37 -05:00
|
|
|
class Error < ::StandardError; end
|
|
|
|
class RuntimeError < Error; end
|
|
|
|
class ProgramError < Error; end
|
|
|
|
|
2011-02-09 01:30:39 -05:00
|
|
|
autoload :ExternalRuntime, "execjs/external_runtime"
|
|
|
|
autoload :RubyRacerRuntime, "execjs/ruby_racer_runtime"
|
|
|
|
autoload :RubyRhinoRuntime, "execjs/ruby_rhino_runtime"
|
|
|
|
autoload :Runtimes, "execjs/runtimes"
|
2011-02-06 20:09:07 -05:00
|
|
|
|
|
|
|
def self.exec(source)
|
|
|
|
runtime.exec(source)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.eval(source)
|
|
|
|
runtime.eval(source)
|
|
|
|
end
|
|
|
|
|
2011-02-09 22:27:56 -05:00
|
|
|
def self.runtimes
|
|
|
|
Runtimes.runtimes
|
|
|
|
end
|
|
|
|
|
2011-02-06 20:09:07 -05:00
|
|
|
def self.runtime
|
2011-02-06 21:44:01 -05:00
|
|
|
@runtime ||= Runtimes.best_available
|
2011-02-06 20:09:07 -05:00
|
|
|
end
|
2011-02-07 13:27:00 -05:00
|
|
|
|
|
|
|
def self.root
|
|
|
|
@root ||= File.expand_path("../execjs", __FILE__)
|
|
|
|
end
|
2011-02-07 13:48:15 -05:00
|
|
|
|
|
|
|
def self.windows?
|
|
|
|
@windows ||= RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
|
|
|
|
end
|
2011-02-06 15:22:40 -05:00
|
|
|
end
|