Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@thermistor
Forked from arthurnn/assets.rake
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thermistor/ea8e5ea22f0fb7429b3c to your computer and use it in GitHub Desktop.
Save thermistor/ea8e5ea22f0fb7429b3c to your computer and use it in GitHub Desktop.
require 'non_digest_assets'
namespace :assets do
task :non_digested do
NonDigestAssets.new.generate
end
end
class NonDigestAssets
include Rake::DSL
FILES = ["external/app.js"]
def generate
assets_files.map do |file|
non_digested = file.gsub /(\-[a-z0-9]{32})/, ""
next unless FILES.all? {|s| non_digested =~ /#{s}/}
copy(file, non_digested)
end
end
def assets_files
Rake::FileList.new("public/assets/**/*") do |list|
list.exclude do |file|
file !~ /\-[a-z0-9]{32}\.[a-z]{2,4}/
end
end
end
def copy(from, to)
sh "cp #{from} #{to}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment