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/tracemonkey/context.rb,
lib/johnson/tracemonkey/runtime.rb,
lib/johnson/tracemonkey/debugger.rb,
lib/johnson/visitors/dot_visitor.rb,
lib/johnson/visitors/ecma_visitor.rb,
lib/johnson/visitors/sexp_visitor.rb,
lib/johnson/tracemonkey/js_land_proxy.rb,
lib/johnson/tracemonkey/immutable_node.rb,
lib/johnson/tracemonkey/ruby_land_proxy.rb,
lib/johnson/visitors/enumerating_visitor.rb,
lib/johnson/tracemonkey/mutable_tree_visitor.rb

Overview

:nodoc:

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"2.0.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.



30
31
32
33
34
35
# File 'lib/johnson.rb', line 30

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.



45
46
47
48
49
# File 'lib/johnson.rb', line 45

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

.parse(js, *args) ⇒ Object



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

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

.runtimesObject



51
52
53
# File 'lib/johnson.rb', line 51

def self.runtimes
  Runtime.runtimes
end

.versionObject



21
22
23
# File 'lib/johnson.rb', line 21

def self.version
  VERSION
end