New Upstream Snapshot - ruby-sprockets-rails

Ready changes

Summary

Merged new upstream version: 3.4.2+git20220810.1.3908b4e (was: 3.4.1).

Resulting package

Built on 2022-12-29T13:59 (took 9m56s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots ruby-sprockets-rails

Lintian Result

Diff

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 7ed1ef5..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,80 +0,0 @@
-name: CI
-on: [push, pull_request]
-jobs:
-  tests:
-    runs-on: ubuntu-latest
-    strategy:
-      fail-fast: false
-      matrix:
-        include:
-          - ruby: 2.5
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-5.2.x"
-          - ruby: 2.5
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-5.2.x.sprockets-4.x"
-          - ruby: 2.5
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-6.0.x"
-          - ruby: 2.5
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-6.0.x.sprockets-4.x"
-          - ruby: 2.6
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-5.2.x"
-          - ruby: 2.6
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-5.2.x.sprockets-4.x"
-          - ruby: 2.6
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-6.0.x"
-          - ruby: 2.6
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-6.0.x.sprockets-4.x"
-          - ruby: 2.7
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-5.2.x"
-          - ruby: 2.7
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-5.2.x.sprockets-4.x"
-          - ruby: 2.7
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-6.0.x"
-          - ruby: 2.7
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-6.0.x.sprockets-4.x"
-          - ruby: 2.7
-            os: ubuntu-latest
-            gemfile: "gemfiles/Gemfile.rails-6.1.x.sprockets-4.x"
-          - ruby: 2.7
-            os: ubuntu-latest
-            gemfile: Gemfile
-            allow-failure: true
-          - ruby: 3.0
-            os: ubuntu-latest
-            gemfile: Gemfile
-            allow-failure: true
-          - ruby: head
-            os: ubuntu-latest
-            gemfile: Gemfile
-            allow-failure: true
-    steps:
-      - uses: actions/checkout@v2
-      - uses: actions/cache@v2
-        with:
-          path: /home/runner/bundle
-          key: bundle-use-ruby-${{ matrix.ruby }}-${{ matrix.gemfile }}-gems-${{ hashFiles(matrix.gemfile) }}-${{ hashFiles('**/*.gemspec') }}
-          restore-keys: |
-            bundle-use-ruby-${{ matrix.ruby }}-${{ matrix.gemfile }}-gems-
-      - name: Set up Ruby
-        uses: ruby/setup-ruby@v1
-        with:
-          ruby-version: ${{ matrix.ruby }}
-      - name: Bundle install
-        run: |
-          gem install bundler -v 2.1.4
-          bundle config path /home/runner/bundle
-          bundle config --global gemfile ${{ matrix.gemfile }}
-          bundle install --jobs 4 --retry 3
-      - name: Run tests
-        run: bundle exec rake
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 0fe058a..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Gemfile*.lock
-tmp/
-*.gem
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e2b6457..024ab7d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -5,10 +5,11 @@ Sprockets Rails is work of [many contributors](https://github.com/rails/sprocket
 
 #### Fork the Project
 
-Fork the [project on Github](https://github.com/rails/sprockets-rails) and check out your copy.
+Fork the [project on GitHub](https://github.com/rails/sprockets-rails) and clone your fork.
+Use your GitHub username instead of `YOUR-USERNAME`.
 
 ```
-git clone https://github.com/contributor/sprockets-rails.git
+git clone https://github.com/YOUR-USERNAME/sprockets-rails.git
 cd sprockets-rails
 git remote add upstream https://github.com/rails/sprockets-rails.git
 ```
diff --git a/README.md b/README.md
index 6972092..db17a8e 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # Sprockets Rails
 
-Provides Sprockets implementation for Rails 4.x (and beyond) Asset Pipeline.
+Provides [Sprockets](https://github.com/rails/sprockets) implementation for Rails 4.x (and beyond) Asset Pipeline.
 
 
 ## Installation
@@ -86,7 +86,7 @@ When enabled, fingerprints will be added to asset filenames.
 
 **`config.assets.debug`**
 
-Enable expanded asset debugging mode. Individual files will be served to make referencing filenames in the web console easier. This feature will eventually be deprecated and replaced by Source Maps in Sprockets 3.x.
+Enable asset debugging mode. A source map will be included with each asset when this is true.
 
 **`config.assets.compile`**
 
@@ -108,6 +108,10 @@ config.assets.configure do |env|
 end
 ```
 
+**`config.assets.resolve_assets_in_css_urls`**
+
+When this option is enabled, sprockets-rails will register a CSS postprocessor to resolve assets referenced in [`url()`](https://developer.mozilla.org/en-US/docs/Web/CSS/url()) function calls and replace them with the digested paths. Defaults to `true`.
+
 **`config.assets.resolve_with`**
 
 A list of `:environment` and `:manifest` symbols that defines the order that
diff --git a/debian/changelog b/debian/changelog
index 618b87f..79f3e0c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-sprockets-rails (3.4.2+git20220810.1.3908b4e-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 29 Dec 2022 13:52:36 -0000
+
 ruby-sprockets-rails (3.4.1-2) unstable; urgency=medium
 
   * Team upload
diff --git a/gemfiles/Gemfile.rails-5.2.x.sprockets-4.x b/gemfiles/Gemfile.rails-5.2.x.sprockets-4.x
index 89e01de..98c6cf7 100644
--- a/gemfiles/Gemfile.rails-5.2.x.sprockets-4.x
+++ b/gemfiles/Gemfile.rails-5.2.x.sprockets-4.x
@@ -4,4 +4,4 @@ gemspec path: '..'
 
 gem 'actionpack', '~> 5.2.0'
 gem 'railties', '~> 5.2.0'
-gem 'sprockets', github: 'rails/sprockets', branch: 'master'
+gem 'sprockets', github: 'rails/sprockets', branch: 'main'
diff --git a/gemfiles/Gemfile.rails-6.0.x.sprockets-4.x b/gemfiles/Gemfile.rails-6.0.x.sprockets-4.x
index e2226d2..5004fb6 100644
--- a/gemfiles/Gemfile.rails-6.0.x.sprockets-4.x
+++ b/gemfiles/Gemfile.rails-6.0.x.sprockets-4.x
@@ -4,4 +4,4 @@ gemspec path: '..'
 
 gem 'actionpack', '~> 6.0.0'
 gem 'railties', '~> 6.0.0'
-gem 'sprockets', github: 'rails/sprockets', branch: 'master'
+gem 'sprockets', github: 'rails/sprockets', branch: 'main'
diff --git a/lib/sprockets/rails/asset_url_processor.rb b/lib/sprockets/rails/asset_url_processor.rb
index 7739f43..7adcb9e 100644
--- a/lib/sprockets/rails/asset_url_processor.rb
+++ b/lib/sprockets/rails/asset_url_processor.rb
@@ -1,8 +1,8 @@
 module Sprockets
   module Rails
-    # Rewrites urls in CSS files with the digested paths
+    # Resolve assets referenced in CSS `url()` calls and replace them with the digested paths
     class AssetUrlProcessor
-      REGEX = /url\(\s*["']?(?!(?:\#|data|http))(?<relativeToCurrentDir>.\/)?(?<path>[^"'\s)]+)\s*["']?\)/
+      REGEX = /url\(\s*["']?(?!(?:\#|data|http))(?<relativeToCurrentDir>\.\/)?(?<path>[^"'\s)]+)\s*["']?\)/
       def self.call(input)
         context = input[:environment].context_class.new(input)
         data    = input[:data].gsub(REGEX) do |_match|
diff --git a/lib/sprockets/rails/helper.rb b/lib/sprockets/rails/helper.rb
index f3e9df0..23e34e6 100644
--- a/lib/sprockets/rails/helper.rb
+++ b/lib/sprockets/rails/helper.rb
@@ -89,8 +89,7 @@ module Sprockets
             message << "To bypass the asset pipeline and preserve this behavior,\n"
             message << "use the `skip_pipeline: true` option.\n"
 
-            call_stack = Kernel.respond_to?(:caller_locations) && ::Rails::VERSION::MAJOR >= 5 ? caller_locations : caller
-            ActiveSupport::Deprecation.warn(message, call_stack)
+            ActiveSupport::Deprecation.warn(message, caller_locations)
           end
           super
         end
diff --git a/lib/sprockets/rails/quiet_assets.rb b/lib/sprockets/rails/quiet_assets.rb
index a54ab82..62bd092 100644
--- a/lib/sprockets/rails/quiet_assets.rb
+++ b/lib/sprockets/rails/quiet_assets.rb
@@ -1,5 +1,7 @@
 module Sprockets
   module Rails
+    class LoggerSilenceError < StandardError; end
+
     class QuietAssets
       def initialize(app)
         @app = app
@@ -8,11 +10,23 @@ module Sprockets
 
       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
diff --git a/lib/sprockets/rails/route_wrapper.rb b/lib/sprockets/rails/route_wrapper.rb
index a8712eb..0a11923 100644
--- a/lib/sprockets/rails/route_wrapper.rb
+++ b/lib/sprockets/rails/route_wrapper.rb
@@ -1,7 +1,6 @@
 module Sprockets
   module Rails
     module RouteWrapper
-
       def internal_assets_path?
         path =~ %r{\A#{self.class.assets_prefix}\z}
       end
@@ -9,15 +8,6 @@ module Sprockets
       def internal?
         super || internal_assets_path?
       end
-
-      def self.included(klass)
-        klass.class_eval do
-          def internal_with_sprockets?
-            internal_without_sprockets? || internal_assets_path?
-          end
-          alias_method_chain :internal?, :sprockets
-        end
-      end
     end
   end
 end
diff --git a/lib/sprockets/rails/version.rb b/lib/sprockets/rails/version.rb
index 5a9baf2..ae65877 100644
--- a/lib/sprockets/rails/version.rb
+++ b/lib/sprockets/rails/version.rb
@@ -1,5 +1,5 @@
 module Sprockets
   module Rails
-    VERSION = "3.4.1"
+    VERSION = "3.4.2"
   end
 end
diff --git a/lib/sprockets/railtie.rb b/lib/sprockets/railtie.rb
index 5651faf..498c529 100644
--- a/lib/sprockets/railtie.rb
+++ b/lib/sprockets/railtie.rb
@@ -53,17 +53,6 @@ module Rails
       @precompiled_assets ||= assets_manifest.find(config.assets.precompile).map(&:logical_path).to_set
     end
   end
-
-  class Engine < Railtie
-    # Skip defining append_assets_path on Rails <= 4.2
-    unless initializers.find { |init| init.name == :append_assets_path }
-      initializer :append_assets_path, :group => :all do |app|
-        app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
-        app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
-        app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
-      end
-    end
-  end
 end
 
 module Sprockets
@@ -96,13 +85,20 @@ module Sprockets
       end
     end
 
+    ::Rails::Engine.initializer :append_assets_path, :group => :all do |app|
+      app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
+      app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
+      app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
+    end
+
     config.assets = OrderedOptions.new
-    config.assets._blocks     = []
-    config.assets.paths       = []
-    config.assets.precompile  = []
-    config.assets.prefix      = "/assets"
-    config.assets.manifest    = nil
-    config.assets.quiet       = false
+    config.assets._blocks                    = []
+    config.assets.paths                      = []
+    config.assets.precompile                 = []
+    config.assets.prefix                     = "/assets"
+    config.assets.manifest                   = nil
+    config.assets.quiet                      = false
+    config.assets.resolve_assets_in_css_urls = true
 
     initializer :set_default_precompile do |app|
       if using_sprockets4?
@@ -120,7 +116,9 @@ module Sprockets
     end
 
     initializer :asset_url_processor do |app|
-      Sprockets.register_postprocessor "text/css", ::Sprockets::Rails::AssetUrlProcessor
+      if app.config.assets.resolve_assets_in_css_urls
+        Sprockets.register_postprocessor "text/css", ::Sprockets::Rails::AssetUrlProcessor
+      end
     end
 
     initializer :asset_sourcemap_url_processor do |app|
@@ -234,11 +232,7 @@ module Sprockets
       ActionDispatch::Routing::RouteWrapper.class_eval do
         class_attribute :assets_prefix
 
-        if defined?(prepend) && ::Rails.version >= '4'
-          prepend Sprockets::Rails::RouteWrapper
-        else
-          include Sprockets::Rails::RouteWrapper
-        end
+        prepend Sprockets::Rails::RouteWrapper
 
         self.assets_prefix = config.assets.prefix
       end
diff --git a/test/test_asset_url_processor.rb b/test/test_asset_url_processor.rb
index d9fbd70..7b1bdac 100644
--- a/test/test_asset_url_processor.rb
+++ b/test/test_asset_url_processor.rb
@@ -61,4 +61,10 @@ class TestAssetUrlProcessor < Minitest::Test
     jquery_digest = 'c6910e1db4a5ed4905be728ab786471e81565f4a9d544734b199f3790de9f9a3'
     assert_equal("background: url(/jquery/jquery-#{jquery_digest}.js);", output[:data])
   end
+
+  def test_protocol_relative_paths
+    input = { environment: @env, data: "background: url(//assets.example.com/assets/fontawesome-webfont-82ff0fe46a6f60e0ab3c4a9891a0ae0a1f7b7e84c625f55358379177a2dcb202.eot);", filename: 'url2.css', metadata: {} }
+    output = Sprockets::Rails::AssetUrlProcessor.call(input)
+    assert_equal("background: url(//assets.example.com/assets/fontawesome-webfont-82ff0fe46a6f60e0ab3c4a9891a0ae0a1f7b7e84c625f55358379177a2dcb202.eot);", output[:data])
+  end
 end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8e68051..63b3bfb 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -893,7 +893,7 @@ class PrecompiledAssetHelperTest < HelperTest
     end
   end
 
-  def test_javascript_precompile_thows_the_descriptive_error
+  def test_javascript_precompile_throws_the_descriptive_error
     assert_raises(Sprockets::Rails::Helper::AssetNotPrecompiledError) do
       @view.javascript_include_tag("not_precompiled")
     end
diff --git a/test/test_quiet_assets.rb b/test/test_quiet_assets.rb
index 8c39720..1a07b80 100644
--- a/test/test_quiet_assets.rb
+++ b/test/test_quiet_assets.rb
@@ -43,6 +43,12 @@ class TestQuietAssets < Minitest::Test
     assert_equal Logger::DEBUG, middleware.call("PATH_INFO" => "/path/to/thing")
   end
 
+  def test_logger_does_not_respond_to_silence
+    ::Rails.logger.stub :respond_to?, false do
+      assert_raises(Sprockets::Rails::LoggerSilenceError) { middleware.call("PATH_INFO" => "/assets/stylesheets/application.css") }
+    end
+  end
+
   private
 
   def middleware
diff --git a/test/test_railtie.rb b/test/test_railtie.rb
index c24b237..6eb1c82 100644
--- a/test/test_railtie.rb
+++ b/test/test_railtie.rb
@@ -423,6 +423,23 @@ class TestRailtie < TestBoot
     assert middleware.each_cons(2).include?([Sprockets::Rails::QuietAssets, Rails::Rack::Logger])
   end
 
+  def test_resolve_assets_in_css_urls_defaults_to_true
+    app.initialize!
+
+    assert_equal true, app.config.assets.resolve_assets_in_css_urls
+    assert_includes Sprockets.postprocessors['text/css'], Sprockets::Rails::AssetUrlProcessor
+  end
+
+  def test_resolve_assets_in_css_urls_when_false_avoids_registering_postprocessor
+    app.configure do
+      config.assets.resolve_assets_in_css_urls = false
+    end
+    app.initialize!
+
+    assert_equal false, app.config.assets.resolve_assets_in_css_urls
+    refute_includes Sprockets.postprocessors['text/css'], Sprockets::Rails::AssetUrlProcessor
+  end
+
   private
     def action_view
       ActionView::Base.new(ActionView::LookupContext.new([]), {}, nil)

More details

Full run details