Class: Opal::Environment
- Defined in:
- opal/lib/opal/sprockets/environment.rb
Overview
Environment is a subclass of Sprockets::Environment which already has our opal load paths loaded. This makes it easy for stand-alone rack apps, or test runners that have opal load paths ready to use. You can also add an existing gem's lib directory to our load path to use real gems inside your opal environment.
If you are running rails, then you just need opal-rails instead, which will do this for you.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(*args) ⇒ Environment
constructor
A new instance of Environment.
- #use_gem(gem_name) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Environment
Returns a new instance of Environment
21 22 23 24 |
# File 'opal/lib/opal/sprockets/environment.rb', line 21 def initialize *args super Opal.paths.each { |p| append_path p } end |
Instance Method Details
#use_gem(gem_name) ⇒ Object
26 27 28 |
# File 'opal/lib/opal/sprockets/environment.rb', line 26 def use_gem gem_name append_path File.join(Gem::Specification.find_by_name(gem_name).gem_dir, 'lib') end |