Module: Middleman::Extensions::CacheBuster

Defined in:
lib/middleman-more/extensions/cache_buster.rb

Overview

The Cache Buster extension

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object Also known as: included

Once registered



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/middleman-more/extensions/cache_buster.rb', line 12

def registered(app)
  # Add instance methods to context
  app.send :include, InstanceMethods

  # 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
end