Module: Nanoc::Cachebuster
- Defined in:
- lib/nanoc/cachebuster.rb,
lib/nanoc/cachebuster/version.rb,
lib/nanoc/cachebuster/strategy.rb
Defined Under Namespace
Constant Summary collapse
- FILETYPES_TO_FINGERPRINT =
List of file extensions that the routing system should regard as needing a fingerprint. These are input file extensions, so we also include the extensions used by popular preprocessors.
%w[css js scss sass less coffee html htm png jpg jpeg gif svg]
- FILETYPES_CONSIDERED_CSS =
List of file extensions that should be considered css. This is used to determine what filtering strategy to use when none is explicitly set.
%w[css js scss sass less]
- CACHEBUSTER_PREFIX =
Value prepended to the file fingerprint, to identify it as a cache buster.
'-cb'
- NoSuchSourceFile =
Custom exception that might be raised by the rewriting strategies when there can be no source file found for the reference that it found that might need rewriting.
This exception should never bubble up from the filter.
Class.new(Exception)
- NoSuchStrategy =
Custom exception that will be raised when trying to use a filtering strategy that does not exist. This will bubble up to the end user.
Class.new(Exception)
- VERSION =
'0.4.0'
Class Method Summary collapse
Class Method Details
.fingerprint_file(filename, length = 8) ⇒ Object
37 38 39 |
# File 'lib/nanoc/cachebuster.rb', line 37 def self.fingerprint_file(filename, length = 8) CACHEBUSTER_PREFIX + Digest::MD5.hexdigest(File.open(filename, 'rb'){|io| io.read})[0..length.to_i] end |
.should_apply_fingerprint_to_file?(item) ⇒ Boolean
33 34 35 |
# File 'lib/nanoc/cachebuster.rb', line 33 def self.should_apply_fingerprint_to_file?(item) FILETYPES_TO_FINGERPRINT.include? item[:extension] end |