Module: Roda::RodaPlugins::HashPublicCache
- Defined in:
- lib/roda/plugins/hash_public_cache.rb
Overview
The hash_public_cache plugin builds on top of the hash_public plugin and adds the ability to store the digests for the public files in a json file, and load that file at startup, which avoids the need for the process to read the public file in order to compute the digest.
Examples:
# Load the plugin. Options given will be passed to public and hash_public.
plugin :hash_public_cache, "path/to/cache_file.json"
# When rebuilding the cache:
#
# * Scan the public directory for files, calculate the digest on each.
# * Write the hash public cache to a file.
#
# This is split into separate steps in case you want to modify the cache
# manually after the scan.
scan_hash_public_cache_dir
dump_hash_public_cache_file
# To load the cache at application startup (if the file exists):
load_hash_public_cache_file
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.configure(app, cache_file, opts = OPTS) ⇒ Object
Specify the location of the hash public cache file.
- .load_dependencies(app, _cache_file, opts = OPTS) ⇒ Object
Class Method Details
.configure(app, cache_file, opts = OPTS) ⇒ Object
Specify the location of the hash public cache file.
The options given are passed to the hash_public plugin.
38 39 40 |
# File 'lib/roda/plugins/hash_public_cache.rb', line 38 def self.configure(app, cache_file, opts = OPTS) app.opts[:hash_public_cache_file] = cache_file end |
.load_dependencies(app, _cache_file, opts = OPTS) ⇒ Object
31 32 33 |
# File 'lib/roda/plugins/hash_public_cache.rb', line 31 def self.load_dependencies(app, _cache_file, opts = OPTS) app.plugin :hash_public, opts end |