Class: AssetFingerprinter::Fingerprinter::Digest

Inherits:
Object
  • Object
show all
Defined in:
lib/asset_fingerprinter/fingerprinter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDigest

Digests a file and returns the cachebusted path



9
10
11
12
13
# File 'lib/asset_fingerprinter/fingerprinter.rb', line 9

def initialize
  @cache = Hash.new{ |hash,key|
    hash[key] = ::Digest::MD5.hexdigest(File.read(root ? File.join(root, key) : key))
  }
end

Instance Attribute Details

#rootObject

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



15
16
17
# File 'lib/asset_fingerprinter/fingerprinter.rb', line 15

def call(path)
  @cache[clean_path(path)]
end