Sha256: 79acfb36cc7e1275b8bdf9cd55a5992a1779993651b3d1e47efd0c0777d8b669

Contents?: true

Size: 698 Bytes

Versions: 36

Compression:

Stored size: 698 Bytes

Contents

module Locomotive::Steam
  module Middlewares

    class DynamicAssets

      REGEXP = /^\/(javascripts|stylesheets)\/(.*)$/o

      @@sprocket_environments = {}

      attr_reader :app, :assets

      def initialize(app, options)
        @app    = app
        @assets = self.class.sprocket_environment(options[:root], options)
      end

      def call(env)
        if env['PATH_INFO'] =~ REGEXP
          env['PATH_INFO'] = $2
          assets.call(env)
        else
          app.call(env)
        end
      end

      def self.sprocket_environment(root, options)
        @@sprocket_environments[root] ||= Locomotive::Steam::SprocketsEnvironment.new(root, options)
      end

    end

  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
locomotivecms_steam-1.6.1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.0.rc0 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.0.beta3 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.0.beta2 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.5.0.beta1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.4.1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.4.0 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.4.0.rc2 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.4.0.rc1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.4.0.pre.rc.1 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.3.0 lib/locomotive/steam/middlewares/dynamic_assets.rb
locomotivecms_steam-1.3.0.rc2 lib/locomotive/steam/middlewares/dynamic_assets.rb