sprockets 3.7.3 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -259
  3. data/{LICENSE → MIT-LICENSE} +2 -2
  4. data/README.md +527 -320
  5. data/bin/sprockets +11 -7
  6. data/lib/rake/sprocketstask.rb +9 -4
  7. data/lib/sprockets/add_source_map_comment_to_asset_processor.rb +60 -0
  8. data/lib/sprockets/asset.rb +39 -27
  9. data/lib/sprockets/autoload/babel.rb +8 -0
  10. data/lib/sprockets/autoload/closure.rb +1 -0
  11. data/lib/sprockets/autoload/coffee_script.rb +1 -0
  12. data/lib/sprockets/autoload/eco.rb +1 -0
  13. data/lib/sprockets/autoload/ejs.rb +1 -0
  14. data/lib/sprockets/autoload/jsminc.rb +8 -0
  15. data/lib/sprockets/autoload/sass.rb +1 -0
  16. data/lib/sprockets/autoload/sassc.rb +8 -0
  17. data/lib/sprockets/autoload/uglifier.rb +1 -0
  18. data/lib/sprockets/autoload/yui.rb +1 -0
  19. data/lib/sprockets/autoload/zopfli.rb +7 -0
  20. data/lib/sprockets/autoload.rb +5 -0
  21. data/lib/sprockets/babel_processor.rb +66 -0
  22. data/lib/sprockets/base.rb +49 -12
  23. data/lib/sprockets/bower.rb +6 -3
  24. data/lib/sprockets/bundle.rb +41 -5
  25. data/lib/sprockets/cache/file_store.rb +25 -3
  26. data/lib/sprockets/cache/memory_store.rb +28 -10
  27. data/lib/sprockets/cache/null_store.rb +8 -0
  28. data/lib/sprockets/cache.rb +37 -2
  29. data/lib/sprockets/cached_environment.rb +15 -20
  30. data/lib/sprockets/closure_compressor.rb +1 -0
  31. data/lib/sprockets/coffee_script_processor.rb +19 -5
  32. data/lib/sprockets/compressing.rb +43 -3
  33. data/lib/sprockets/configuration.rb +5 -9
  34. data/lib/sprockets/context.rb +99 -25
  35. data/lib/sprockets/dependencies.rb +2 -1
  36. data/lib/sprockets/digest_utils.rb +35 -18
  37. data/lib/sprockets/directive_processor.rb +64 -38
  38. data/lib/sprockets/eco_processor.rb +2 -1
  39. data/lib/sprockets/ejs_processor.rb +2 -1
  40. data/lib/sprockets/encoding_utils.rb +2 -2
  41. data/lib/sprockets/environment.rb +9 -4
  42. data/lib/sprockets/erb_processor.rb +33 -32
  43. data/lib/sprockets/errors.rb +1 -0
  44. data/lib/sprockets/exporters/base.rb +71 -0
  45. data/lib/sprockets/exporters/file_exporter.rb +24 -0
  46. data/lib/sprockets/exporters/zlib_exporter.rb +33 -0
  47. data/lib/sprockets/exporters/zopfli_exporter.rb +14 -0
  48. data/lib/sprockets/exporting.rb +73 -0
  49. data/lib/sprockets/file_reader.rb +1 -0
  50. data/lib/sprockets/http_utils.rb +25 -7
  51. data/lib/sprockets/jsminc_compressor.rb +32 -0
  52. data/lib/sprockets/jst_processor.rb +11 -10
  53. data/lib/sprockets/loader.rb +91 -69
  54. data/lib/sprockets/manifest.rb +67 -64
  55. data/lib/sprockets/manifest_utils.rb +9 -6
  56. data/lib/sprockets/mime.rb +8 -62
  57. data/lib/sprockets/npm.rb +52 -0
  58. data/lib/sprockets/path_dependency_utils.rb +3 -11
  59. data/lib/sprockets/path_digest_utils.rb +2 -1
  60. data/lib/sprockets/path_utils.rb +88 -8
  61. data/lib/sprockets/paths.rb +1 -0
  62. data/lib/sprockets/preprocessors/default_source_map.rb +49 -0
  63. data/lib/sprockets/processing.rb +32 -62
  64. data/lib/sprockets/processor_utils.rb +28 -38
  65. data/lib/sprockets/resolve.rb +177 -93
  66. data/lib/sprockets/sass_cache_store.rb +2 -6
  67. data/lib/sprockets/sass_compressor.rb +13 -1
  68. data/lib/sprockets/sass_functions.rb +1 -0
  69. data/lib/sprockets/sass_importer.rb +1 -0
  70. data/lib/sprockets/sass_processor.rb +31 -10
  71. data/lib/sprockets/sassc_compressor.rb +56 -0
  72. data/lib/sprockets/sassc_processor.rb +297 -0
  73. data/lib/sprockets/server.rb +63 -40
  74. data/lib/sprockets/source_map_processor.rb +66 -0
  75. data/lib/sprockets/source_map_utils.rb +483 -0
  76. data/lib/sprockets/transformers.rb +63 -35
  77. data/lib/sprockets/uglifier_compressor.rb +21 -11
  78. data/lib/sprockets/unloaded_asset.rb +13 -11
  79. data/lib/sprockets/uri_tar.rb +1 -0
  80. data/lib/sprockets/uri_utils.rb +19 -16
  81. data/lib/sprockets/utils/gzip.rb +46 -14
  82. data/lib/sprockets/utils.rb +64 -90
  83. data/lib/sprockets/version.rb +2 -1
  84. data/lib/sprockets/yui_compressor.rb +1 -0
  85. data/lib/sprockets.rb +102 -39
  86. metadata +148 -45
  87. data/lib/sprockets/coffee_script_template.rb +0 -17
  88. data/lib/sprockets/deprecation.rb +0 -90
  89. data/lib/sprockets/eco_template.rb +0 -17
  90. data/lib/sprockets/ejs_template.rb +0 -17
  91. data/lib/sprockets/engines.rb +0 -92
  92. data/lib/sprockets/erb_template.rb +0 -11
  93. data/lib/sprockets/legacy.rb +0 -330
  94. data/lib/sprockets/legacy_proc_processor.rb +0 -35
  95. data/lib/sprockets/legacy_tilt_processor.rb +0 -29
  96. data/lib/sprockets/sass_template.rb +0 -19
