Class: OpalFiles
Overview
Sets up the maps for the opal assets, and source maps if enabled.
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
- #add_asset_folders(environment) ⇒ Object
-
#initialize(builder, app_path, component_paths) ⇒ OpalFiles
constructor
A new instance of OpalFiles.
Constructor Details
#initialize(builder, app_path, component_paths) ⇒ OpalFiles
Returns a new instance of OpalFiles.
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 |
# File 'lib/volt/server/rack/opal_files.rb', line 7 def initialize(builder, app_path, component_paths) ::Opal::Processor.source_map_enabled = Volt.source_maps? # Opal::Processor.arity_check_enabled = true # Opal::Processor.dynamic_require_severity = :raise @component_paths = component_paths @environment = Opal::Environment.new # Since the scope changes in builder blocks, we need to capture # environment in closure environment = @environment environment.cache = Sprockets::Cache::FileStore.new("./tmp") environment.append_path(app_path) volt_gem_lib_path = File.(File.join(File.dirname(__FILE__), "../../..")) environment.append_path(volt_gem_lib_path) add_asset_folders(environment) # Add the opal load paths Opal.paths.each do |path| environment.append_path(path) end # opal-jquery gem spec = Gem::Specification.find_by_name("opal-jquery") environment.append_path(spec.gem_dir + "/opal") builder.map '/assets' do run environment end if Volt.source_maps? source_maps = SourceMapServer.new(environment) builder.map(source_maps.prefix) do run source_maps end end end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
5 6 7 |
# File 'lib/volt/server/rack/opal_files.rb', line 5 def environment @environment end |
Instance Method Details
#add_asset_folders(environment) ⇒ Object
50 51 52 53 54 |
# File 'lib/volt/server/rack/opal_files.rb', line 50 def add_asset_folders(environment) @component_paths.asset_folders do |asset_folder| environment.append_path(asset_folder) end end |