sprockets 3.6.1 → 3.6.2

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: 395f97699c07aab98cec80882a5e7f3737aaaa6c
4
- data.tar.gz: 30beb1d71c6bfa3c26472dc5d9e30a0e9d6a077f
3
+ metadata.gz: 65038c23bce0f78dc46dbd1a795a5f7d63ae3e6d
4
+ data.tar.gz: 2eb90ccca5227ccb89ad3d120d3f517a40207c82
5
5
  SHA512:
6
- metadata.gz: c7f9e96886a62cc1704af19e305beb4e6b1ae49cabcd2c23d3464d91694c1798920e9aba2658a1725e1628a0689d11ea83d03839e5254de21d81a9d13d1423da
7
- data.tar.gz: 576f6ecb35fa61eeef7f14c22a8de476f916cd704865185abfd11170375df51058df781b4db57d98f463704ad6cf48b5f7a0af130648bfa5b26d8bac89d4eb2f
6
+ metadata.gz: 8f679d41d2cf85076d30cfba047f7e339683e21942db8bda5e7199be98d5a985b386a9364ef8ebf093cc902bd6e1943d3c51a94526fa5525c626b68b3ee84551
7
+ data.tar.gz: 01172abe899835640b8bb76ca6c8f2ba519c060c24306ba72255513fb85c8424ed481e681d86357bd4f221d7eb4276e5fd143821bc3671853fa6b526d484b320
@@ -1,3 +1,7 @@
1
+ **3.6.2** (June 21, 2016)
2
+
3
+ * More performance improvements.
4
+
1
5
  **3.6.1** (June 17, 2016)
2
6
 
3
7
  * Some performance improvements.
@@ -34,6 +34,50 @@ module Sprockets
34
34
  DIGEST_SIZES[bytes.bytesize]
35
35
  end
36
36
 
37
+ ADD_VALUE_TO_DIGEST = {
38
+ String => ->(val, digest) { digest << val },
39
+ FalseClass => ->(val, digest) { digest << 'FalseClass'.freeze },
40
+ TrueClass => ->(val, digest) { digest << 'TrueClass'.freeze },
41
+ NilClass => ->(val, digest) { digest << 'NilClass'.freeze },
42
+
43
+ Symbol => ->(val, digest) {
44
+ digest << 'Symbol'.freeze
45
+ digest << val.to_s
46
+ },
47
+ Fixnum => ->(val, digest) {
48
+ digest << 'Fixnum'.freeze
49
+ digest << val.to_s
50
+ },
51
+ Bignum => ->(val, digest) {
52
+ digest << 'Bignum'.freeze
53
+ digest << val.to_s
54
+ },
55
+ Array => ->(val, digest) {
56
+ digest << 'Array'.freeze
57
+ val.each do |element|
58
+ ADD_VALUE_TO_DIGEST[element.class].call(element, digest)
59
+ end
60
+ },
61
+ Hash => ->(val, digest) {
62
+ digest << 'Hash'.freeze
63
+ val.sort.each do |array|
64
+ ADD_VALUE_TO_DIGEST[Array].call(array, digest)
65
+ end
66
+ },
67
+ Set => ->(val, digest) {
68
+ digest << 'Set'.freeze
69
+ ADD_VALUE_TO_DIGEST[Array].call(val.to_a, digest)
70
+ },
71
+ Encoding => ->(val, digest) {
72
+ digest << 'Encoding'.freeze
73
+ digest << val.name
74
+ },
75
+ }
76
+ ADD_VALUE_TO_DIGEST.default_proc = ->(_, val) {
77
+ raise TypeError, "couldn't digest #{ val }"
78
+ }
79
+ private_constant :ADD_VALUE_TO_DIGEST
80
+
37
81
  # Internal: Generate a hexdigest for a nested JSON serializable object.
38
82
  #
39
83
  # This is used for generating cache keys, so its pretty important its
@@ -44,46 +88,8 @@ module Sprockets
44
88
  # Returns a String digest of the object.
45
89
  def digest(obj)
46
90
  digest = digest_class.new
47
- queue = [obj]
48
-
49
- while queue.length > 0
50
- obj = queue.shift
51
- klass = obj.class
52
-
53
- if klass == String
54
- digest << obj
55
- elsif klass == Symbol
56
- digest << 'Symbol'
57
- digest << obj.to_s
58
- elsif klass == Fixnum
59
- digest << 'Fixnum'
60
- digest << obj.to_s
61
- elsif klass == Bignum
62
- digest << 'Bignum'
63
- digest << obj.to_s
64
- elsif klass == TrueClass
65
- digest << 'TrueClass'
66
- elsif klass == FalseClass
67
- digest << 'FalseClass'
68
- elsif klass == NilClass
69
- digest << 'NilClass'.freeze
70
- elsif klass == Array
71
- digest << 'Array'
72
- queue.concat(obj)
73
- elsif klass == Hash
74
- digest << 'Hash'
75
- queue.concat(obj.sort)
76
- elsif klass == Set
77
- digest << 'Set'
78
- queue.concat(obj.to_a)
79
- elsif klass == Encoding
80
- digest << 'Encoding'
81
- digest << obj.name
82
- else
83
- raise TypeError, "couldn't digest #{klass}"
84
- end
85
- end
86
91
 
92
+ ADD_VALUE_TO_DIGEST[obj.class].call(obj, digest)
87
93
  digest.digest
88
94
  end
89
95
 
@@ -121,6 +121,17 @@ module Sprockets
121
121
  Set
122
122
  ]).freeze
123
123
 
124
+ # Internal: Hash of all "simple" value types allowed to be returned in
125
+ # processor metadata.
126
+ VALID_METADATA_VALUE_TYPES_HASH = VALID_METADATA_VALUE_TYPES.each_with_object({}) do |type, hash|
127
+ hash[type] = true
128
+ end.freeze
129
+
130
+ # Internal: Hash of all nested compound metadata types that can nest values.
131
+ VALID_METADATA_COMPOUND_TYPES_HASH = VALID_METADATA_COMPOUND_TYPES.each_with_object({}) do |type, hash|
132
+ hash[type] = true
133
+ end.freeze
134
+
124
135
  # Internal: Set of all allowed metadata types.
125
136
  VALID_METADATA_TYPES = (VALID_METADATA_VALUE_TYPES + VALID_METADATA_COMPOUND_TYPES).freeze
126
137
 
@@ -159,9 +170,9 @@ module Sprockets
159
170
  #
160
171
  # Returns true if class is in whitelist otherwise false.
161
172
  def valid_processor_metadata_value?(value)
162
- if VALID_METADATA_VALUE_TYPES.include?(value.class)
173
+ if VALID_METADATA_VALUE_TYPES_HASH[value.class]
163
174
  true
164
- elsif VALID_METADATA_COMPOUND_TYPES.include?(value.class)
175
+ elsif VALID_METADATA_COMPOUND_TYPES_HASH[value.class]
165
176
  value.all? { |v| valid_processor_metadata_value?(v) }
166
177
  else
167
178
  false
@@ -1,3 +1,3 @@
1
1
  module Sprockets
2
- VERSION = "3.6.1"
2
+ VERSION = "3.6.2"
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.6.1
4
+ version: 3.6.2
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: 2016-06-17 00:00:00.000000000 Z
12
+ date: 2016-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack