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

42 lines
1.1 KiB
Ruby

require 'rake/testtask'
require 'pathname'
require 'sprockets'
require 'coffee-script'
require 'action_cable'
dir = File.dirname(__FILE__)
task :default => :test
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = Dir.glob("#{dir}/test/**/*_test.rb")
t.warning = true
t.verbose = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end
namespace :assets do
desc "Compile dist/action_cable.js"
task :compile do
asset_mapping = { "source.js" => "action_cable.js" }
root_path = Pathname.new(dir)
load_path = root_path.join("lib/assets/javascripts/action_cable")
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), load_path.join("dist/#{dist_path}"))
end
end
end