sprockets 3.6.3 → 3.7.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: 60bd74a92e432ab26a1c9ff6a5f3a1ced8ccc1c8
4
- data.tar.gz: 8708f6433b0ab2438bea014db7783388d2c0d493
3
+ metadata.gz: f3dc22bf9c6e294e72cca5cf894e39d28d56b419
4
+ data.tar.gz: 58e0dcc75e743f649f83e48080c5f060c091dd85
5
5
  SHA512:
6
- metadata.gz: 41f481255492f56a331de0a8b5df114a9f60681b048a79cba5cf90f44b08622fb08f6cf23fa108fb2a448890c1808d685ba785934db949ac47911d6f1aebee98
7
- data.tar.gz: 45204e3291b8427570c24e75a245039a02a8cb10ceda060984a904c7c9abea4d1f19e4ce50133fc83e2980da93ce1485f0d38b3c6188d075ab985b026d018971
6
+ metadata.gz: 2c2cd23c31002b28297944e76fff80b8a05fcdc1f4aa64652bf43c5481c2f006854b20e6d4e45e234a482bf45ddd2e8cf122f0a9a5b1ae71ee421f346a2ba478
7
+ data.tar.gz: 06168eae576a776fef2b13ba12f5c4a51e6e7846e1b7e098e0052e9da52fd40e9aef3830aad0bb36dc099643d113182eae39e1d0ac09456bd63bb3e19e5e5cac
@@ -1,3 +1,7 @@
1
+ ** 3.7.0** (July 21, 2016)
2
+
3
+ * Deprecated interfaces now emit deprecation warnings #345
4
+
1
5
  **3.6.3** (July 1, 2016)
2
6
 
3
7
  * Faster asset lookup in large directories #336
@@ -4,6 +4,7 @@ require 'sprockets/cache'
4
4
  require 'sprockets/environment'
5
5
  require 'sprockets/errors'
6
6
  require 'sprockets/manifest'
7
+ require 'sprockets/deprecation'
7
8
 
8
9
  module Sprockets
9
10
  require 'sprockets/processor_utils'
@@ -122,25 +123,31 @@ module Sprockets
122
123
 
123
124
  # Mmm, CoffeeScript
124
125
  require 'sprockets/coffee_script_processor'
125
- register_engine '.coffee', CoffeeScriptProcessor, mime_type: 'application/javascript'
126
+ Deprecation.silence do
127
+ register_engine '.coffee', CoffeeScriptProcessor, mime_type: 'application/javascript', silence_deprecation: true
128
+ end
126
129
 
127
130
  # JST engines
128
131
  require 'sprockets/eco_processor'
129
132
  require 'sprockets/ejs_processor'
130
133
  require 'sprockets/jst_processor'
131
- register_engine '.jst', JstProcessor, mime_type: 'application/javascript'
132
- register_engine '.eco', EcoProcessor, mime_type: 'application/javascript'
133
- register_engine '.ejs', EjsProcessor, mime_type: 'application/javascript'
134
+ Deprecation.silence do
135
+ register_engine '.jst', JstProcessor, mime_type: 'application/javascript', silence_deprecation: true
136
+ register_engine '.eco', EcoProcessor, mime_type: 'application/javascript', silence_deprecation: true
137
+ register_engine '.ejs', EjsProcessor, mime_type: 'application/javascript', silence_deprecation: true
138
+ end
134
139
 
135
140
  # CSS engines
136
141
  require 'sprockets/sass_processor'
137
- register_engine '.sass', SassProcessor, mime_type: 'text/css'
138
- register_engine '.scss', ScssProcessor, mime_type: 'text/css'
142
+ Deprecation.silence do
143
+ register_engine '.sass', SassProcessor, mime_type: 'text/css', silence_deprecation: true
144
+ register_engine '.scss', ScssProcessor, mime_type: 'text/css', silence_deprecation: true
145
+ end
139
146
  register_bundle_metadata_reducer 'text/css', :sass_dependencies, Set.new, :+
140
147
 
141
148
  # Other
142
149
  require 'sprockets/erb_processor'
143
- register_engine '.erb', ERBProcessor, mime_type: 'text/plain'
150
+ register_engine '.erb', ERBProcessor, mime_type: 'text/plain', silence_deprecation: true
144
151
 
145
152
  register_dependency_resolver 'environment-version' do |env|
146
153
  env.version
@@ -2,5 +2,16 @@ require 'sprockets/coffee_script_processor'
2
2
 
3
3
  module Sprockets
4
4
  # Deprecated
