Class: AssetFingerprinter::Fingerprinter::Digest
- Inherits:
-
Object
- Object
- AssetFingerprinter::Fingerprinter::Digest
- Defined in:
- lib/asset_fingerprinter/fingerprinter.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #call(path) ⇒ Object
-
#initialize ⇒ Digest
constructor
Digests a file and returns the cachebusted path.
Constructor Details
#initialize ⇒ Digest
Digests a file and returns the cachebusted path
9 10 11 12 13 14 15 16 17 |
# File 'lib/asset_fingerprinter/fingerprinter.rb', line 9 def initialize @cache = Hash.new do |hash,key| begin hash[key] = ::Digest::MD5.hexdigest(File.read(root ? File.join(root, key) : key)) rescue Errno::ENOENT # Don't set a key, maybe next time around something will happen? end end end |
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
6 7 8 |
# File 'lib/asset_fingerprinter/fingerprinter.rb', line 6 def root @root end |
Instance Method Details
#call(path) ⇒ Object
19 20 21 |
# File 'lib/asset_fingerprinter/fingerprinter.rb', line 19 def call(path) @cache[clean_path(path)] end |