module Sprockets::PathDigestUtils
def file_digest(path)
path - String filename or directory path.
Internal: Compute digest for path.
def file_digest(path) if stat = self.stat(path) self.stat_digest(path, stat) end end
def files_digest(paths)
paths - Array of filename or directory paths.
Internal: Compute digest for a set of paths.
def files_digest(paths) self.digest(paths.map { |path| self.file_digest(path) }) end
def stat_digest(path, stat)
stat - File::Stat
path - String filename
Internal: Compute digest for file stat.
def stat_digest(path, stat) if stat.directory? # If its a directive, digest the list of filenames digest_class.digest(self.entries(path).join(',')) elsif stat.file? # If its a file, digest the contents digest_class.file(path.to_s).digest else raise TypeError, "stat was not a directory or file: #{stat.ftype}" end end