5
- CoffeeScriptTemplate = CoffeeScriptProcessor
5
+ module CoffeeScriptTemplate
6
+ VERSION = CoffeeScriptProcessor::VERSION
7
+
8
+ def self.cache_key
9
+ CoffeeScriptProcessor.cache_key
10
+ end
11
+
12
+ def self.call(*args)
13
+ Deprecation.new.warn "CoffeeScriptTemplate is deprecated please use CoffeeScriptProcessor instead"
14
+ CoffeeScriptProcessor.call(*args)
15
+ end
16
+ end
6
17
  end
@@ -0,0 +1,90 @@
1
+ module Sprockets
2
+ class Deprecation
3
+ THREAD_LOCAL__SILENCE_KEY = "_sprockets_deprecation_silence".freeze
4
+ DEFAULT_BEHAVIORS = {
5
+ raise: ->(message, callstack) {
6
+ e = DeprecationException.new(message)
7
+ e.set_backtrace(callstack.map(&:to_s))
8
+ raise e
9
+ },
10
+
11
+ stderr: ->(message, callstack) {
12
+ $stderr.puts(message)
13
+ },
14
+ }
15
+
16
+ attr_reader :callstack
17
+
18
+ def self.silence(&block)
19
+ Thread.current[THREAD_LOCAL__SILENCE_KEY] = true
20
+ block.call
21
+ ensure
22
+ Thread.current[THREAD_LOCAL__SILENCE_KEY] = false
23
+ end
24
+
25
+ def initialize(callstack = nil)
26
+ @callstack = callstack || caller(2)
27
+ end
28
+
29
+ def warn(message)
30
+ return if Thread.current[THREAD_LOCAL__SILENCE_KEY]
31
+ deprecation_message(message).tap do |m|
32
+ behavior.each { |b| b.call(m, callstack) }
33
+ end
34
+ end
35
+
36
+ private
37
+ def behavior
38
+ @behavior ||= [DEFAULT_BEHAVIORS[:stderr]]
39
+ end
40
+
41
+ def behavior=(behavior)
42
+ @behavior = Array(behavior).map { |b| DEFAULT_BEHAVIORS[b] || b }
43
+ end
44
+
45
+ def deprecation_message(message = nil)
46
+ message ||= "You are using deprecated behavior which will be removed from the next major or minor release."
47
+ "DEPRECATION WARNING: #{message} #{ deprecation_caller_message }"
48
+ end
49
+
50
+ def deprecation_caller_message
51
+ file, line, method = extract_callstack
52
+ if file
53
+ if line && method
54
+ "(called from #{method} at #{file}:#{line})"
55
+ else
56
+ "(called from #{file}:#{line})"
57
+ end
58
+ end
59
+ end
60
+
61
+ SPROCKETS_GEM_ROOT = File.expand_path("../../../../..", __FILE__) + "/"
62
+
63
+ def ignored_callstack(path)
64
+ path.start_with?(SPROCKETS_GEM_ROOT) || path.start_with?(RbConfig::CONFIG['rubylibdir'])
65
+ end
66
+
67
+ def extract_callstack
68
+ return _extract_callstack if callstack.first.is_a? String
69
+
70
+ offending_line = callstack.find { |frame|
71
+ frame.absolute_path && !ignored_callstack(frame.absolute_path)
72
+ } || callstack.first
73
+
74
+ [offending_line.path, offending_line.lineno, offending_line.label]
75
+ end
76
+
77
+ def _extract_callstack
78
+ offending_line = callstack.find { |line| !ignored_callstack(line) } || callstack.first
79
+
80
+ if offending_line
81
+ if md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/)
82
+ md.captures
83
+ else
84
+ offending_line
85
+ end
86
+ end
87
+ end
88
+ end
89
+ private_constant :Deprecation
90
+ end
@@ -2,5 +2,16 @@ require 'sprockets/eco_processor'
2
2
 
3
3
  module Sprockets
4
4
  # Deprecated
5
- EcoTemplate = EcoProcessor
5
+ module EcoTemplate
6
+ VERSION = EcoProcessor::VERSION
7
+
8
+ def self.cache_key
9
+ EcoProcessor.cache_key
10
+ end
11
+
12
+ def self.call(*args)
13
+ Deprecation.new.warn "EcoTemplate is deprecated please use EcoProcessor instead"
14
+ EcoProcessor.call(*args)
15
+ end
16
+ end
6
17
  end
@@ -2,5 +2,16 @@ require 'sprockets/ejs_processor'
2
2
 
3
3
  module Sprockets
4
4
  # Deprecated
