Sha256: 0ec5f09a29a4b5c303a21446340288de479fe24586050c4350516fb7520841e7

Contents?: true

Size: 576 Bytes

Versions: 17

Compression:

Stored size: 576 Bytes

Contents

require 'rack/cache'

module Locomotive
  module Middlewares
    class Cache

      def initialize(app, opts = {}, &block)
        url_format  = Locomotive::Dragonfly.app.configuration[:url_format]
        base_format = url_format.split('/:').first rescue '/images/dynamic'

        @app      = app
        @regexp   = %r{^#{base_format}/}
        @context  = ::Rack::Cache.new(app, opts, &block)
      end

      def call(env)
        if env['PATH_INFO'] =~ @regexp
          @context.call(env)
        else
          @app.call(env)
        end
      end

    end

  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
locomotive_cms-2.0.3 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.2 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.1 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0 lib/locomotive/middlewares/cache.rb
tribeca_cms-0.1.1 lib/locomotive/middlewares/cache.rb
tribeca_cms-2.0.0.rc12 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc12 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc11 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc10 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc9 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc8 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc7 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc6 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc5 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc4 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc2 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.0.0.rc1 lib/locomotive/middlewares/cache.rb