Sha256: 8a2d737deb3a441f59756648994aa609d27acbad33524ab7531585f541c8920a
Contents?: true
Size: 663 Bytes
Versions: 2
Compression:
Stored size: 663 Bytes
Contents
module Sinatra module AssetPack module BusterHelpers extend self # Returns the cache buster suffix for given file(s). # This implementation somewhat obfuscates the mtime to not reveal deployment dates. def cache_buster_hash(*files) i = files.map { |f| File.mtime(f).to_i }.max (i * 4567).to_s.reverse[0...6] end # Adds a cache buster for the given path. # # add_cache_buster('/images/email.png', '/var/www/x/public/images/email.png') # def add_cache_buster(path, *files) path.gsub(/(\.[^.]+)$/) { |ext| ".#{cache_buster_hash *files}#{ext}" } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sinatra-assetpack-0.0.6 | lib/sinatra/assetpack/buster_helpers.rb |
sinatra-assetpack-0.0.5 | lib/sinatra/assetpack/buster_helpers.rb |