sprockets 3.5.2 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprockets might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 929bf083589cbbd2e0c130a06fd8c3a528dc9be8
4
- data.tar.gz: 87faf2c9c2276b06057647e99ab856d19ae3e1cb
3
+ metadata.gz: a1eef394792f4af6343438fcc3666a88ca893348
4
+ data.tar.gz: 464e323e318b96534f12621a3f1a5dfc9a024425
5
5
  SHA512:
6
- metadata.gz: 88961b6e91bcc5f16e4e0d62440a03e16cb783ec57c953300a971d327d02f52871e8a0826fec6695711ddf6dda0894f2a1abf213d8bca8c5a8d5a68b7b6abe11
7
- data.tar.gz: 250a379b175d515ca5a34c8f85fe50a3b9af881c367783756e72ff20fb34cc2a492c646af0b31f1c53c78beaff6fd690253a14a44dbf70f03671403025c9c512
6
+ metadata.gz: 446a6718c9ae7f0e94e57672680c7bbb2233855000dd813d3dc1867d0d3c6f12f3dcb43abe21f9a72bfcc05bff7524b9030eb771c342d4ea65fdde1169887f21
7
+ data.tar.gz: e49c3925afb5988848f46439b1e9c3b5334932e599c13398f0a7a6a312dde2f228c0e679bd8fc898e80dd1861bc4fcfedfd807a9872b91b2af14be210870ab7d
@@ -1,4 +1,8 @@
1
- **Master**
1
+ **3.6.0** (April 6, 2016)
2
+
3
+ * Add `Manifest#find_sources` to return the source of the compiled assets.
4
+ * Fix the list of compressable mime types.
5
+ * Improve performance of the `FileStore` cache.
2
6
 
3
7
  **3.5.2** (December 8, 2015)
4
8
 
@@ -76,6 +76,7 @@ module Sprockets
76
76
 
77
77
  # Common font types
78
78
  register_mime_type 'application/vnd.ms-fontobject', extensions: ['.eot']
79
+ register_mime_type 'application/x-font-opentype', extensions: ['.otf']
79
80
  register_mime_type 'application/x-font-ttf', extensions: ['.ttf']
80
81
  register_mime_type 'application/font-woff', extensions: ['.woff']
81
82
 
@@ -153,7 +153,9 @@ module Sprockets
153
153
  #
154
154
  # Returns a String with a length less than 250 characters.
155
155
  def expand_key(key)
156
- "sprockets/v#{VERSION}/#{DigestUtils.pack_urlsafe_base64digest(DigestUtils.digest(key))}"
156
+ digest_key = DigestUtils.pack_urlsafe_base64digest(DigestUtils.digest(key))
157
+ namespace = digest_key[0, 2]
158
+ "sprockets/v#{VERSION}/#{namespace}/#{digest_key}"
157
159
  end
158
160
 
159
161
  PEEK_SIZE = 100
@@ -143,11 +143,10 @@ module Sprockets
143
143
  })
144
144
  validate_processor_result!(result)
145
145
  source = result.delete(:data)
146
- metadata = result.merge!(
147
- charset: source.encoding.name.downcase,
148
- digest: digest(source),
149
- length: source.bytesize
150
- )
146
+ metadata = result
147
+ metadata[:charset] = source.encoding.name.downcase unless metadata.key?(:charset)
148
+ metadata[:digest] = digest(source)
149
+ metadata[:length] = source.bytesize
151
150
  else
152
151
  dependencies << build_file_digest_uri(unloaded.filename)
153
152
  metadata = {
@@ -149,6 +149,23 @@ module Sprockets
149
149
  nil
150
150
  end
151
151
 
152
+ # Public: Find the source of assets by paths.
153
+ #
154
+ # Returns Enumerator of assets file content.
155
+ def find_sources(*args)
156
+ return to_enum(__method__, *args) unless block_given?
157
+
158
+ if environment
159
+ find(*args).each do |asset|
160
+ yield asset.source
161
+ end
162
+ else
163
+ args.each do |path|
164
+ yield File.binread(File.join(dir, assets[path]))
165
+ end
166
+ end
167
+ end
168
+
152
169
  # Compile and write asset to directory. The asset is written to a
153
170
  # fingerprinted filename like
154
171
  # `application-2e8e9a7c6b0aafa0c9bdeec90ea30213.js`. An entry is
@@ -1,5 +1,3 @@
1
- require 'fileutils'
2
-
3
1
  module Sprockets
4
2
  # Internal: File and path related utilities. Mixed into Environment.
5
3
  #
@@ -276,9 +274,9 @@ module Sprockets
276
274
  yield f
277
275
  end
278
276
 
279
- FileUtils.mv(tmpname, filename)
277
+ File.rename(tmpname, filename)
280
278
  ensure
281
- FileUtils.rm(tmpname) if File.exist?(tmpname)
279
+ File.delete(tmpname) if File.exist?(tmpname)
282
280
  end
283
281
  end
284
282
  end
@@ -8,6 +8,16 @@ module Sprockets
8
8
  @charset = asset.charset
9
9
  end
10
10
 
11
+ # What non-text mime types should we compress? This list comes from:
12
+ # https://www.fastly.com/blog/new-gzip-settings-and-deciding-what-compress
13
+ COMPRESSABLE_MIME_TYPES = {
14
+ "application/vnd.ms-fontobject" => true,
15
+ "application/x-font-opentype" => true,
16
+ "application/x-font-ttf" => true,
17
+ "image/x-icon" => true,
18
+ "image/svg+xml" => true
19
+ }
20
+
11
21
  # Private: Returns whether or not an asset can be compressed.
12
22
  #
13
23
  # We want to compress any file that is text based.
@@ -21,9 +31,8 @@ module Sprockets
21
31
  # encoded text. We can check this value to see if the asset
22
32
  # can be compressed.
23
33
  #
24
- # SVG images are text but do not have
25
- # a charset defined, this is special cased.
26
- @charset || @content_type == "image/svg+xml".freeze
34
+ # We also check against our list of non-text compressible mime types
35
+ @charset || COMPRESSABLE_MIME_TYPES.include?(@content_type)
27
36
  end
28
37
 
29
38
  # Private: Opposite of `can_compress?`.
@@ -1,3 +1,3 @@
1
1
  module Sprockets
2
- VERSION = "3.5.2"
2
+ VERSION = "3.6.0"
3
3
  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: 3.5.2
4
+ version: 3.6.0
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: 2015-12-08 00:00:00.000000000 Z
12
+ date: 2016-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -332,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
332
  version: '0'
333
333
  requirements: []
334
334
  rubyforge_project: sprockets
335
- rubygems_version: 2.4.5.1
335
+ rubygems_version: 2.5.1
336
336
  signing_key:
337
337
  specification_version: 4
338
338
  summary: Rack-based asset packaging system