Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal-rails
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ab4748cb9f67^
Choose a base ref
...
head repository: opal/opal-rails
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ac8f9754d6e3
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 1, 2015

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    ab4748c View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    6ab546a View commit details
  3. Quotes

    elia committed Apr 1, 2015

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    4df1c03 View commit details
  4. debug

    elia committed Apr 1, 2015

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    ac8f975 View commit details
Showing with 26 additions and 10 deletions.
  1. +6 −0 README.md
  2. +4 −3 app/helpers/opal_helper.rb
  3. +16 −7 lib/opal/rails/engine.rb
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -37,6 +37,12 @@ module MyApp
config.opal.optimized_operators = true
config.opal.arity_check = false
config.opal.const_missing = true
config.opal.dynamic_require_severity = :ignore

# Enable/disable /opal_specs route
config.opal.enable_specs = true

config.opal.spec_location = 'spec-opal'
end
end
```
7 changes: 4 additions & 3 deletions app/helpers/opal_helper.rb
Original file line number Diff line number Diff line change
@@ -6,12 +6,13 @@ def opal_tag(&block)
end

def javascript_include_tag(*sources)
sources_copy = sources.dup.tap(&:extract_options!)
options = sources.extract_options!.stringify_keys
sprockets = Rails.application.assets

script_tags = super
script_tags = []

sources_copy.map do |source|
sources.map do |source|
script_tags << super(source, options)
loading_code = Opal::Processor.load_asset_code(sprockets, source)
script_tags << javascript_tag(loading_code) if loading_code.present?
end
23 changes: 16 additions & 7 deletions lib/opal/rails/engine.rb
Original file line number Diff line number Diff line change
@@ -9,8 +9,12 @@ class Engine < ::Rails::Engine
config.app_generators.javascript_engine :opal

config.opal = ActiveSupport::OrderedOptions.new

config.opal.enable_specs = true

# new default location, override-able in a Rails initializer
config.opal.spec_location = "spec-opal"
config.opal.spec_location = 'spec-opal'

config.opal.dynamic_require_severity = :ignore

# Cache eager_load_paths now, otherwise the assets dir is added
@@ -22,12 +26,15 @@ class Engine < ::Rails::Engine
end

initializer 'opal.asset_paths', :after => 'sprockets.environment', :group => :all do |app|
spec_location = app.root.join(app.config.opal.spec_location).to_s
runner_dir = ::Opal::Rails::SpecBuilder.runner_dir(app.root)
runner_dir.mkpath
if app.config.opal.enable_specs
spec_location = app.root.join(app.config.opal.spec_location).to_s
runner_dir = ::Opal::Rails::SpecBuilder.runner_dir(app.root)
runner_dir.mkpath

app.assets.append_path runner_dir.to_s
app.assets.append_path spec_location
end

app.assets.append_path runner_dir.to_s
app.assets.append_path spec_location
Opal.paths.each do |path|
app.assets.append_path path
end
@@ -53,7 +60,9 @@ class Engine < ::Rails::Engine
mount maps_app => maps_prefix
end

get '/opal_spec' => 'opal_spec#run', as: :opal_spec
if app.config.opal.enable_specs
get '/opal_spec' => 'opal_spec#run', as: :opal_spec
end
end
end