Class: Middleman::Extensions::CacheBuster
- Inherits:
-
Middleman::Extension
- Object
- Middleman::Extension
- Middleman::Extensions::CacheBuster
- Defined in:
- lib/middleman-more/extensions/cache_buster.rb
Overview
The Cache Buster extension
Instance Attribute Summary
Attributes inherited from Middleman::Extension
Instance Method Summary collapse
-
#initialize(app, options_hash = {}, &block) ⇒ CacheBuster
constructor
A new instance of CacheBuster.
Methods inherited from Middleman::Extension
activate, activated_extension, after_extension_activated, clear_after_extension_callbacks, config, extension_name, helpers, option, register
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ CacheBuster
Returns a new instance of CacheBuster.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/middleman-more/extensions/cache_buster.rb', line 4 def initialize(app, ={}, &block) super # After compass is setup, make it use the registered cache buster app.compass_config do |config| config.asset_cache_buster do |path, real_path| real_path = real_path.path if real_path.is_a? File real_path = real_path.gsub(File.join(root, build_dir), source) if File.readable?(real_path) File.mtime(real_path).strftime("%s") else logger.warn "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}" end end end if app.respond_to?(:compass_config) end |