Skip to content

Instantly share code, notes, and snippets.

@elia
Forked from ryana/commands.sh
Last active December 30, 2015 03:39
Show Gist options
  • Save elia/7770421 to your computer and use it in GitHub Desktop.
Save elia/7770421 to your computer and use it in GitHub Desktop.
SPROCKETS_NON_DIGEST = true
# form: https://gist.github.com/ryana/6049833
raise("Sprockets monkey patch for v 2.10.0. Check before moving on") unless Sprockets::VERSION == "2.10.0"
module Sprockets
class Manifest
def compile(*args)
unless environment
raise Error, "manifest requires environment for compilation"
end
paths = environment.each_logical_path(*args).to_a +
args.flatten.select { |fn| Pathname.new(fn).absolute? if fn.is_a?(String)}
paths.each do |path|
if asset = find_asset(path)
files[asset.digest_path] = {
'logical_path' => asset.logical_path,
'mtime' => asset.mtime.iso8601,
'size' => asset.bytesize,
'digest' => asset.digest
}
logical_path = asset.logical_path
assets[asset.logical_path] = asset.digest_path
target = File.join(dir, asset.digest_path)
if File.exist?(target)
logger.debug "Skipping #{target}, already exists"
else
logger.info "Writing #{target}"
asset.write_to target
asset.write_to "#{target}.gz" if asset.is_a?(BundledAsset)
end
if SPROCKETS_NON_DIGEST
logical_target = File.join(dir, logical_path)
logger.info "Writing #{logical_target}"
asset.write_to logical_target
asset.write_to "#{logical_target}.gz" if asset.is_a?(BundledAsset)
end
save
asset
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment