sprockets 3.7.0 → 3.7.1

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: f3dc22bf9c6e294e72cca5cf894e39d28d56b419
4
- data.tar.gz: 58e0dcc75e743f649f83e48080c5f060c091dd85
3
+ metadata.gz: d7893a1473428786e2b49eaf7554496d153a57b1
4
+ data.tar.gz: 805a200abef6ae553c05d71b343dc367c8da0ba1
5
5
  SHA512:
6
- metadata.gz: 2c2cd23c31002b28297944e76fff80b8a05fcdc1f4aa64652bf43c5481c2f006854b20e6d4e45e234a482bf45ddd2e8cf122f0a9a5b1ae71ee421f346a2ba478
7
- data.tar.gz: 06168eae576a776fef2b13ba12f5c4a51e6e7846e1b7e098e0052e9da52fd40e9aef3830aad0bb36dc099643d113182eae39e1d0ac09456bd63bb3e19e5e5cac
6
+ metadata.gz: 14207c7eb061d38e9a848e4c1632764939718352ea48adb3fec86f6bfd4799eae3a36767a7a1669ca890ae2810d9a63b9da12c88c69f99c6276a945be92dc7c3
7
+ data.tar.gz: 2015339e22e7268c3f817aa6e16a308b1c0d22de40e55e9795d1450a54bf41a1b0605328b8bdd5d15cfd055ec2165c6af751f5a93d46f26802eb97509bcd15bd
@@ -1,4 +1,8 @@
1
- ** 3.7.0** (July 21, 2016)
1
+ **3.7.1** (December 19, 2016)
2
+
3
+ * Ruby 2.4 support for Sprockets 3.
4
+
5
+ **3.7.0** (July 21, 2016)
2
6
 
3
7
  * Deprecated interfaces now emit deprecation warnings #345
4
8
 
@@ -103,7 +107,7 @@
103
107
 
104
108
  **3.0.0** (April 12, 2015)
105
109
 
106
- [Guide to upgrading from Sprockets 2.x to 3.x](https://github.com/rails/sprockets/blob/master/UPGRADING.md)
110
+ [Guide to upgrading from Sprockets 2.x to 3.x](https://github.com/rails/sprockets/blob/3.x/UPGRADING.md)
107
111
 
108
112
  * New processor API. Tilt interface is deprecated.
109
113
  * Improved file store caching backend.
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ $VERBOSE = nil
2
3
 
3
4
  require 'sprockets'
4
5
  require 'optparse'
@@ -35,11 +35,12 @@ module Sprockets
35
35
  attr_reader :cache_key
36
36
 
37
37
  def initialize(options = {})
38
- @compiler = Autoload::Closure::Compiler.new(options)
38
+ @options = options
39
39
  @cache_key = "#{self.class.name}:#{Autoload::Closure::VERSION}:#{Autoload::Closure::COMPILER_VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
40
40
  end
41
41
 
42
42
  def call(input)
43
+ @compiler ||= Autoload::Closure::Compiler.new(@options)
43
44
  @compiler.compile(input[:data])
44
45
  end
45
46
  end
@@ -44,12 +44,8 @@ module Sprockets
44
44
  digest << 'Symbol'.freeze
45
45
  digest << val.to_s
46
46
  },
47
- Fixnum => ->(val, digest) {
48
- digest << 'Fixnum'.freeze
49
- digest << val.to_s
50
- },
51
- Bignum => ->(val, digest) {
52
- digest << 'Bignum'.freeze
47
+ Integer => ->(val, digest) {
48
+ digest << 'Integer'.freeze
53
49
  digest << val.to_s
54
50
  },
55
51
  Array => ->(val, digest) {
@@ -73,6 +69,16 @@ module Sprockets
73
69
  digest << val.name
74
70
  },
75
71
  }
72
+ if 0.class != Integer # Ruby < 2.4
73
+ ADD_VALUE_TO_DIGEST[Fixnum] = ->(val, digest) {
74
+ digest << 'Integer'.freeze
75
+ digest << val.to_s
76
+ }
77
+ ADD_VALUE_TO_DIGEST[Bignum] = ->(val, digest) {
78
+ digest << 'Integer'.freeze
79
+ digest << val.to_s
80
+ }
81
+ end
76
82
  ADD_VALUE_TO_DIGEST.default_proc = ->(_, val) {
77
83
  raise TypeError, "couldn't digest #{ val }"
78
84
  }
@@ -107,12 +107,10 @@ module Sprockets
107
107
  VALID_METADATA_VALUE_TYPES = Set.new([
108
108
  String,
109
109
  Symbol,
110
- Fixnum,
111
- Bignum,
112
110
  TrueClass,
113
111
  FalseClass,
114
112
  NilClass
115
- ]).freeze
113
+ ] + (0.class == Integer ? [Integer] : [Bignum, Fixnum])).freeze
116
114
 
117
115
  # Internal: Set of all nested compound metadata types that can nest values.
