Sha256: c205b4aafc79f4f124c1b5ba4b418a97920002f0bcf49e480b0d97ebab495acb

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require "rbconfig"

module ExecJS
  class Error < ::StandardError; end
  class RuntimeError    < Error; end
  class ProgramError    < Error; end

  autoload :ExternalRuntime,  "execjs/external_runtime"
  autoload :MustangRuntime,   "execjs/mustang_runtime"
  autoload :RubyRacerRuntime, "execjs/ruby_racer_runtime"
  autoload :RubyRhinoRuntime, "execjs/ruby_rhino_runtime"
  autoload :Runtimes,         "execjs/runtimes"

  def self.exec(source)
    runtime.exec(source)
  end

  def self.eval(source)
    runtime.eval(source)
  end

  def self.compile(source)
    runtime.compile(source)
  end

  def self.runtimes
    Runtimes.runtimes
  end

  def self.runtime
    @runtime ||= Runtimes.best_available ||
      raise(ExecJS::RuntimeError, "Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.")
  end

  def self.root
    @root ||= File.expand_path("../execjs", __FILE__)
  end

  def self.windows?
    @windows ||= RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
  end

  # Eager detect runtime
  self.runtime
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
execjs-0.3.4 lib/execjs.rb
execjs-0.3.3 lib/execjs.rb