Sha256: f625035da06e2776a9d05e316c350dabfdb48d5c0f7d1791bc7e08d001816bbb

Contents?: true

Size: 932 Bytes

Versions: 7

Compression:

Stored size: 932 Bytes

Contents

module Sprockets
  module Rails
    class LoggerSilenceError < StandardError; end

    class QuietAssets
      def initialize(app)
        @app = app
        @assets_regex = %r(\A/{0,2}#{::Rails.application.config.assets.prefix})
      end

      def call(env)
        if env['PATH_INFO'] =~ @assets_regex
          raise_logger_silence_error unless ::Rails.logger.respond_to?(:silence)

          ::Rails.logger.silence { @app.call(env) }
        else
          @app.call(env)
        end
      end

      private
        def raise_logger_silence_error
          error = "You have enabled `config.assets.quiet`, but your `Rails.logger`\n"
          error << "does not use the `LoggerSilence` module.\n\n"
          error << "Please use a compatible logger such as `ActiveSupport::Logger`\n"
          error << "to take advantage of quiet asset logging.\n\n"

          raise LoggerSilenceError, error
        end
    end
  end
end

Version data entries

7 entries across 6 versions & 4 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/sprockets-rails-3.5.2/lib/sprockets/rails/quiet_assets.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/sprockets-rails-3.5.2/lib/sprockets/rails/quiet_assets.rb
sprockets-rails-3.5.2 lib/sprockets/rails/quiet_assets.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/sprockets-rails-3.5.1/lib/sprockets/rails/quiet_assets.rb
sprockets-rails-3.5.1 lib/sprockets/rails/quiet_assets.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/sprockets-rails-3.5.0/lib/sprockets/rails/quiet_assets.rb
sprockets-rails-3.5.0 lib/sprockets/rails/quiet_assets.rb