Module: Johnson

Defined in:
lib/johnson/cli.rb,
lib/johnson.rb,
lib/johnson/error.rb,
lib/johnson/parser.rb,
lib/johnson/runtime.rb,
lib/johnson/nodes/for.rb,
lib/johnson/visitable.rb,
lib/johnson/nodes/list.rb,
lib/johnson/nodes/node.rb,
lib/johnson/cli/options.rb,
lib/johnson/nodes/for_in.rb,
lib/johnson/nodes/function.rb,
lib/johnson/ruby_land_proxy.rb,
lib/johnson/visitors/visitor.rb,
lib/johnson/nodes/binary_node.rb,
lib/johnson/nodes/ternary_node.rb,
lib/johnson/parser/syntax_error.rb,
lib/johnson/spidermonkey/context.rb,
lib/johnson/spidermonkey/runtime.rb,
lib/johnson/visitors/dot_visitor.rb,
lib/johnson/spidermonkey/debugger.rb,
lib/johnson/visitors/ecma_visitor.rb,
lib/johnson/visitors/sexp_visitor.rb,
lib/johnson/spidermonkey/js_land_proxy.rb,
lib/johnson/spidermonkey/immutable_node.rb,
lib/johnson/spidermonkey/ruby_land_proxy.rb,
lib/johnson/visitors/enumerating_visitor.rb,
lib/johnson/spidermonkey/mutable_tree_visitor.rb

Overview

:nodoc:

Defined Under Namespace

Modules: CLI, Nodes, Parser, SpiderMonkey, Visitable, Visitors Classes: Error, RubyLandProxy, Runtime

Constant Summary collapse

VERSION =
"1.2.0"

Class Method Summary collapse

Class Method Details

.evaluate(expression, vars = {}) ⇒ Object

Evaluate the given JavaScript expression in a new runtime, after setting the given vars into the global object.

Returns the result of evaluating the given expression.



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

def self.evaluate(expression, vars={})
  runtime = Johnson::Runtime.new
  vars.each { |key, value| runtime[key] = value }

  runtime.evaluate(expression)
end

.load(*files) ⇒ Object

Create a new runtime and load all files.

Returns the new Johnson::Runtime.



42
43
44
45
46
# File 'lib/johnson.rb', line 42

def self.load(*files)
  rt = Johnson::Runtime.new
  rt.load(*files)
  rt
end

.parse(js, *args) ⇒ Object



34
35
36
# File 'lib/johnson.rb', line 34

def self.parse(js, *args)
  Johnson::Parser.parse(js, *args)
end