Skip to content
This repository
tag: v2.0.0.pre2
Fetching contributors…

Cannot retrieve contributors at this time

file 55 lines (44 sloc) 1.073 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
require "stackdeck"
require 'date'
require "generator"

# the 'public' interface
require "johnson/error"
require "johnson/runtime"
require "johnson/ruby_land_proxy"
require "johnson/parser"

# visitable module and visitors
require "johnson/visitable"
require "johnson/visitors"

# parse tree nodes
require "johnson/nodes"

module Johnson
  VERSION = "2.0.0.pre2"

  def self.version
    VERSION
  end

  ###
  # 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.
  def self.evaluate(expression, vars={})
    runtime = Johnson::Runtime.new
    vars.each { |key, value| runtime[key] = value }

    runtime.evaluate(expression)
  end

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

  ###
  # Create a new runtime and load all +files+.
  #
  # Returns the new Johnson::Runtime.
  def self.load(*files)
    rt = Johnson::Runtime.new
    rt.load(*files)
    rt
  end
  
  def self.runtimes
    Runtime.runtimes
  end

end
Something went wrong with that request. Please try again.