Module: Sprockets::PathDigestUtils
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Extended In:
| |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
DigestUtils ,
PathUtils
|
|
Defined in: | lib/sprockets/path_digest_utils.rb |
Overview
Internal: Crossover of path and digest utilities functions.
Constant Summary
PathUtils
- Included
DigestUtils
- Included
Instance Method Summary
-
#file_digest(path)
Internal: Compute digest for path.
-
#files_digest(paths)
Internal: Compute digest for a set of paths.
-
#stat_digest(path, stat)
Internal: Compute digest for file stat.
DigestUtils
- Included
#already_digested? | Internal: Checks an asset name for a valid digest. |
#detect_digest_class | Internal: Detect digest class hash algorithm for digest bytes. |
#digest | Internal: Generate a hexdigest for a nested JSON serializable object. |
#digest_class | Internal: Default digest class. |
#hexdigest | Internal: Generate a hexdigest for a nested JSON serializable object. |
#hexdigest_integrity_uri | Public: Generate hash for use in the |
#integrity_uri | Public: Generate hash for use in the |
#pack_base64digest | Internal: Pack a binary digest to a base64 encoded string. |
#pack_hexdigest | Internal: Pack a binary digest to a hex encoded string. |
#pack_urlsafe_base64digest | Internal: Pack a binary digest to a urlsafe base64 encoded string. |
#unpack_hexdigest | Internal: Unpack a hex encoded digest string into binary bytes. |
#build_digest |
PathUtils
- Included
#absolute_path? | On Windows, ALT_SEPARATOR is \ Delegate to Pathname since the logic gets complex. |
#atomic_write | Public: Write to a file atomically. |
#directory? | Public: Like |
#entries | Public: A version of |
#file? | Public: Like |
#find_matching_path_for_extensions | Internal: Match paths in a directory against available extensions. |
#find_upwards | Internal: Find target basename checking upwards from path. |
#join | Public: Joins path to base path. |
#match_path_extname | Internal: Match path extnames against available extensions. |
#path_extnames | Internal: Get path’s extensions. |
#path_parents | Internal: Returns all parents for path. |
#paths_split | Internal: Detect root path and base for file in a set of paths. |
#relative_path? | Public: Check if path is explicitly relative. |
#relative_path_from | Public: Get relative path from |
#set_pipeline | Public: Sets pipeline for path. |
#split_subpath | Internal: Get relative path for root path and subpath. |
#stat | Public: Like |
#stat_directory | Public: Stat all the files under a directory. |
#stat_sorted_tree | Public: Recursive stat all the files under a directory in alphabetical order. |
#stat_tree | Public: Recursive stat all the files under a directory. |
Instance Method Details
#file_digest(path)
Internal: Compute digest for path.
path - String filename or directory path.
Returns String digest bytes or nil.
# File 'lib/sprockets/path_digest_utils.rb', line 33
def file_digest(path) if stat = self.stat(path) self.stat_digest(path, stat) end end
#files_digest(paths)
Internal: Compute digest for a set of paths.
paths - Array of filename or directory paths.
Returns String digest bytes.
# File 'lib/sprockets/path_digest_utils.rb', line 44
def files_digest(paths) self.digest(paths.map { |path| self.file_digest(path) }) end
#stat_digest(path, stat)
Internal: Compute digest for file stat.
path - String filename stat - File::Stat
Returns String digest bytes.
# File 'lib/sprockets/path_digest_utils.rb', line 16
def stat_digest(path, stat) if stat.directory? # If its a directive, digest the list of filenames digest_class.digest(self.entries(path).join(','.freeze)) 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