Module: Sprockets::PathDigestUtils
- Includes:
- DigestUtils, PathUtils
- Included in:
- Base, Dependencies
- Defined in:
- lib/sprockets/path_digest_utils.rb
Overview
Internal: Crossover of path and digest utilities functions.
Constant Summary
Constants included from DigestUtils
DigestUtils::DIGEST_SIZES, DigestUtils::NI_HASH_ALGORITHMS
Constants included from PathUtils
Sprockets::PathUtils::SEPARATOR_PATTERN
Instance Method Summary collapse
-
#file_digest(path) ⇒ Object
Internal: Compute digest for path.
-
#files_digest(paths) ⇒ Object
Internal: Compute digest for a set of paths.
-
#stat_digest(path, stat) ⇒ Object
Internal: Compute digest for file stat.
Methods included from DigestUtils
#detect_digest_class, #digest, #digest_class, #integrity_uri, #pack_base64digest, #pack_hexdigest, #pack_urlsafe_base64digest
Methods included from PathUtils
#absolute_path?, #atomic_write, #directory?, #entries, #file?, #find_upwards, #match_path_extname, #path_extnames, #path_parents, #paths_split, #relative_path?, #split_subpath, #stat, #stat_directory, #stat_sorted_tree, #stat_tree
Instance Method Details
#file_digest(path) ⇒ Object
Internal: Compute digest for path.
path - String filename or directory path.
Returns String digest bytes or nil.
32 33 34 35 36 |
# File 'lib/sprockets/path_digest_utils.rb', line 32 def file_digest(path) if stat = self.stat(path) self.stat_digest(path, stat) end end |
#files_digest(paths) ⇒ Object
Internal: Compute digest for a set of paths.
paths - Array of filename or directory paths.
Returns String digest bytes.
43 44 45 |
# File 'lib/sprockets/path_digest_utils.rb', line 43 def files_digest(paths) self.digest(paths.map { |path| self.file_digest(path) }) end |
#stat_digest(path, stat) ⇒ Object
Internal: Compute digest for file stat.
path - String filename stat - File::Stat
Returns String digest bytes.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sprockets/path_digest_utils.rb', line 15 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 |