sprockets 4.0.0.beta8 → 4.0.0.beta9

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: fbe399f50753fd31d29282b47fa94e3fe7a47a4e68e8ecd13e10b64e77bf1bf5
4
- data.tar.gz: 9ed07b767bfac2586bec42f89ab577f536eea205c4d2398f2271786454f88329
3
+ metadata.gz: 6f01b64fd78772abf12d6c9f603059c9a398e56d2955d007b6b25b78d6d35e54
4
+ data.tar.gz: a4b3d110e6f084fd830d49b48e00147e53dce7e7c50f8957d670bd3d7e12d0dc
5
5
  SHA512:
6
- metadata.gz: 05a368c8f64c7469441e524d9886cbd0edd75b0c877e91f3c8ce4802efa378500725b4fe803f74bc03fc5927ffe4ee09433766a3451dabcc6ec19d6101dcfdae
7
- data.tar.gz: 96734d6f69801043e458d9a383f3011538264a934908936eb20ea357203e10a9c2bf48863ebc8d28d069628e314debaa15361a1d807468605a24e68393e3ce64
6
+ metadata.gz: c19695c9d705de579a62812a9c630decfef94f2599719fdd72d99c06815e6b86f522b84aef2eca2b9b7b592c65363c51f273353c50670ab8c3fadd7ae9108562
7
+ data.tar.gz: 3ec14baaff1b624ac3e2fe7877fa6520173260ac9cf387423a426839989bbe54af800003f80df0476553eeee2e1e4df3584acbe2105dfb15554610902fbc873e
@@ -4,6 +4,12 @@ Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprocket
4
4
 
5
5
  ## Master
6
6
 
7
+ ## 4.0.0.beta9
8
+
9
+ - Minimum Ruby version for Sprockets 4 is now 2.5+ which matches minimum ruby verision of Rails [#604]
10
+ - Fix threading bug introduced in Sprockets 4 [#603]
11
+ - Warn when two potential manifest files exist. [#560]
12
+
7
13
  ## 4.0.0.beta8
8
14
 
9
15
  - Security release for [CVE-2018-3760](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-3760)
@@ -51,4 +57,3 @@ Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprocket
51
57
  - Initial release of Sprockets 4
52
58
 
53
59
  Please upgrade to the latest Sprockets 3 version before upgrading to Sprockets 4. Check the 3.x branch for previous changes https://github.com/rails/sprockets/blob/3.x/CHANGELOG.md.
54
-
data/README.md CHANGED
@@ -390,7 +390,7 @@ Example:
390
390
  You can specify a file extension so any extra files will be ignored:
391
391
 
392
392
  ```js
393
- //= link_tree path/to/folder .js
393
+ //= link_tree ./path/to/folder .js
394
394
  ```
395
395
 
396
396
  > Note: There is an intentional space between the path and the extension
@@ -119,8 +119,8 @@ module Sprockets
119
119
  register_bundle_processor 'application/javascript', Bundle
120
120
  register_bundle_processor 'text/css', Bundle
121
121
 
122
- register_bundle_metadata_reducer '*/*', :data, proc { String.new("") }, :concat
123
- register_bundle_metadata_reducer 'application/javascript', :data, proc { String.new("") }, Utils.method(:concat_javascript_sources)
122
+ register_bundle_metadata_reducer '*/*', :data, proc { +"" }, :concat
123
+ register_bundle_metadata_reducer 'application/javascript', :data, proc { +"" }, Utils.method(:concat_javascript_sources)
124
124
  register_bundle_metadata_reducer '*/*', :links, :+
125
125
  register_bundle_metadata_reducer '*/*', :sources, proc { [] }, :+
126
126
 
@@ -165,11 +165,11 @@ module Sprockets
165
165
  register_transformer 'application/javascript+function', 'application/javascript', JstProcessor
166
166
 
167
167
  # CSS processors
168
- require 'sprockets/sass_processor'
168
+ require 'sprockets/sassc_processor'
169
169
  register_mime_type 'text/sass', extensions: ['.sass', '.css.sass']
170
170
  register_mime_type 'text/scss', extensions: ['.scss', '.css.scss']
171
- register_transformer 'text/sass', 'text/css', SassProcessor
172
- register_transformer 'text/scss', 'text/css', ScssProcessor
171
+ register_transformer 'text/sass', 'text/css', SasscProcessor
172
+ register_transformer 'text/scss', 'text/css', ScsscProcessor
173
173
  register_preprocessor 'text/sass', DirectiveProcessor.new(comments: ["//", ["/*", "*/"]])
174
174
  register_preprocessor 'text/scss', DirectiveProcessor.new(comments: ["//", ["/*", "*/"]])
175
175
  register_bundle_metadata_reducer 'text/css', :sass_dependencies, Set.new, :+
@@ -19,12 +19,12 @@ module Sprockets
19
19
 
20
20
  class DoubleLinkError < Sprockets::Error
21
21
  def initialize(parent_filename:, logical_path:, last_filename:, filename:)
22
- message = String.new
23
- message << "Multiple files with the same output path cannot be linked (#{logical_path.inspect})\n"
24
- message << "In #{parent_filename.inspect} these files were linked:\n"
25
- message << " - #{last_filename}\n"
26
- message << " - #{filename}\n"
27
- super(message)
22
+ super <<~MSG
23
+ Multiple files with the same output path cannot be linked (#{logical_path.inspect})
24
+ In #{parent_filename.inspect} these files were linked:
25
+ - #{last_filename}
26
+ - #{filename}
27
+ MSG
28
28
  end
29
29
  end
30
30
 
@@ -137,8 +137,10 @@ module Sprockets
137
137
  #
138
138
  # Returns true
139
139
  def clear(options=nil)
140
- root_dirs = Dir.entries(@root).reject { |f| (EXCLUDED_DIRS + GITKEEP_FILES).include?(f) }
141
- FileUtils.rm_r(root_dirs.collect{ |f| File.join(@root, f) })
140
+ if File.exist?(@root)
141
+ root_dirs = Dir.entries(@root).reject { |f| (EXCLUDED_DIRS + GITKEEP_FILES).include?(f) }
142
+ FileUtils.rm_r(root_dirs.collect{ |f| File.join(@root, f) })
143
+ end
142
144
  true
143
145
  end
144
146
 
@@ -121,7 +121,7 @@ module Sprockets
121
121
 
122
122
  header, directives = extract_directives(header)
123
123
 
124
- data = String.new("")
124
+ data = +""
125
125
  data.force_encoding(body.encoding)
126
126
  data << header unless header.empty?
127
127
  data << body
@@ -139,7 +139,7 @@ module Sprockets
139
139
  # [[1, "require", "foo"], [2, "require", "bar"]]
140
140
  #
141
141
  def extract_directives(header)
142
- processed_header = String.new("")
142
+ processed_header = +""
143
143
  directives = []
144
144
 
145
145
  header.lines.each_with_index do |line, index|
@@ -18,7 +18,12 @@ class Sprockets::ERBProcessor
18
18
  end
19
19
 
20
20
  def call(input)
21
- engine = ::ERB.new(input[:data], nil, '<>')
21
+ match = ERB.version.match(/\Aerb\.rb \[(?<version>[^ ]+) /)
22
+ if match && match[:version] >= "2.2.0" # Ruby 2.6+
23
+ engine = ::ERB.new(input[:data], trim_mode: '<>')
24
+ else
25
+ engine = ::ERB.new(input[:data], nil, '<>')
26
+ end
22
27
  engine.filename = input[:filename]
23
28
 
24
29
  context = input[:environment].context_class.new(input)
@@ -86,14 +86,16 @@ module Sprockets
86
86
  raise TypeError, "unknown q_values type: #{q_values.class}"
87
87
  end
88
88
 
89
+ i = 0
89
90
  q_values.each do |accepted, quality|
90
91
  if match = available.find { |option| matcher.call(option, accepted) }
91
- matches << [match, quality]
92
+ i += 1
93
+ matches << [-quality, i, match]
92
94
  end
93
95
  end
94
96
 
95
- matches.sort_by! { |match, quality| -quality }
96
- matches.map! { |match, quality| match }
97
+ matches.sort!
98
+ matches.map! { |_, _, match| match }
97
99
  matches
98
100
  end
99
101
 
@@ -64,6 +64,43 @@ module Sprockets
64
64
  end
65
65
 
66
66
  private
67
+ def compress_key_from_hash(hash, key)
68
+ return unless hash.key?(key)
69
+ value = hash[key].dup
70
+ return if !value
71
+
72
+ if block_given?
73
+ value.map! do |x|
74
+ if yield x
75
+ compress_from_root(x)
76
+ else
77
+ x
78
+ end
79
+ end
80
+ else
81
+ value.map! { |x| compress_from_root(x) }
82
+ end
83
+ hash[key] = value
84
+ end
85
+
86
+
87
+ def expand_key_from_hash(hash, key)
88
+ return unless hash.key?(key)
89
+ value = hash[key].dup
90
+ return if !value
91
+ if block_given?
92
+ value.map! do |x|
93
+ if yield x
94
+ expand_from_root(x)
95
+ else
96
+ x
97
+ end
98
+ end
99
+ else
100
+ value.map! { |x| expand_from_root(x) }
101
+ end
102
+ hash[key] = value
103
+ end
67
104
 
68
105
  # Internal: Load asset hash from cache
69
106
  #
@@ -77,17 +114,16 @@ module Sprockets
77
114
  asset[:uri] = expand_from_root(asset[:uri])
78
115
  asset[:load_path] = expand_from_root(asset[:load_path])
79
116
  asset[:filename] = expand_from_root(asset[:filename])
80
- asset[:metadata][:included].map! { |uri| expand_from_root(uri) } if asset[:metadata][:included]
81
- asset[:metadata][:links].map! { |uri| expand_from_root(uri) } if asset[:metadata][:links]
82
- asset[:metadata][:stubbed].map! { |uri| expand_from_root(uri) } if asset[:metadata][:stubbed]
83
- asset[:metadata][:required].map! { |uri| expand_from_root(uri) } if asset[:metadata][:required]
84
- asset[:metadata][:to_load].map! { |uri| expand_from_root(uri) } if asset[:metadata][:to_load]
85
- asset[:metadata][:to_link].map! { |uri| expand_from_root(uri) } if asset[:metadata][:to_link]
86
- asset[:metadata][:dependencies].map! { |uri| uri.start_with?("file-digest://") ? expand_from_root(uri) : uri } if asset[:metadata][:dependencies]
117
+ expand_key_from_hash(asset[:metadata], :included)
118
+ expand_key_from_hash(asset[:metadata], :stubbed)
119
+ expand_key_from_hash(asset[:metadata], :required)
120
+ expand_key_from_hash(asset[:metadata], :to_load)
121
+ expand_key_from_hash(asset[:metadata], :to_link)
122
+ expand_key_from_hash(asset[:metadata], :dependencies) { |uri| uri.start_with?("file-digest://") }
87
123
 
88
124
  asset[:metadata].each_key do |k|
89
- next unless k =~ /_dependencies\z/
90
- asset[:metadata][k].map! { |uri| expand_from_root(uri) }
125
+ next unless k.match?(/_dependencies\z/) # rubocop:disable Performance/EndWith
126
+ expand_key_from_hash(asset[:metadata], k)
91
127
  end
92
128
  end
93
129
  asset
@@ -205,48 +241,17 @@ module Sprockets
205
241
  if cached_asset[:metadata]
206
242
  # Deep dup to avoid modifying `asset`
207
243
  cached_asset[:metadata] = cached_asset[:metadata].dup
208
- if cached_asset[:metadata][:included] && !cached_asset[:metadata][:included].empty?
209
- cached_asset[:metadata][:included] = cached_asset[:metadata][:included].dup
210
- cached_asset[:metadata][:included].map! { |uri| compress_from_root(uri) }
211
- end
212
-
213
- if cached_asset[:metadata][:links] && !cached_asset[:metadata][:links].empty?
214
- cached_asset[:metadata][:links] = cached_asset[:metadata][:links].dup
215
- cached_asset[:metadata][:links].map! { |uri| compress_from_root(uri) }
216
- end
217
-
218
- if cached_asset[:metadata][:stubbed] && !cached_asset[:metadata][:stubbed].empty?
219
- cached_asset[:metadata][:stubbed] = cached_asset[:metadata][:stubbed].dup
220
- cached_asset[:metadata][:stubbed].map! { |uri| compress_from_root(uri) }
221
- end
222
-
223
- if cached_asset[:metadata][:required] && !cached_asset[:metadata][:required].empty?
224
- cached_asset[:metadata][:required] = cached_asset[:metadata][:required].dup
225
- cached_asset[:metadata][:required].map! { |uri| compress_from_root(uri) }
226
- end
227
-
228
- if cached_asset[:metadata][:to_load] && !cached_asset[:metadata][:to_load].empty?
229
- cached_asset[:metadata][:to_load] = cached_asset[:metadata][:to_load].dup
230
- cached_asset[:metadata][:to_load].map! { |uri| compress_from_root(uri) }
231
- end
232
-
233
- if cached_asset[:metadata][:to_link] && !cached_asset[:metadata][:to_link].empty?
234
- cached_asset[:metadata][:to_link] = cached_asset[:metadata][:to_link].dup
235
- cached_asset[:metadata][:to_link].map! { |uri| compress_from_root(uri) }
236
- end
237
-
238
- if cached_asset[:metadata][:dependencies] && !cached_asset[:metadata][:dependencies].empty?
239
- cached_asset[:metadata][:dependencies] = cached_asset[:metadata][:dependencies].dup
240
- cached_asset[:metadata][:dependencies].map! do |uri|
241
- uri.start_with?("file-digest://".freeze) ? compress_from_root(uri) : uri
242
- end
243
- end
244
+ compress_key_from_hash(cached_asset[:metadata], :included)
245
+ compress_key_from_hash(cached_asset[:metadata], :links)
246
+ compress_key_from_hash(cached_asset[:metadata], :stubbed)
247
+ compress_key_from_hash(cached_asset[:metadata], :required)
248
+ compress_key_from_hash(cached_asset[:metadata], :to_load)
249
+ compress_key_from_hash(cached_asset[:metadata], :to_link)
250
+ compress_key_from_hash(cached_asset[:metadata], :dependencies) { |uri| uri.start_with?("file-digest://") }
244
251
 
245
- # compress all _dependencies in metadata like `sass_dependencies`
246
252
  cached_asset[:metadata].each do |key, value|
247
- next unless key =~ /_dependencies\z/
248
- cached_asset[:metadata][key] = value.dup
249
- cached_asset[:metadata][key].map! {|uri| compress_from_root(uri) }
253
+ next unless key.match?(/_dependencies\z/) # rubocop:disable Performance/EndWith
254
+ compress_key_from_hash(cached_asset[:metadata], key)
250
255
  end
251
256
  end
252
257
 
@@ -53,7 +53,7 @@ module Sprockets
53
53
 
54
54
  # If directory is given w/o filename, pick a random manifest location
55
55
  if @directory && @filename.nil?
56
- @filename = find_directory_manifest(@directory)
56
+ @filename = find_directory_manifest(@directory, logger)
57
57
  end
58
58
 
59
59
  unless @directory && @filename
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require 'securerandom'
3
+ require 'logger'
3
4
 
4
5
  module Sprockets
5
6
  # Public: Manifest utilities.
@@ -33,10 +34,13 @@ module Sprockets
33
34
  # # => "/app/public/assets/.sprockets-manifest-abc123.json"
34
35
  #
35
36
  # Returns String filename.
36
- def find_directory_manifest(dirname)
37
+ def find_directory_manifest(dirname, logger = Logger.new($stderr))
37
38
  entries = File.directory?(dirname) ? Dir.entries(dirname) : []
38
- entry = entries.find { |e| e =~ MANIFEST_RE } ||
39
- generate_manifest_path
39
+ manifest_entries = entries.select { |e| e =~ MANIFEST_RE }
40
+ if manifest_entries.length > 1
41
+ logger.warn("Found multiple manifests: #{manifest_entries}. Choosing the first alphabetically: #{manifest_entries.first}")
42
+ end
43
+ entry = manifest_entries.first || generate_manifest_path
40
44
  File.join(dirname, entry)
41
45
  end
42
46
  end
@@ -98,7 +98,7 @@ module Sprockets
98
98
  #
99
99
  # Returns true if path is relative, otherwise false.
100
100
  def relative_path?(path)
101
- path =~ /^\.\.?($|#{SEPARATOR_PATTERN})/ ? true : false
101
+ path.match?(/^\.\.?($|#{SEPARATOR_PATTERN})/) ? true : false
102
102
  end
103
103
 
104
104
  # Public: Get relative path from `start` to `dest`.
@@ -161,29 +161,9 @@ module Sprockets
161
161
  if !key.instance_of?(Symbol)
162
162
  raise TypeError, "processor metadata[#{key.inspect}] expected to be a Symbol"
163
163
  end
164
-
165
- if !valid_processor_metadata_value?(value)
166
- raise TypeError, "processor metadata[:#{key}] returned a complex type: #{value.inspect}\n" +
167
- "Only #{VALID_METADATA_TYPES.to_a.join(", ")} maybe used."
168
- end
169
164
  end
170
165
 
171
166
  result
172
167
  end
173
-
174
- # Internal: Validate object is in validate metadata whitelist.
175
- #
176
- # value - Any Object
177
- #
178
- # Returns true if class is in whitelist otherwise false.
179
- def valid_processor_metadata_value?(value)
180
- if VALID_METADATA_VALUE_TYPES_HASH[value.class]
181
- true
182
- elsif VALID_METADATA_COMPOUND_TYPES_HASH[value.class]
183
- value.all? { |v| valid_processor_metadata_value?(v) }
184
- else
185
- false
186
- end
187
- end
188
168
  end
189
169
  end
@@ -47,7 +47,7 @@ module Sprockets
47
47
  uri, deps = resolve(path, **kargs)
48
48
 
49
49
  unless uri
50
- message = String.new("couldn't find file '#{path}'")
50
+ message = +"couldn't find file '#{path}'"
51
51
 
52
52
  if relative_path?(path) && kargs[:base_path]
53
53
  load_path, _ = paths_split(config[:paths], kargs[:base_path])
@@ -1,10 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
  require 'sprockets/autoload'
3
- require 'sprockets/sass_compressor'
4
- require 'base64'
3
+ require 'sprockets/source_map_utils'
5
4
 
6
5
  module Sprockets
7
- class SasscCompressor < SassCompressor
6
+ # Public: Sass CSS minifier.
7
+ #
8
+ # To accept the default options
9
+ #
10
+ # environment.register_bundle_processor 'text/css',
11
+ # Sprockets::SasscCompressor
12
+ #
13
+ # Or to pass options to the Sass::Engine class.
14
+ #
15
+ # environment.register_bundle_processor 'text/css',
16
+ # Sprockets::SasscCompressor.new({ ... })
17
+ #
18
+ class SasscCompressor
19
+ # Public: Return singleton instance with default options.
20
+ #
21
+ # Returns SasscCompressor object.
22
+ def self.instance
23
+ @instance ||= new
24
+ end
25
+
26
+ def self.call(input)
27
+ instance.call(input)
28
+ end
29
+
8
30
  def initialize(options = {})
9
31
  @options = {
10
32
  syntax: :scss,
@@ -1,17 +1,49 @@
1
1
  # frozen_string_literal: true
2
- require 'sprockets/sass_processor'
3
- require 'sprockets/path_utils'
4
- require 'base64'
2
+ require 'rack/utils'
3
+ require 'sprockets/autoload'
4
+ require 'sprockets/source_map_utils'
5
+ require 'uri'
5
6
 
6
7
  module Sprockets
7
- class SasscProcessor < SassProcessor
8
+ # Processor engine class for the SASS/SCSS compiler. Depends on the `sassc` gem.
9
+ #
10
+ # For more infomation see:
11
+ #
12
+ # https://github.com/sass/sassc-ruby
13
+ # https://github.com/sass/sassc-rails
14
+ #
15
+ class SasscProcessor
16
+
17
+ # Internal: Defines default sass syntax to use. Exposed so the ScsscProcessor
18
+ # may override it.
19
+ def self.syntax
20
+ :sass
21
+ end
22
+
23
+ # Public: Return singleton instance with default options.
24
+ #
25
+ # Returns SasscProcessor object.
26
+ def self.instance
27
+ @instance ||= new
28
+ end
29
+
30
+ def self.call(input)
31
+ instance.call(input)
32
+ end
33
+
34
+ def self.cache_key
35
+ instance.cache_key
36
+ end
37
+
38
+ attr_reader :cache_key
39
+
8
40
  def initialize(options = {}, &block)
9
41
  @cache_version = options[:cache_version]
10
42
  @cache_key = "#{self.class.name}:#{VERSION}:#{Autoload::SassC::VERSION}:#{@cache_version}".freeze
11
43
  @importer_class = options[:importer]
12
44
  @sass_config = options[:sass_config] || {}
13
45
  @functions = Module.new do
14
- include SassProcessor::Functions
46
+ include Functions
15
47
  include options[:functions] if options[:functions]
16
48
  class_eval(&block) if block_given?
17
49
  end
@@ -43,6 +75,201 @@ module Sprockets
43
75
 
44
76
  private
45
77
 
78
+ def merge_options(options)
79
+ defaults = @sass_config.dup
80
+
81
+ if load_paths = defaults.delete(:load_paths)
82
+ options[:load_paths] += load_paths
83
+ end
84
+
85
+ options.merge!(defaults)
86
+ options
87
+ end
88
+
89
+ # Public: Functions injected into Sass context during Sprockets evaluation.
90
+ #
91
+ # This module may be extended to add global functionality to all Sprockets
92
+ # Sass environments. Though, scoping your functions to just your environment
93
+ # is preferred.
94
+ #
95
+ # module Sprockets::SasscProcessor::Functions
96
+ # def asset_path(path, options = {})
97
+ # end
98
+ # end
99
+ #
100
+ module Functions
101
+ # Public: Generate a url for asset path.
102
+ #
103
+ # Default implementation is deprecated. Currently defaults to
104
+ # Context#asset_path.
105
+ #
106
+ # Will raise NotImplementedError in the future. Users should provide their
107
+ # own base implementation.
108
+ #
109
+ # Returns a SassC::Script::Value::String.
110
+ def asset_path(path, options = {})
111
+ path = path.value
112
+
113
+ path, _, query, fragment = URI.split(path)[5..8]
114
+ path = sprockets_context.asset_path(path, options)
115
+ query = "?#{query}" if query
116
+ fragment = "##{fragment}" if fragment
117
+
118
+ Autoload::SassC::Script::Value::String.new("#{path}#{query}#{fragment}", :string)
119
+ end
120
+
121
+ # Public: Generate a asset url() link.
122
+ #
123
+ # path - SassC::Script::Value::String URL path
124
+ #
125
+ # Returns a SassC::Script::Value::String.
126
+ def asset_url(path, options = {})
127
+ Autoload::SassC::Script::Value::String.new("url(#{asset_path(path, options).value})")
128
+ end
129
+
130
+ # Public: Generate url for image path.
131
+ #
132
+ # path - SassC::Script::Value::String URL path
133
+ #
134
+ # Returns a SassC::Script::Value::String.
135
+ def image_path(path)
136
+ asset_path(path, type: :image)
137
+ end
138
+
139
+ # Public: Generate a image url() link.
140
+ #
141
+ # path - SassC::Script::Value::String URL path
142
+ #
143
+ # Returns a SassC::Script::Value::String.
144
+ def image_url(path)
145
+ asset_url(path, type: :image)
146
+ end
147
+
148
+ # Public: Generate url for video path.
149
+ #
150
+ # path - SassC::Script::Value::String URL path
151
+ #
152
+ # Returns a SassC::Script::Value::String.
153
+ def video_path(path)
154
+ asset_path(path, type: :video)
155
+ end
156
+
157
+ # Public: Generate a video url() link.
158
+ #
159
+ # path - SassC::Script::Value::String URL path
160
+ #
161
+ # Returns a SassC::Script::Value::String.
162
+ def video_url(path)
163
+ asset_url(path, type: :video)
164
+ end
165
+
166
+ # Public: Generate url for audio path.
167
+ #
168
+ # path - SassC::Script::Value::String URL path
169
+ #
170
+ # Returns a SassC::Script::Value::String.
171
+ def audio_path(path)
172
+ asset_path(path, type: :audio)
173
+ end
174
+
175
+ # Public: Generate a audio url() link.
176
+ #
177
+ # path - SassC::Script::Value::String URL path
178
+ #
179
+ # Returns a SassC::Script::Value::String.
180
+ def audio_url(path)
181
+ asset_url(path, type: :audio)
182
+ end
183
+
184
+ # Public: Generate url for font path.
185
+ #
186
+ # path - SassC::Script::Value::String URL path
187
+ #
188
+ # Returns a SassC::Script::Value::String.
189
+ def font_path(path)
190
+ asset_path(path, type: :font)
191
+ end
192
+
193
+ # Public: Generate a font url() link.
194
+ #
195
+ # path - SassC::Script::Value::String URL path
196
+ #
197
+ # Returns a SassC::Script::Value::String.
198
+ def font_url(path)
199
+ asset_url(path, type: :font)
200
+ end
201
+
202
+ # Public: Generate url for javascript path.
203
+ #
204
+ # path - SassC::Script::Value::String URL path
205
+ #
206
+ # Returns a SassC::Script::Value::String.
207
+ def javascript_path(path)
208
+ asset_path(path, type: :javascript)
209
+ end
210
+
211
+ # Public: Generate a javascript url() link.
212
+ #
213
+ # path - SassC::Script::Value::String URL path
214
+ #
215
+ # Returns a SassC::Script::Value::String.
216
+ def javascript_url(path)
217
+ asset_url(path, type: :javascript)
218
+ end
219
+
220
+ # Public: Generate url for stylesheet path.
221
+ #
222
+ # path - SassC::Script::Value::String URL path
223
+ #
224
+ # Returns a SassC::Script::Value::String.
225
+ def stylesheet_path(path)
226
+ asset_path(path, type: :stylesheet)
227
+ end
228
+
229
+ # Public: Generate a stylesheet url() link.
230
+ #
231
+ # path - SassC::Script::Value::String URL path
232
+ #
233
+ # Returns a SassC::Script::Value::String.
234
+ def stylesheet_url(path)
235
+ asset_url(path, type: :stylesheet)
236
+ end
237
+
238
+ # Public: Generate a data URI for asset path.
239
+ #
240
+ # path - SassC::Script::Value::String logical asset path
241
+ #
242
+ # Returns a SassC::Script::Value::String.
243
+ def asset_data_url(path)
244
+ url = sprockets_context.asset_data_uri(path.value)
245
+ Autoload::SassC::Script::Value::String.new("url(" + url + ")")
246
+ end
247
+
248
+ protected
249
+ # Public: The Environment.
250
+ #
251
+ # Returns Sprockets::Environment.
252
+ def sprockets_environment
253
+ options[:sprockets][:environment]
254
+ end
255
+
256
+ # Public: Mutatable set of dependencies.
257
+ #
258
+ # Returns a Set.
259
+ def sprockets_dependencies
260
+ options[:sprockets][:dependencies]
261
+ end
262
+
263
+ # Deprecated: Get the Context instance. Use APIs on
264
+ # sprockets_environment or sprockets_dependencies directly.
265
+ #
266
+ # Returns a Context instance.
267
+ def sprockets_context
268
+ options[:sprockets][:context]
269
+ end
270
+
271
+ end
272
+
46
273
  def engine_options(input, context)
47
274
  merge_options({
48
275
  filename: input[:filename],
@@ -248,7 +248,7 @@ module Sprockets
248
248
  headers = {}
249
249
 
250
250
  # Set caching headers
251
- headers["Cache-Control"] = String.new("public")
251
+ headers["Cache-Control"] = +"public"
252
252
  headers["ETag"] = %("#{etag}")
253
253
 
254
254
  # If the request url contains a fingerprint, set a long
@@ -48,8 +48,10 @@ module Sprockets
48
48
  path = URI::Generic::DEFAULT_PARSER.unescape(path)
49
49
  path.force_encoding(Encoding::UTF_8)
50
50
 
51
- # Hack for parsing Windows "file:///C:/Users/IEUser" paths
52
- path.gsub!(/^\/([a-zA-Z]:)/, '\1'.freeze)
51
+ # Hack for parsing Windows "/C:/Users/IEUser" paths
52
+ if File::ALT_SEPARATOR && path[2] == ':'
53
+ path = path[1..-1]
54
+ end
53
55
 
54
56
  [scheme, host, path, query]
55
57
  end
@@ -58,7 +60,7 @@ module Sprockets
58
60
  #
59
61
  # Returns String.
60
62
  def join_file_uri(scheme, host, path, query)
61
- str = String.new("#{scheme}://")
63
+ str = +"#{scheme}://"
62
64
  str << host if host
63
65
  path = "/#{path}" unless path.start_with?("/".freeze)
64
66
  str << URI::Generic::DEFAULT_PARSER.escape(path)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Sprockets
3
- VERSION = "4.0.0.beta8"
3
+ VERSION = "4.0.0.beta9"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta8
4
+ version: 4.0.0.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-06-19 00:00:00.000000000 Z
12
+ date: 2019-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -171,6 +171,20 @@ dependencies:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
173
  version: '1.1'
174
+ - !ruby/object:Gem::Dependency
175
+ name: timecop
176
+ requirement: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.9.1
181
+ type: :development
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.9.1
174
188
  - !ruby/object:Gem::Dependency
175
189
  name: minitest
176
190
  requirement: !ruby/object:Gem::Requirement
@@ -219,14 +233,14 @@ dependencies:
219
233
  requirements:
220
234
  - - "~>"
221
235
  - !ruby/object:Gem::Version
222
- version: '10.0'
236
+ version: '12.0'
223
237
  type: :development
224
238
  prerelease: false
225
239
  version_requirements: !ruby/object:Gem::Requirement
226
240
  requirements:
227
241
  - - "~>"
228
242
  - !ruby/object:Gem::Version
229
- version: '10.0'
243
+ version: '12.0'
230
244
  - !ruby/object:Gem::Dependency
231
245
  name: sass
232
246
  requirement: !ruby/object:Gem::Requirement
@@ -245,20 +259,14 @@ dependencies:
245
259
  name: sassc
246
260
  requirement: !ruby/object:Gem::Requirement
247
261
  requirements:
248
- - - ">="
249
- - !ruby/object:Gem::Version
250
- version: 1.10.1
251
- - - "<"
262
+ - - "~>"
252
263
  - !ruby/object:Gem::Version
253
264
  version: '2.0'
254
265
  type: :development
255
266
  prerelease: false
256
267
  version_requirements: !ruby/object:Gem::Requirement
257
268
  requirements:
258
- - - ">="
259
- - !ruby/object:Gem::Version
260
- version: 1.10.1
261
- - - "<"
269
+ - - "~>"
262
270
  - !ruby/object:Gem::Version
263
271
  version: '2.0'
264
272
  - !ruby/object:Gem::Dependency
@@ -303,6 +311,20 @@ dependencies:
303
311
  - - "~>"
304
312
  - !ruby/object:Gem::Version
305
313
  version: 0.0.4
314
+ - !ruby/object:Gem::Dependency
315
+ name: rubocop-performance
316
+ requirement: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: '1.3'
321
+ type: :development
322
+ prerelease: false
323
+ version_requirements: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - "~>"
326
+ - !ruby/object:Gem::Version
327
+ version: '1.3'
306
328
  description: Sprockets is a Rack-based asset packaging system that concatenates and
307
329
  serves JavaScript, CoffeeScript, CSS, Sass, and SCSS.
308
330
  email:
@@ -408,15 +430,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
408
430
  requirements:
409
431
  - - ">="
410
432
  - !ruby/object:Gem::Version
411
- version: 2.2.0
433
+ version: 2.5.0
412
434
  required_rubygems_version: !ruby/object:Gem::Requirement
413
435
  requirements:
414
436
  - - ">"
415
437
  - !ruby/object:Gem::Version
416
438
  version: 1.3.1
417
439
  requirements: []
418
- rubyforge_project: sprockets
419
- rubygems_version: 2.7.6
440
+ rubygems_version: 3.0.3
420
441
  signing_key:
421
442
  specification_version: 4
422
443
  summary: Rack-based asset packaging system