1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #23369 from maclover7/actioncable-assets-redux

Action Cable Assets Compilation redux
This commit is contained in:
Matthew Draper 2016-02-01 05:02:42 +10:30
commit ca9603fc35
11 changed files with 49 additions and 7 deletions

2
actioncable/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/lib/assets/javascripts/action_cable.js
/tmp

View file

@ -1,4 +1,8 @@
require 'rake/testtask'
require 'pathname'
require 'sprockets'
require 'coffee-script'
require 'action_cable'
dir = File.dirname(__FILE__)
@ -11,3 +15,34 @@ Rake::TestTask.new do |t|
t.verbose = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end
namespace :assets do
desc "Compile dist/action_cable.js"
task :compile do
puts 'Compiling Action Cable assets...'
asset_mapping = { "source.js" => "action_cable.js" }
root_path = Pathname.new(dir)
load_path = root_path.join("app/assets/javascripts/action_cable")
destination_path = root_path.join("lib/assets/javascripts")
compile_path = root_path.join("tmp/sprockets")
compile_path.rmtree if compile_path.exist?
compile_path.mkpath
environment = Sprockets::Environment.new
environment.append_path(load_path)
manifest = Sprockets::Manifest.new(environment.index, compile_path)
manifest.compile(asset_mapping.keys)
asset_mapping.each do |logical_path, dist_path|
fingerprint_path = manifest.assets[logical_path]
FileUtils.cp(compile_path.join(fingerprint_path), destination_path.join(dist_path))
end
puts '======'
puts 'Action Cable assets compiled successfully!'
end
end

View file

@ -24,9 +24,12 @@ Gem::Specification.new do |s|
s.add_dependency 'nio4r', '~> 1.2'
s.add_dependency 'websocket-driver', '~> 0.6.1'
s.add_development_dependency 'em-hiredis', '~> 0.3.0'
s.add_development_dependency 'coffee-script', '~> 2.4.1'
s.add_development_dependency 'coffee-script-source', '~> 1.10.0'
s.add_development_dependency 'em-hiredis', '~> 0.3.0'
s.add_development_dependency 'mocha'
s.add_development_dependency 'pg'
s.add_development_dependency 'puma'
s.add_development_dependency 'redis', '~> 3.0'
s.add_development_dependency 'redis', '~> 3.0'
s.add_development_dependency 'sprockets', '~> 3.5.2'
end

View file

@ -0,0 +1 @@
//= require_tree ./source

View file

@ -1,7 +1,7 @@
#= require action_cable/connection
#= require action_cable/connection_monitor
#= require action_cable/subscriptions
#= require action_cable/subscription
#= require ./connection
#= require ./connection_monitor
#= require ./subscriptions
#= require ./subscription
# The ActionCable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,
# the ActionCable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.

View file

@ -1,5 +1,5 @@
#= require_self
#= require action_cable/consumer
#= require ./consumer
@ActionCable =
INTERNAL: <%= ActionCable::INTERNAL.to_json %>

View file

@ -48,6 +48,7 @@ directory "pkg"
task gem => %w(update_versions pkg) do
cmd = ""
cmd << "cd #{framework} && " unless framework == "rails"
cmd << "bundle exec rake assets:compile && " if framework == "actioncable"
cmd << "gem build #{gemspec} && mv #{framework}-#{version}.gem #{root}/pkg/"
sh cmd
end