Sha256: de8926d02443f5f4d3f7eaaadcfe385b29416073d3fbfbfb811266b35337dc04

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require 'opal/compiler'
require 'opal/builder'
require 'opal/erb'
require 'opal/sprockets'
require 'opal/version'

# Opal is a ruby to javascript compiler, with a runtime for running
# in any javascript environment.
module Opal
  def self.gem_dir
    File.expand_path('..', __FILE__.untaint)
  end

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

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

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

  def self.use_gem(gem_name, include_dependecies = true)
    spec = Gem::Specification.find_by_name(gem_name)

    spec.runtime_dependencies.each do |dependency|
      use_gem dependency.name
    end if include_dependecies

    Opal.append_path File.join(spec.gem_dir, 'lib')
  end

  # Private, don't add to these directly (use .append_path instead).
  def self.paths
    @paths ||= [core_dir.untaint, std_dir.untaint, gem_dir.untaint]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opal-0.6.3 lib/opal.rb
opal-0.6.2 lib/opal.rb
opal-0.6.1 lib/opal.rb
opal-0.6.0 lib/opal.rb