Sha256: 972f9ed485a51e038fe1463e11d748cab718e1cb9e05a6f0894ca22b30093d9f

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

module MongoBrowser
  module Middleware
    class SprocketsSinatra
      def initialize(app, options = {})
        @app = app
        @root = options[:root]
        path =  options[:path] || "assets"
        @matcher = /^\/#{path}\/*/
        @environment = ::Sprockets::Environment.new(@root)

        # Application assets
        @environment.append_path "app/assets/javascripts"
        @environment.append_path "app/assets/stylesheets"
        @environment.append_path "app/assets/images"

        # Vendor assets
        @environment.append_path "vendor/assets/javascripts"
        @environment.append_path "vendor/assets/stylesheets"
        @environment.append_path "vendor/assets/images"
      end

      def call(env)
        return @app.call(env) unless @matcher =~ env["PATH_INFO"]
        env["PATH_INFO"].sub!(@matcher, "")
        @environment.call(env)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_browser-0.1.3 lib/mongo_browser/middleware/sprockets_sinatra.rb