Sha256: 3ff217bc1350aae201b94f75daceca11ecd03594d0df21063b43d4a20021fff5
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
require 'digest/sha2' module Hanko class Fingerprint class << self attr_writer :digest_class, :cachable def pon(assets_dir, source) fingerprint = generate_pon(assets_dir, source) if cachable? cached_pon[source] ||= fingerprint else fingerprint end end def digest_class=(klass) @cached_pon = {} @digest_class = klass end private def cached_pon @cached_pon ||= {} end def generate_pon(assets_dir, source) path = File.join(assets_dir || '', source) File.file?(path) ? file_digest(path) : '' end def file_digest(path) digest_class.file(path).hexdigest end def digest_class @digest_class || ::Digest::SHA256 end def cachable? @cachable != false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hanko-0.1.4 | lib/hanko/fingerprint.rb |