@@ -1,90 +0,0 @@
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
@@ -1,17 +0,0 @@
1
- require 'sprockets/eco_processor'
2
-
3
- module Sprockets
4
- # Deprecated
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
17
- end
@@ -1,17 +0,0 @@
1
- require 'sprockets/ejs_processor'
2
-
3
- module Sprockets
4
- # Deprecated
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
17
- end
@@ -1,92 +0,0 @@
1
- require 'sprockets/legacy_tilt_processor'
2
- require 'sprockets/utils'
3
-
4
- module Sprockets
5
- # `Engines` provides a global and `Environment` instance registry.
6
- #
7
- # An engine is a type of processor that is bound to a filename
8
- # extension. `application.js.coffee` indicates that the
9
- # `CoffeeScriptProcessor` engine will be ran on the file.
10
- #
11
- # Extensions can be stacked and will be evaulated from right to
12
- # left. `application.js.coffee.erb` will first run `ERBProcessor`
13
- # then `CoffeeScriptProcessor`.
14
- #
15
- # All `Engine`s must follow the `Template` interface. It is
16
- # recommended to subclass `Template`.
17
- #
18
- # Its recommended that you register engine changes on your local
19
- # `Environment` instance.
20
- #
21
- # environment.register_engine '.foo', FooProcessor
22
- #
23
- # The global registry is exposed for plugins to register themselves.
24
- #
25
- # Sprockets.register_engine '.sass', SassProcessor
26
- #
27
- module Engines
28
- include Utils
29
-
30
- # Returns a `Hash` of `Engine`s registered on the `Environment`.
31
- # If an `ext` argument is supplied, the `Engine` associated with
32
- # that extension will be returned.
33
- #
34
- # environment.engines
35
- # # => {".coffee" => CoffeeScriptProcessor, ".sass" => SassProcessor, ...}
36
- #
37
- def engines
38
- config[:engines]
39
- end
40
-
41
- # Internal: Returns a `Hash` of engine extensions to mime types.
42
- #
43
- # # => { '.coffee' => 'application/javascript' }
44
- def engine_mime_types
45
- config[:engine_mime_types]
46
- end
47
-
48
- # Registers a new Engine `klass` for `ext`. If the `ext` already
49
- # has an engine registered, it will be overridden.
50
- #
51
- # environment.register_engine '.coffee', CoffeeScriptProcessor
52
- #
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
-
65
- ext = Sprockets::Utils.normalize_extension(ext)
66
-
67
- self.computed_config = {}
68
-
69
- if klass.respond_to?(:call)
70
- processor = klass
71
- self.config = hash_reassoc(config, :engines) do |engines|
72
- engines.merge(ext => klass)
73
- end
74
- if options[:mime_type]
75
- self.config = hash_reassoc(config, :engine_mime_types) do |mime_types|
76
- mime_types.merge(ext.to_s => options[:mime_type])
77
- end
78
- end
79
- else
80
- processor = LegacyTiltProcessor.new(klass)
81
- self.config = hash_reassoc(config, :engines) do |engines|
82
- engines.merge(ext => processor)
83
- end
84
- if klass.respond_to?(:default_mime_type) && klass.default_mime_type
85
- self.config = hash_reassoc(config, :engine_mime_types) do |mime_types|
86
- mime_types.merge(ext.to_s => klass.default_mime_type)
87
- end
88
- end
89
- end
90
- end
91
- end
92
- end
@@ -1,11 +0,0 @@
1
- require 'sprockets/erb_processor'
2
-
3
- module Sprockets
4
- # Deprecated
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
11
- end
@@ -1,330 +0,0 @@
1
- require 'pathname'
2
- require 'sprockets/asset'
3
- require 'sprockets/base'
4
- require 'sprockets/cached_environment'
5
- require 'sprockets/context'
6
- require 'sprockets/manifest'
7
- require 'sprockets/resolve'
8
-
9
- module Sprockets
10
- autoload :CoffeeScriptTemplate, 'sprockets/coffee_script_template'
11
- autoload :EcoTemplate, 'sprockets/eco_template'
12
- autoload :EjsTemplate, 'sprockets/ejs_template'
13
- autoload :ERBTemplate, 'sprockets/erb_template'
14
- autoload :SassTemplate, 'sprockets/sass_template'
15
- autoload :ScssTemplate, 'sprockets/sass_template'
16
-
17
- # Deprecated
18
- Index = CachedEnvironment
19
-
20
- class Base
21
- include Resolve
22
-
23
- # Deprecated: Change default return type of resolve() to return 2.x
24
- # compatible plain filename String. 4.x will always return an Asset URI
25
- # and a set of file system dependencies that had to be read to compute the
26
- # result.
27
- #
28
- # 2.x
29
- #
30
- # resolve("foo.js")
31
- # # => "/path/to/app/javascripts/foo.js"
32
- #
33
- # 3.x
34
- #
35
- # resolve("foo.js")
36
- # # => "/path/to/app/javascripts/foo.js"
37
- #
38
- # resolve("foo.js", compat: true)
39
- # # => "/path/to/app/javascripts/foo.js"
40
- #
41
- # resolve("foo.js", compat: false)
42
- # # => [
43
- # # "file:///path/to/app/javascripts/foo.js?type=application/javascript"
44
- # # #<Set: {"file-digest:/path/to/app/javascripts/foo.js"}>
45
- # # ]
46
- #
47
- # 4.x
48
- #
49
- # resolve("foo.js")
50
- # # => [
51
- # # "file:///path/to/app/javascripts/foo.js?type=application/javascript"
52
- # # #<Set: {"file-digest:/path/to/app/javascripts/foo.js"}>
53
- # # ]
54
- #
55
- def resolve_with_compat(path, options = {})
56
- options = options.dup
57
- if options.delete(:compat) { true }
58
- uri, _ = resolve_without_compat(path, options)
59
- if uri
60
- path, _ = parse_asset_uri(uri)
61
- path
62
- else
63
- nil
64
- end
65
- else
66
- resolve_without_compat(path, options)
67
- end
68
- end
69
- alias_method :resolve_without_compat, :resolve
70
- alias_method :resolve, :resolve_with_compat
71
-
72
- # Deprecated: Iterate over all logical paths with a matcher.
73
- #
74
- # Remove from 4.x.
75
- #
76
- # args - List of matcher objects.
77
- #
78
- # Returns Enumerator if no block is given.
79
- def each_logical_path(*args, &block)
80
- return to_enum(__method__, *args) unless block_given?
81
-
82
- filters = args.flatten.map { |arg| Manifest.compile_match_filter(arg) }
83
- logical_paths.each do |a, b|
84
- if filters.any? { |f| f.call(a, b) }
85
- if block.arity == 2
86
- yield a, b
87
- else
88
- yield a
89
- end
90
- end
91
- end
92
-
93
- nil
94
- end
95
-
96
- # Deprecated: Enumerate over all logical paths in the environment.
97
- #
98
- # Returns an Enumerator of [logical_path, filename].
99
- def logical_paths
100
- return to_enum(__method__) unless block_given?
101
-
102
- seen = Set.new
103
-
104
- paths.each do |load_path|
105
- stat_tree(load_path).each do |filename, stat|
106
- next unless stat.file?
107
-
108
- path = split_subpath(load_path, filename)
109
- path, mime_type, _, _ = parse_path_extnames(path)
110
- path = normalize_logical_path(path)
111
- path += mime_types[mime_type][:extensions].first if mime_type
112
-
113
- if !seen.include?(path)
114
- yield path, filename
115
- seen << path
116
- end
117
- end
118
- end
119
-
120
- nil
121
- end
122
-
123
- def cache_get(key)
124
- cache.get(key)
125
- end
126
-
127
- def cache_set(key, value)
128
- cache.set(key, value)
129
- end
130
-
131
- def normalize_logical_path(path)
132
- dirname, basename = File.split(path)
133
- path = dirname if basename == 'index'
134
- path
135
- end
136
-
137
- private
138
- # Deprecated: Seriously.
139
- def matches_filter(filters, logical_path, filename)
140
- return true if filters.empty?
141
-
142
- filters.any? do |filter|
143
- if filter.is_a?(Regexp)
144
- filter.match(logical_path)
145
- elsif filter.respond_to?(:call)
146
- if filter.arity == 1
147
- filter.call(logical_path)
148
- else
149
- filter.call(logical_path, filename.to_s)
150
- end
151
- else
152
- File.fnmatch(filter.to_s, logical_path)
153
- end
154
- end
155
- end
156
-
157
- # URI.unescape is deprecated on 1.9. We need to use URI::Parser
158
- # if its available.
159
- if defined? URI::DEFAULT_PARSER
160
- def unescape(str)
161
- str = URI::DEFAULT_PARSER.unescape(str)
162
- str.force_encoding(Encoding.default_internal) if Encoding.default_internal
163
- str
164
- end
165
- else
166
- def unescape(str)
167
- URI.unescape(str)
168
- end
169
- end
170
- end
171
-
172
- class Asset
173
- # Deprecated: Use #filename instead.
174
- #
175
- # Returns Pathname.
176
- def pathname
177
- @pathname ||= Pathname.new(filename)
178
- end
179
-
180
- # Deprecated: Expand asset into an `Array` of parts.
181
- #
182
- # Appending all of an assets body parts together should give you
183
- # the asset's contents as a whole.
184
- #
185
- # This allows you to link to individual files for debugging
186
- # purposes.
187
- #
188
- # Use Asset#included instead. Keeping a full copy of the bundle's processed
189
- # assets in memory (and in cache) is expensive and redundant. The common use
190
- # case is to relink to the assets anyway.
191
- #
192
- # Returns Array of Assets.
193
- def to_a
194
- if metadata[:included]
195
- metadata[:included].map { |uri| @environment.load(uri) }
196
- else
197
- [self]
198
- end
199
- end
200
-
201
- # Deprecated: Get all required Assets.
202
- #
203
- # See Asset#to_a
204
- #
205
- # Returns Array of Assets.
206
- def dependencies
207
- to_a.reject { |a| a.filename.eql?(self.filename) }
208
- end
209
-
210
- # Deprecated: Returns Time of the last time the source was modified.
211
- #
212
- # Time resolution is normalized to the nearest second.
213
- #
214
- # Returns Time.
215
- def mtime
216
- Time.at(@mtime)
217
- end
218
- end
219
-
220
- class Context
221
- # Deprecated: Change default return type of resolve() to return 2.x
222
- # compatible plain filename String. 4.x will always return an Asset URI.
223
- #
224
- # 2.x
225
- #
226
- # resolve("foo.js")
227
- # # => "/path/to/app/javascripts/foo.js"
228
- #
229
- # 3.x
230
- #
231
- # resolve("foo.js")
232
- # # => "/path/to/app/javascripts/foo.js"
233
- #
234
- # resolve("foo.js", compat: true)
235
- # # => "/path/to/app/javascripts/foo.js"
236
- #
237
- # resolve("foo.js", compat: false)
238
- # # => "file:///path/to/app/javascripts/foo.js?type=application/javascript"
239
- #
240
- # 4.x
241
- #
242
- # resolve("foo.js")
243
- # # => "file:///path/to/app/javascripts/foo.js?type=application/javascript"
244
- #
245
- def resolve_with_compat(path, options = {})
246
- options = options.dup
247
-
248
- # Support old :content_type option, prefer :accept going forward
249
- if type = options.delete(:content_type)
250
- type = self.content_type if type == :self
251
- options[:accept] ||= type
252
- end
253
-
254
- if options.delete(:compat) { true }
255
- uri = resolve_without_compat(path, options)
256
- path, _ = environment.parse_asset_uri(uri)
257
- path
258
- else
259
- resolve_without_compat(path, options)
260
- end
261
- end
262
- alias_method :resolve_without_compat, :resolve
263
- alias_method :resolve, :resolve_with_compat
264
- end
265
-
266
- class Manifest
267
- # Deprecated: Compile logical path matching filter into a proc that can be
268
- # passed to logical_paths.select(&proc).
269
- #
270
- # compile_match_filter(proc { |logical_path|
271
- # File.extname(logical_path) == '.js'
272
- # })
273
- #
274
- # compile_match_filter(/application.js/)
275
- #
276
- # compile_match_filter("foo/*.js")
277
- #
278
- # Returns a Proc or raise a TypeError.
279
- def self.compile_match_filter(filter)
280
- # If the filter is already a proc, great nothing to do.
281
- if filter.respond_to?(:call)
282
- filter
283
- # If the filter is a regexp, wrap it in a proc that tests it against the
284
- # logical path.
285
- elsif filter.is_a?(Regexp)
286
- proc { |logical_path| filter.match(logical_path) }
287
- elsif filter.is_a?(String)
288
- # If its an absolute path, detect the matching full filename
289
- if PathUtils.absolute_path?(filter)
290
- proc { |logical_path, filename| filename == filter.to_s }
291
- else
292
- # Otherwise do an fnmatch against the logical path.
293
- proc { |logical_path| File.fnmatch(filter.to_s, logical_path) }
294
- end
295
- else
296
- raise TypeError, "unknown filter type: #{filter.inspect}"
297
- end
298
- end
299
-
300
- def self.simple_logical_path?(str)
301
- str.is_a?(String) &&
302
- !PathUtils.absolute_path?(str) &&
303
- str !~ /\*|\*\*|\?|\[|\]|\{|\}/
304
- end
305
-
306
- def self.compute_alias_logical_path(path)
307
- dirname, basename = File.split(path)
308
- extname = File.extname(basename)
309
- if File.basename(basename, extname) == 'index'
310
- "#{dirname}#{extname}"
311
- else
312
- nil
313
- end
314
- end
315
-
316
- # Deprecated: Filter logical paths in environment. Useful for selecting what
317
- # files you want to compile.
318
- #
319
- # Returns an Enumerator.
320
- def filter_logical_paths(*args)
321
- filters = args.flatten.map { |arg| self.class.compile_match_filter(arg) }
322
- environment.cached.logical_paths.select do |a, b|
323
- filters.any? { |f| f.call(a, b) }
324
- end
325
- end
326
-
327
- # Deprecated alias.
328
- alias_method :find_logical_paths, :filter_logical_paths
329
- end
330
- end
@@ -1,35 +0,0 @@
1
- require 'delegate'
2
-
3
- module Sprockets
4
- # Deprecated: Wraps legacy process Procs with new processor call signature.
5
- #
6
- # Will be removed in Sprockets 4.x.
7
- #
8
- # LegacyProcProcessor.new(:compress,
9
- # proc { |context, data| data.gsub(...) })
10
- #
11
- class LegacyProcProcessor < Delegator
12
- def initialize(name, proc)
13
- @name = name
14
- @proc = proc
15
- end
16
-
17
- def __getobj__
18
- @proc
19
- end
20
-
21
- def name
22
- "Sprockets::LegacyProcProcessor (#{@name})"
23
- end
24
-
25
- def to_s
26
- name
27
- end
28
-
29
- def call(input)
30
- context = input[:environment].context_class.new(input)
31
- data = @proc.call(context, input[:data])
32
- context.metadata.merge(data: data.to_str)
33
- end
34
- end
35
- end
@@ -1,29 +0,0 @@
1
- require 'delegate'
2
-
3
- module Sprockets
4
- # Deprecated: Wraps legacy engine and process Tilt templates with new
5
- # processor call signature.
6
- #
7
- # Will be removed in Sprockets 4.x.
8
- #
9
- # LegacyTiltProcessor.new(Tilt::CoffeeScriptProcessor)
10
- #
11
- class LegacyTiltProcessor < Delegator
12
- def initialize(klass)
13
- @klass = klass
14
- end
15
-
16
- def __getobj__
17
- @klass
18
- end
19
-
20
- def call(input)
21
- filename = input[:filename]
22
- data = input[:data]
23
- context = input[:environment].context_class.new(input)
24
-
25
- data = @klass.new(filename) { data }.render(context, {})
26
- context.metadata.merge(data: data.to_str)
27
- end
28
- end
29
- end
@@ -1,19 +0,0 @@
1
- require 'sprockets/sass_processor'
2
-
3
- module Sprockets
4
- # Deprecated
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
19
- end