118
116
  VALID_METADATA_COMPOUND_TYPES = Set.new([
@@ -23,7 +23,7 @@ module Sprockets
23
23
  start_time = Time.now.to_f
24
24
  time_elapsed = lambda { ((Time.now.to_f - start_time) * 1000).to_i }
25
25
 
26
- if env['REQUEST_METHOD'] != 'GET'
26
+ if !['GET', 'HEAD'].include?(env['REQUEST_METHOD'])
27
27
  return method_not_allowed_response
28
28
  end
29
29
 
@@ -39,7 +39,7 @@ module Sprockets
39
39
 
40
40
  # URLs containing a `".."` are rejected for security reasons.
41
41
  if forbidden_request?(path)
42
- return forbidden_response
42
+ return forbidden_response(env)
43
43
  end
44
44
 
45
45
  # Look up the asset.
@@ -86,10 +86,10 @@ module Sprockets
86
86
  not_modified_response(env, if_none_match)
87
87
  when :not_found
88
88
  logger.info "#{msg} 404 Not Found (#{time_elapsed.call}ms)"
89
- not_found_response
89
+ not_found_response(env)
90
90
  when :precondition_failed
91
91
  logger.info "#{msg} 412 Precondition Failed (#{time_elapsed.call}ms)"
92
- precondition_failed_response
92
+ precondition_failed_response(env)
93
93
  end
94
94
  rescue Exception => e
95
95
  logger.error "Error compiling asset #{path}:"
@@ -118,9 +118,17 @@ module Sprockets
118
118
  path.include?("..") || absolute_path?(path)
119
119
  end
120
120
 
121
+ def head_request?(env)
122
+ env['REQUEST_METHOD'] == 'HEAD'
123
+ end
124
+
121
125
  # Returns a 200 OK response tuple
122
126
  def ok_response(asset, env)
123
- [ 200, headers(env, asset, asset.length), asset ]
127
+ if head_request?(env)
128
+ [ 200, headers(env, asset, 0), [] ]
129
+ else
130
+ [ 200, headers(env, asset, asset.length), asset ]
131
+ end
124
132
  end
125
133
 
126
134
  # Returns a 304 Not Modified response tuple
@@ -129,21 +137,33 @@ module Sprockets
129
137
  end
130
138
 
131
139
  # Returns a 403 Forbidden response tuple
132
- def forbidden_response
133
- [ 403, { "Content-Type" => "text/plain", "Content-Length" => "9" }, [ "Forbidden" ] ]
140
+ def forbidden_response(env)
141
+ if head_request?(env)
142
+ [ 403, { "Content-Type" => "text/plain", "Content-Length" => "0" }, [] ]
143
+ else
144
+ [ 403, { "Content-Type" => "text/plain", "Content-Length" => "9" }, [ "Forbidden" ] ]
145
+ end
134
146
  end
135
147
 
136
148
  # Returns a 404 Not Found response tuple
137
- def not_found_response
138
- [ 404, { "Content-Type" => "text/plain", "Content-Length" => "9", "X-Cascade" => "pass" }, [ "Not found" ] ]
149
+ def not_found_response(env)
150
+ if head_request?(env)
151
+ [ 404, { "Content-Type" => "text/plain", "Content-Length" => "0", "X-Cascade" => "pass" }, [] ]
152
+ else
153
+ [ 404, { "Content-Type" => "text/plain", "Content-Length" => "9", "X-Cascade" => "pass" }, [ "Not found" ] ]
154
+ end
139
155
  end
140
156
 
141
157
  def method_not_allowed_response
142
158
  [ 405, { "Content-Type" => "text/plain", "Content-Length" => "18" }, [ "Method Not Allowed" ] ]
143
159
  end
144
160
 
145
- def precondition_failed_response
146
- [ 412, { "Content-Type" => "text/plain", "Content-Length" => "19", "X-Cascade" => "pass" }, [ "Precondition Failed" ] ]
161
+ def precondition_failed_response(env)
162
+ if head_request?(env)
163
+ [ 412, { "Content-Type" => "text/plain", "Content-Length" => "0", "X-Cascade" => "pass" }, [] ]
164
+ else
165
+ [ 412, { "Content-Type" => "text/plain", "Content-Length" => "19", "X-Cascade" => "pass" }, [ "Precondition Failed" ] ]
166
+ end
147
167
  end
148
168
 
149
169
  # Returns a JavaScript response that re-throws a Ruby exception
@@ -44,11 +44,12 @@ module Sprockets
44
44
  options[:comments] ||= :none
45
45
  end
46
46
 
47
- @uglifier = Autoload::Uglifier.new(options)
47
+ @options = options
48
48
  @cache_key = "#{self.class.name}:#{Autoload::Uglifier::VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
49
49
  end
50
50
 
51
51
  def call(input)
52
+ @uglifier ||= Autoload::Uglifier.new(@options)
52
53
  @uglifier.compile(input[:data])
53
54
  end
54
55
  end
@@ -14,11 +14,15 @@ module Sprockets
14
14
  #
15
15
  # Returns false if .dup would raise a TypeError, otherwise true.
16
16
  def duplicable?(obj)
17
- case obj
18
- when NilClass, FalseClass, TrueClass, Symbol, Numeric
19
- false
20
- else
17
+ if RUBY_VERSION >= "2.4.0"
21
18
  true
19
+ else
20
+ case obj
21
+ when NilClass, FalseClass, TrueClass, Symbol, Numeric
22
+ false
23
+ else
24
+ true
25
+ end
22
26
  end
23
27
  end
24
28
 
@@ -1,3 +1,3 @@
1
1
  module Sprockets
2
- VERSION = "3.7.0"
2
+ VERSION = "3.7.1"
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.7.0
4
+ version: 3.7.1
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-07-21 00:00:00.000000000 Z
12
+ date: 2016-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -333,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  requirements: []
335
335
  rubyforge_project: sprockets
336
- rubygems_version: 2.5.1
336
+ rubygems_version: 2.5.2
337
337
  signing_key:
338
338
  specification_version: 4
339
339
  summary: Rack-based asset packaging system