5
- EjsTemplate = EjsProcessor
5
+ module EjsTemplate
6
+ VERSION = EjsProcessor::VERSION
7
+
8
+ def self.cache_key
9
+ EjsProcessor.cache_key
10
+ end
11
+
12
+ def self.call(*args)
13
+ Deprecation.new.warn "EjsTemplate is deprecated please use EjsProcessor instead"
14
+ EjsProcessor.call(*args)
15
+ end
16
+ end
6
17
  end
@@ -51,6 +51,17 @@ module Sprockets
51
51
  # environment.register_engine '.coffee', CoffeeScriptProcessor
52
52
  #
53
53
  def register_engine(ext, klass, options = {})
54
+ unless options[:silence_deprecation]
55
+ msg = <<-MSG
56
+ Sprockets method `register_engine` is deprecated.
57
+ Please register a mime type using `register_mime_type` then
58
+ use `register_compressor` or `register_transformer`.
59
+ https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
60
+ MSG
61
+
62
+ Deprecation.new([caller.first]).warn(msg)
63
+ end
64
+
54
65
  ext = Sprockets::Utils.normalize_extension(ext)
55
66
 
56
67
  self.computed_config = {}
@@ -2,5 +2,10 @@ require 'sprockets/erb_processor'
2
2
 
3
3
  module Sprockets
4
4
  # Deprecated
5
- ERBTemplate = ERBProcessor
5
+ class ERBTemplate < ERBProcessor
6
+ def call(*args)
7
+ Deprecation.new.warn "ERBTemplate is deprecated please use ERBProcessor instead"
8
+ super
9
+ end
10
+ end
6
11
  end
@@ -231,14 +231,24 @@ module Sprockets
231
231
  compute_transformers!
232
232
  end
233
233
 
234
+ def deprecate_legacy_processor_interface(interface)
235
+ msg = "You are using the a deprecated processor interface #{ interface.inspect }.\n" +
236
+ "Please update your processor interface:\n" +
237
+ "https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors\n"
238
+
239
+ Deprecation.new([caller[3]]).warn msg
240
+ end
241
+
234
242
  def wrap_processor(klass, proc)
235
243
  if !proc
236
244
  if klass.respond_to?(:call)
237
245
  klass
238
246
  else
247
+ deprecate_legacy_processor_interface(klass)
239
248
  LegacyTiltProcessor.new(klass)
240
249
  end
241
250
  elsif proc.respond_to?(:arity) && proc.arity == 2
251
+ deprecate_legacy_processor_interface(proc)
242
252
  LegacyProcProcessor.new(klass.to_s, proc)
243
253
  else
244
254
  proc
@@ -25,5 +25,10 @@ module Sprockets
25
25
  end
26
26
 
27
27
  # Deprecated: Use Sprockets::SassProcessor::CacheStore instead.
28
- SassCacheStore = SassProcessor::CacheStore
28
+ class SassCacheStore < SassProcessor::CacheStore
29
+ def initialize(*args)
30
+ Deprecation.new.warn "SassCacheStore is deprecated please use SassProcessor::CacheStore instead"
31
+ super
32
+ end
33
+ end
29
34
  end
@@ -2,6 +2,18 @@ require 'sprockets/sass_processor'
2
2
 
3
3
  module Sprockets
4
4
  # Deprecated
5
- SassTemplate = SassProcessor
6
- ScssTemplate = ScssProcessor
5
+ class SassTemplate < SassProcessor
6
+ def self.call(*args)
7
+ Deprecation.new.warn "SassTemplate is deprecated please use SassProcessor instead"
8
+ super
9
+ end
10
+ end
11
+
12
+ # Deprecated
13
+ class ScssTemplate < ScssProcessor
14
+ def self.call(*args)
15
+ Deprecation.new.warn "ScssTemplate is deprecated please use ScssProcessor instead"
16
+ super
17
+ end
18
+ end
7
19
  end
@@ -1,3 +1,3 @@
1
1
  module Sprockets
2
- VERSION = "3.6.3"
2
+ VERSION = "3.7.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.6.3
4
+ version: 3.7.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: 2016-07-01 00:00:00.000000000 Z
12
+ date: 2016-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -267,6 +267,7 @@ files:
267
267
  - lib/sprockets/configuration.rb
268
268
  - lib/sprockets/context.rb
269
269
  - lib/sprockets/dependencies.rb
270
+ - lib/sprockets/deprecation.rb
270
271
  - lib/sprockets/digest_utils.rb
271
272
  - lib/sprockets/directive_processor.rb
272
273
  - lib/sprockets/eco_processor.rb