Sha256: a0d723264427de045438065efbb82011d3fb94712a208ae94ccb8f73dd3a9f00

Contents?: true

Size: 537 Bytes

Versions: 5

Compression:

Stored size: 537 Bytes

Contents

module Spinebox
  
  # Rack middleware that reloads the sprockets environment on 
  # every request with a default delay of 5 seconds
  class Reloader
    
    def initialize(app, cooldown = 5)
      @app, @cooldown = app, cooldown
      @last = (Time.now - cooldown)
    end

    def call(env)
      reload! if Time.now > @last + @cooldown
      @app.call(env)
    end

    private
    def reload!
      Spinebox.config.assets.version  = '0.1'
      Spinebox.config.views.version   = '0.1'

      @last = Time.now
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spinebox-0.0.15 lib/spinebox/reloader.rb
spinebox-0.0.14 lib/spinebox/reloader.rb
spinebox-0.0.13 lib/spinebox/reloader.rb
spinebox-0.0.12 lib/spinebox/reloader.rb
spinebox-0.0.11 lib/spinebox/reloader.rb