module Opal

def self.add_opal_location_to_error(opal_location, error)

def self.add_opal_location_to_error(opal_location, error)
  backtrace = error.backtrace.to_a
  backtrace.unshift opal_location.to_s
  error.set_backtrace backtrace
  error
end

def self.append_path(path)

Opal.
here should only be paths which contain code targeted at being compiled by
has access to should add a load path through this method. Load paths added
Add a file path to opals load path. Any gem containing ruby code that Opal
def self.append_path(path)
  append_paths(path)
end

def self.append_paths(*paths)

Same as #append_path but can take multiple paths.
def self.append_paths(*paths)
  @paths.concat(paths)
  nil
end

def self.compile(source, options = {})

Returns:
  • (String) - javascript code

Parameters:
  • options (Hash) -- compiler options
  • source (String) -- ruby source

Other tags:
    See: Opal::Compiler.new - for compiler options
def self.compile(source, options = {})
  Compiler.new(source, options).compile
end

def self.core_dir

def self.core_dir
  File.expand_path('../../../opal', __FILE__.dup.untaint)
end

def self.gem_dir

def self.gem_dir
  File.expand_path('../..', __FILE__.dup.untaint)
end

def self.opal_location_from_error(error)

def self.opal_location_from_error(error)
  opal_location = OpalBacktraceLocation.new
  opal_location.location = error.location if error.respond_to?(:location)
  opal_location.diagnostic = error.diagnostic if error.respond_to?(:diagnostic)
  opal_location
end

def self.paths

def self.paths
  @paths.dup.freeze
end

def self.reset_paths!

(includes `corelib`, `stdlib`, `opal/lib`, `ast` gem and `parser` gem)
Resets Opal.paths to the default value
def self.reset_paths!
  @paths = [core_dir.untaint, std_dir.untaint, gem_dir.untaint]
  if RUBY_ENGINE != 'opal'
    use_gem 'ast'
    use_gem 'parser'
  end
  nil
end

def self.std_dir

def self.std_dir
  File.expand_path('../../../stdlib', __FILE__.dup.untaint)
end