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: eea572157a09
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: 143f6f2edc53
Choose a head ref
  • 5 commits
  • 5 files changed
  • 1 contributor

Commits on May 14, 2015

  1. Copy the full SHA
    a45d5a8 View commit details
  2. Bump opal version

    elia committed May 14, 2015
    Copy the full SHA
    4f09c49 View commit details
  3. Use fsync to ensure the file is written

    Never trust `sleep`.
    elia committed May 14, 2015
    Copy the full SHA
    d9a0959 View commit details
  4. Copy the full SHA
    b617b53 View commit details
  5. Copy the full SHA
    143f6f2 View commit details
Showing with 15 additions and 9 deletions.
  1. +3 −4 app/controllers/opal_spec_controller.rb
  2. +1 −1 lib/opal/rails/engine.rb
  3. +1 −1 opal-rails.gemspec
  4. +5 −3 spec/integration/source_map_spec.rb
  5. +5 −0 test_app/config/environments/test.rb
7 changes: 3 additions & 4 deletions app/controllers/opal_spec_controller.rb
Original file line number Diff line number Diff line change
@@ -7,12 +7,11 @@ class OpalSpecController < ActionController::Base
helper_method :check_errors_for

def run
logical_path = builder.runner_logical_path+'.js'
logical_path = builder.runner_logical_path
sprockets = Rails.application.config.assets
runner = builder.runner_pathname

runner.open('w') { |f| f << builder.main_code }
sleep 0.1 unless sprockets[logical_path]
runner.open('w') { |f| f << builder.main_code; f.fsync }
sprockets[logical_path]
end


2 changes: 1 addition & 1 deletion lib/opal/rails/engine.rb
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ class Engine < ::Rails::Engine
end

app.routes.prepend do
if Opal::Processor.source_map_enabled && config.assets.compile
if Opal::Processor.source_map_enabled && config.assets.compile && config.assets.debug
maps_prefix = '/__OPAL_SOURCE_MAPS__'
maps_app = Opal::SourceMapServer.new(app.assets, maps_prefix)

2 changes: 1 addition & 1 deletion opal-rails.gemspec
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
required_ruby_version = '>= 1.9.3'

s.add_dependency 'rails', '>= 3.2', '< 5.0'
s.add_dependency 'opal', '~> 0.8.0.dev'
s.add_dependency 'opal', '~> 0.8.0.beta'
s.add_dependency 'opal-jquery', '~> 0.3.0'
s.add_dependency 'opal-rspec', '~> 0.4.2'
s.add_dependency 'jquery-rails'
8 changes: 5 additions & 3 deletions spec/integration/source_map_spec.rb
Original file line number Diff line number Diff line change
@@ -2,10 +2,12 @@
require 'opal/source_map'

describe Opal::SourceMap do
let(:js_asset_path) { '/assets/source_map_example.js' }
let(:js_asset_path) { '/assets/source_map_example.self.js' }

before do
expect(Rails.application.config.opal.source_map_enabled).to be_truthy
expect(Rails.application.config.assets.compile).to be_truthy
expect(Rails.application.config.assets.debug).to be_truthy
get js_asset_path
end

@@ -32,8 +34,8 @@

def extract_map_path response
source_map_regexp = %r{^//[@#] sourceMappingURL=([^\n]+)}
header_map_path = response.headers['X-SourceMap']
comment_map_path = response.body.scan(source_map_regexp).flatten.first.to_s.strip
header_map_path = response.headers['X-SourceMap'].presence
comment_map_path = response.body.scan(source_map_regexp).flatten.first.to_s.strip.presence

header_map_path or comment_map_path
end
5 changes: 5 additions & 0 deletions test_app/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -34,4 +34,9 @@
config.active_support.deprecation = :stderr

config.eager_load = false if Rails.version.to_i == 4


# Allow sourcemaps to be compiled in test mode
config.assets.debug = true
config.assets.compile = true
end