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-06 21:57:51 -05:00
|
|
|
autoload :ExternalRuntime, "execjs/external_runtime"
|
2011-02-07 10:01:34 -05:00
|
|
|
autoload :RhinoRuntime, "execjs/rhino_runtime"
|
2011-02-06 21:57:51 -05:00
|
|
|
autoload :Runtimes, "execjs/runtimes"
|
2011-02-06 23:52:13 -05:00
|
|
|
autoload :V8Runtime, "execjs/v8_runtime"
|
2011-02-06 20:09:07 -05:00
|
|
|
|
|
|
|
def self.exec(source)
|
|
|
|
runtime.exec(source)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.eval(source)
|
|
|
|
runtime.eval(source)
|
|
|
|
end
|
|
|
|
|
|
|
|
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-06 15:22:40 -05:00
|
|
|
end
|