sprockets-rails 3.2.2 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 801a6cbc13340fb4c74ecf9b7aa2d5c6c563605e3462512e0073f268e269fe8d
4
- data.tar.gz: facde95b73f355f987059128c7f6d852b5b8845d26f2eca5214b4fc37ded168d
3
+ metadata.gz: c96f2a174f4f2e80b8c853df88db8687d2aa25e3884dbfeb56509cee537b4c74
4
+ data.tar.gz: f6147fa621580ff55996a9c53dab30d26b0f5197b085779342271a801119ff8b
5
5
  SHA512:
6
- metadata.gz: 7f6c2f179ba5b3294ad0b49357c4a7a50c207f221d6cbb5d9cad406b1143ee5ff9d5a71897f3f6a2bd9709eda8d5e5bad5380e4defa1e135700cc3edd9669749
7
- data.tar.gz: cbd34277b1e2e89c5ddded1b616ce179a269e384f1781b7032972c966737803e725440f5a23951383adf6b4a8705b50a307eb94a2bd6055ab42dcfc505aa468c
6
+ metadata.gz: c475cd351bc6ca97196cf0d98ef86db40f493f75eff770e6d6643bc3df85b01e304dcaa119d30400564186611ee52753fa73c3517b8a14f2152ed2c556329585
7
+ data.tar.gz: a3cb4867a60e31c591b3342d33602653b6b7c893698c3e754d33524b4f85e5c0dd98f5dcad4a8788fca40d94fcc28289dfac006439781277c20ecb6979e5d1e4
data/README.md CHANGED
@@ -196,5 +196,4 @@ Sprockets Rails is released under the [MIT License](MIT-LICENSE).
196
196
 
197
197
  ## Code Status
198
198
 
199
- * [![Travis CI](https://travis-ci.org/rails/sprockets-rails.svg?branch=master)](http://travis-ci.org/rails/sprockets-rails)
200
199
  * [![Gem Version](https://badge.fury.io/rb/sprockets-rails.svg)](http://badge.fury.io/rb/sprockets-rails)
@@ -0,0 +1,15 @@
1
+ module Sprockets
2
+ module Rails
3
+ # Rewrites urls in CSS files with the digested paths
4
+ class AssetUrlProcessor
5
+ REGEX = /url\(\s*["']?(?!(?:\#|data|http))([^"'\s)]+)\s*["']?\)/
6
+
7
+ def self.call(input)
8
+ context = input[:environment].context_class.new(input)
9
+ data = input[:data].gsub(REGEX) { |_match| "url(#{context.asset_path($1)})" }
10
+
11
+ { data: data }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -369,7 +369,7 @@ module Sprockets
369
369
  end
370
370
 
371
371
  def raise_unless_precompiled_asset(path)
372
- raise Helper::AssetNotPrecompiled.new(path) if @check_precompiled_asset && !precompiled?(path)
372
+ raise Helper::AssetNotPrecompiledError.new(path) if @check_precompiled_asset && !precompiled?(path)
373
373
  end
374
374
  end
375
375
  end
@@ -0,0 +1,22 @@
1
+ module Sprockets
2
+ module Rails
3
+ # Rewrites source mapping urls with the digested paths and protect against semicolon appending with a dummy comment line
4
+ class SourcemappingUrlProcessor
5
+ REGEX = /\/\/# sourceMappingURL=(.*\.map)/
6
+
7
+ def self.call(input)
8
+ env = input[:environment]
9
+ context = env.context_class.new(input)
10
+ data = input[:data].gsub(REGEX) do |_match|
11
+ ensure_file_is_present = context.resolve($1)
12
+ "//# sourceMappingURL=#{context.asset_path($1)}\n//!\n"
13
+ rescue Sprockets::FileNotFound
14
+ env.logger.warn "Removed sourceMappingURL comment for missing asset '#{$1}' from #{input[:filename]}"
15
+ nil
16
+ end
17
+
18
+ { data: data }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Rails
3
- VERSION = "3.2.2"
3
+ VERSION = "3.4.0"
4
4
  end
5
5
  end
@@ -4,6 +4,9 @@ require 'action_controller/railtie'
4
4
  require 'active_support/core_ext/module/remove_method'
5
5
  require 'active_support/core_ext/numeric/bytes'
6
6
  require 'sprockets'
7
+
8
+ require 'sprockets/rails/asset_url_processor'
9
+ require 'sprockets/rails/sourcemapping_url_processor'
7
10
  require 'sprockets/rails/context'
8
11
  require 'sprockets/rails/helper'
9
12
  require 'sprockets/rails/quiet_assets'
@@ -116,6 +119,14 @@ module Sprockets
116
119
  end
117
120
  end
118
121
 
122
+ initializer :asset_url_processor do |app|
123
+ Sprockets.register_postprocessor "text/css", ::Sprockets::Rails::AssetUrlProcessor
124
+ end
125
+
126
+ initializer :asset_sourcemap_url_processor do |app|
127
+ Sprockets.register_postprocessor "application/javascript", ::Sprockets::Rails::SourcemappingUrlProcessor
128
+ end
129
+
119
130
  config.assets.version = ""
120
131
  config.assets.debug = false
121
132
  config.assets.compile = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-12 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '5.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '5.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: '5.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '4.0'
54
+ version: '5.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: railties
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '4.0'
61
+ version: '5.2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '4.0'
68
+ version: '5.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -117,10 +117,12 @@ files:
117
117
  - MIT-LICENSE
118
118
  - README.md
119
119
  - lib/sprockets/rails.rb
120
+ - lib/sprockets/rails/asset_url_processor.rb
120
121
  - lib/sprockets/rails/context.rb
121
122
  - lib/sprockets/rails/helper.rb
122
123
  - lib/sprockets/rails/quiet_assets.rb
123
124
  - lib/sprockets/rails/route_wrapper.rb
125
+ - lib/sprockets/rails/sourcemapping_url_processor.rb
124
126
  - lib/sprockets/rails/task.rb
125
127
  - lib/sprockets/rails/utils.rb
126
128
  - lib/sprockets/rails/version.rb
@@ -137,14 +139,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
139
  requirements:
138
140
  - - ">="
139
141
  - !ruby/object:Gem::Version
140
- version: 1.9.3
142
+ version: '2.5'
141
143
  required_rubygems_version: !ruby/object:Gem::Requirement
142
144
  requirements:
143
145
  - - ">="
144
146
  - !ruby/object:Gem::Version
145
147
  version: '0'
146
148
  requirements: []
147
- rubygems_version: 3.1.2
149
+ rubygems_version: 3.2.22
148
150
  signing_key:
149
151
  specification_version: 4
150
152
  summary: Sprockets Rails integration