Sha256: 9e692b3c7d05b78a6be755427b19215426cb35270c604ea6c6213d81a4fce405

Contents?: true

Size: 529 Bytes

Versions: 4

Compression:

Stored size: 529 Bytes

Contents

require 'sprockets'

module Middleware
  class SprocketsChain
    attr_reader :app, :prefix, :sprockets

    def initialize(app, prefix)
      @app = app
      @prefix = prefix
      @sprockets = Sprockets::Environment.new
      yield sprockets if block_given?
    end

    def call(env)
      path_info = env["PATH_INFO"]
      if path_info =~ prefix
        env["PATH_INFO"].sub!(prefix, "")
        sprockets.call(env)
      else
        app.call(env)
      end
    ensure
      env["PATH_INFO"] = path_info
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hoboken-0.0.1 lib/hoboken/templates/sprockets_chain.rb
hoboken-0.0.1.beta3 lib/hoboken/templates/sprockets_chain.rb
hoboken-0.0.1.beta2 lib/hoboken/templates/sprockets_chain.rb
hoboken-0.0.1.beta lib/hoboken/templates/sprockets_chain.rb