Created
May 7, 2014 21:57
-
-
Save jessieay/63e5ca44aba45ba36263 to your computer and use it in GitHub Desktop.
ckeditor rake task
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
namespace :ckeditor do | |
desc 'Create nondigest versions of all ckeditor digest assets' | |
task :create_nondigest_assets do | |
fingerprint = /\-([0-9a-f]{32})\./ | |
for file in Dir['public/assets/ckeditor/**/*'] | |
next unless file =~ fingerprint | |
nondigest = file.sub(fingerprint, '.') | |
filename = nondigest.sub('public/assets/', '').sub(/.gz$/, '') | |
latest_digest = Rails.application.assets.find_asset(filename).digest | |
this_digest = file.match(fingerprint)[1] | |
if (this_digest == latest_digest) | |
FileUtils.cp file, nondigest | |
end | |
end | |
end | |
end | |
# auto run ckeditor:create_nondigest_assets after assets:precompile | |
Rake::Task['assets:precompile'].enhance do | |
Rake::Task['ckeditor:create_nondigest_assets'].invoke | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment