Last active
August 29, 2015 14:02
-
-
Save dperrymorrow/9d3e0c64e655f75d07a7 to your computer and use it in GitHub Desktop.
asets rake file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'js-routes' | |
namespace :project do | |
namespace :assets do | |
desc "generate js routes in javascript" | |
task :js_routes => :environment do | |
JsRoutes.generate!("#{Rails.root}/public/javascripts/routes.js", exclude: [/.*admin.*/]) | |
end | |
desc "update karma test manifest from jammit assets.yml file" | |
task :update_karma_manifest => :environment do | |
karma_files = [] | |
tabs = " " | |
assets = YAML::load(File.open("#{Rails.root}/config/assets.yml")).symbolize_keys | |
karma_file = "#{Rails.root}/spec/javascripts/karma.conf.js" | |
assets[:javascripts].each do |key, files| | |
karma_files << "#{tabs}// #{key}" | |
files.each do |file| | |
str = "#{tabs}'../../#{file}'" | |
karma_files << str unless karma_files.include? str | |
end | |
end | |
contents = File.read karma_file | |
contents.gsub! contents.split('// {{assets.yml}}')[1], "\n#{karma_files.join(",\n")},\n#{tabs}" | |
File.write karma_file, contents | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment