Sha256: a106ba5b7848d95e03b145db49b221da6dea71435d341f1b7c60bf1b009c3378

Contents?: true

Size: 733 Bytes

Versions: 1

Compression:

Stored size: 733 Bytes

Contents

module Locomotive::Steam
  class Server

    class DynamicAssets < Middleware

      attr_reader :app, :sprockets, :regexp

      def initialize(app, site_path)
        super(app)

        @regexp     = /^\/(javascripts|stylesheets)\/(.*)$/

        @sprockets  = Locomotive::Mounter::Extensions::Sprockets.environment(site_path)
      end

      def call(env)
        if env['PATH_INFO'] =~ self.regexp
          env['PATH_INFO'] = $2

          begin
            self.sprockets.call(env)
          rescue Exception => e
            raise Locomotive::Steam::DefaultException.new "Unable to serve a dynamic asset. Please check the logs.", e
          end
        else
          app.call(env)
        end
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locomotivecms_steam-0.1.0 lib/locomotive/steam/server/dynamic_assets.rb