Module: RunJS

Defined in:
lib/runjs.rb,
lib/runjs/os.rb,
lib/runjs/error.rb,
lib/runjs/runtime.rb,
lib/runjs/encoding.rb,
lib/runjs/runtimes/v8.rb,
lib/runjs/runtimes/node.rb,
lib/runjs/system_runtime.rb,
lib/runjs/runtimes/jscript.rb,
lib/runjs/runtimes/spider_monkey.rb,
lib/runjs/runtimes/the_ruby_racer.rb,
lib/runjs/runtimes/the_ruby_rhino.rb,
lib/runjs/runtimes/java_script_core.rb

Defined Under Namespace

Modules: Encoding, OS Classes: CompileError, D8, Error, JScript, JavaScriptCore, JavaScriptError, Node, Runtime, RuntimeUnavailable, SpiderMonkey, SystemRuntime, TheRubyRacer, TheRubyRhino, V8

Constant Summary collapse

VERSION =
'0.1.0'
RUNTIMES =
[TheRubyRacer, JavaScriptCore, V8, D8, Node, JScript,
TheRubyRhino, SpiderMonkey]

Class Method Summary collapse

Class Method Details

.apply(function, this, *args) ⇒ Object



45
46
47
# File 'lib/runjs.rb', line 45

def self.apply(function, this, *args)
  runtime.new.apply(function, this, *args)
end

.call(function, *args) ⇒ Object



41
42
43
# File 'lib/runjs.rb', line 41

def self.call(function, *args)
  runtime.new.call(function, *args)
end

.context(js) ⇒ Object



33
34
35
# File 'lib/runjs.rb', line 33

def self.context(js)
  runtime.new.context(js)
end

.eval(js) ⇒ Object



49
50
51
# File 'lib/runjs.rb', line 49

def self.eval(js)
  runtime.new.eval(js)
end

.run(js) ⇒ Object



37
38
39
# File 'lib/runjs.rb', line 37

def self.run(js)
  runtime.new.run(js)
end

.runtimeObject



27
28
29
30
31
# File 'lib/runjs.rb', line 27

def self.runtime
  @runtime ||= from_environment(ENV['RUNJS_RUNTIME']) ||
               RUNTIMES.reject(&:deprecated?).find(&:available?) ||
               raise(RuntimeUnavailable)
end

.runtime=(runtime) ⇒ Object

Raises:



22
23
24
25
# File 'lib/runjs.rb', line 22

def self.runtime=(runtime)
  raise RuntimeUnavailable, runtime unless runtime.available?
  @runtime = runtime
end