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: 7ade0083d47b
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: ff6e647efd91
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 30, 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
    da8ebf9 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
    ff6e647 View commit details
Showing with 14 additions and 4 deletions.
  1. +5 −1 app/controllers/opal_spec_controller.rb
  2. +8 −2 lib/opal/rails/spec_builder.rb
  3. +1 −1 lib/tasks/opal-rails_tasks.rake
6 changes: 5 additions & 1 deletion app/controllers/opal_spec_controller.rb
Original file line number Diff line number Diff line change
@@ -6,9 +6,13 @@ class OpalSpecController < ActionController::Base
helper_method :spec_files, :pattern, :clean_spec_path, :runner_name

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

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


10 changes: 8 additions & 2 deletions lib/opal/rails/spec_builder.rb
Original file line number Diff line number Diff line change
@@ -51,11 +51,17 @@ def main_code
end

def runner_pathname
@runner_pathname ||= runner_dir.join("opal_spec_runner_#{digest}.js.rb")
runner_dir.join("#{runner_logical_path}.js.rb")
end

def runner_logical_path
"opal_spec_runner_#{digest}"
end

def digest
Digest::SHA1.new.update(requires.join).to_s
# The digest is cached as it shouldn't change
# for a given builder instance
@digest ||= Digest::SHA1.new.update(requires.join).to_s
end

def requires
2 changes: 1 addition & 1 deletion lib/tasks/opal-rails_tasks.rake
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ Opal::RSpec::RakeTask.new('opal:spec' => :environment) do |server|
server.sprockets.clear_paths
builder.paths.each { |path| server.append_path path }

main_name = runner.basename.to_s.gsub(/(\.js)?\.rb$/, '')
main_name = builder.runner_logical_path

# Sometimes seems that sprockets will need a moment to pickup the new file
sleep 0.1 unless server.sprockets[main_name]