sprockets 2.2.3 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +68 -0
  3. data/README.md +482 -255
  4. data/bin/sprockets +20 -7
  5. data/lib/rake/sprocketstask.rb +28 -15
  6. data/lib/sprockets/add_source_map_comment_to_asset_processor.rb +60 -0
  7. data/lib/sprockets/asset.rb +142 -207
  8. data/lib/sprockets/autoload/babel.rb +8 -0
  9. data/lib/sprockets/autoload/closure.rb +8 -0
  10. data/lib/sprockets/autoload/coffee_script.rb +8 -0
  11. data/lib/sprockets/autoload/eco.rb +8 -0
  12. data/lib/sprockets/autoload/ejs.rb +8 -0
  13. data/lib/sprockets/autoload/jsminc.rb +8 -0
  14. data/lib/sprockets/autoload/sass.rb +8 -0
  15. data/lib/sprockets/autoload/sassc.rb +8 -0
  16. data/lib/sprockets/autoload/uglifier.rb +8 -0
  17. data/lib/sprockets/autoload/yui.rb +8 -0
  18. data/lib/sprockets/autoload/zopfli.rb +7 -0
  19. data/lib/sprockets/autoload.rb +16 -0
  20. data/lib/sprockets/babel_processor.rb +66 -0
  21. data/lib/sprockets/base.rb +89 -249
  22. data/lib/sprockets/bower.rb +61 -0
  23. data/lib/sprockets/bundle.rb +105 -0
  24. data/lib/sprockets/cache/file_store.rb +190 -14
  25. data/lib/sprockets/cache/memory_store.rb +75 -0
  26. data/lib/sprockets/cache/null_store.rb +54 -0
  27. data/lib/sprockets/cache.rb +271 -0
  28. data/lib/sprockets/cached_environment.rb +64 -0
  29. data/lib/sprockets/closure_compressor.rb +48 -0
  30. data/lib/sprockets/coffee_script_processor.rb +39 -0
  31. data/lib/sprockets/compressing.rb +134 -0
  32. data/lib/sprockets/configuration.rb +79 -0
  33. data/lib/sprockets/context.rb +204 -135
  34. data/lib/sprockets/dependencies.rb +74 -0
  35. data/lib/sprockets/digest_utils.rb +200 -0
  36. data/lib/sprockets/directive_processor.rb +224 -216
  37. data/lib/sprockets/eco_processor.rb +33 -0
  38. data/lib/sprockets/ejs_processor.rb +32 -0
  39. data/lib/sprockets/encoding_utils.rb +262 -0
  40. data/lib/sprockets/environment.rb +23 -68
  41. data/lib/sprockets/erb_processor.rb +37 -0
  42. data/lib/sprockets/errors.rb +6 -13
  43. data/lib/sprockets/exporters/base.rb +72 -0
  44. data/lib/sprockets/exporters/file_exporter.rb +24 -0
  45. data/lib/sprockets/exporters/zlib_exporter.rb +33 -0
  46. data/lib/sprockets/exporters/zopfli_exporter.rb +14 -0
  47. data/lib/sprockets/exporting.rb +73 -0
  48. data/lib/sprockets/file_reader.rb +16 -0
  49. data/lib/sprockets/http_utils.rb +135 -0
  50. data/lib/sprockets/jsminc_compressor.rb +32 -0
  51. data/lib/sprockets/jst_processor.rb +36 -19
  52. data/lib/sprockets/loader.rb +343 -0
  53. data/lib/sprockets/manifest.rb +231 -96
  54. data/lib/sprockets/manifest_utils.rb +48 -0
  55. data/lib/sprockets/mime.rb +80 -32
  56. data/lib/sprockets/npm.rb +52 -0
  57. data/lib/sprockets/path_dependency_utils.rb +77 -0
  58. data/lib/sprockets/path_digest_utils.rb +48 -0
  59. data/lib/sprockets/path_utils.rb +367 -0
  60. data/lib/sprockets/paths.rb +82 -0
  61. data/lib/sprockets/preprocessors/default_source_map.rb +49 -0
  62. data/lib/sprockets/processing.rb +140 -192
  63. data/lib/sprockets/processor_utils.rb +169 -0
  64. data/lib/sprockets/resolve.rb +295 -0
  65. data/lib/sprockets/sass_cache_store.rb +30 -0
  66. data/lib/sprockets/sass_compressor.rb +63 -0
  67. data/lib/sprockets/sass_functions.rb +3 -0
  68. data/lib/sprockets/sass_importer.rb +3 -0
  69. data/lib/sprockets/sass_processor.rb +313 -0
  70. data/lib/sprockets/sassc_compressor.rb +56 -0
  71. data/lib/sprockets/sassc_processor.rb +297 -0
  72. data/lib/sprockets/server.rb +138 -90
  73. data/lib/sprockets/source_map_processor.rb +66 -0
  74. data/lib/sprockets/source_map_utils.rb +483 -0
  75. data/lib/sprockets/transformers.rb +173 -0
  76. data/lib/sprockets/uglifier_compressor.rb +66 -0
  77. data/lib/sprockets/unloaded_asset.rb +139 -0
  78. data/lib/sprockets/uri_tar.rb +99 -0
  79. data/lib/sprockets/uri_utils.rb +191 -0
  80. data/lib/sprockets/utils/gzip.rb +99 -0
  81. data/lib/sprockets/utils.rb +186 -53
  82. data/lib/sprockets/version.rb +2 -1
  83. data/lib/sprockets/yui_compressor.rb +56 -0
  84. data/lib/sprockets.rb +217 -52
  85. metadata +250 -59
  86. data/LICENSE +0 -21
  87. data/lib/sprockets/asset_attributes.rb +0 -126
  88. data/lib/sprockets/bundled_asset.rb +0 -79
  89. data/lib/sprockets/caching.rb +0 -96
  90. data/lib/sprockets/charset_normalizer.rb +0 -41
  91. data/lib/sprockets/eco_template.rb +0 -38
  92. data/lib/sprockets/ejs_template.rb +0 -37
  93. data/lib/sprockets/engines.rb +0 -74
  94. data/lib/sprockets/index.rb +0 -99
  95. data/lib/sprockets/processed_asset.rb +0 -152
  96. data/lib/sprockets/processor.rb +0 -32
  97. data/lib/sprockets/safety_colons.rb +0 -28
  98. data/lib/sprockets/static_asset.rb +0 -57
  99. data/lib/sprockets/trail.rb +0 -90
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: 2.2.3
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -9,24 +9,30 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-28 00:00:00.000000000 Z
12
+ date: 2019-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: hike
15
+ name: rack
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">"
19
+ - !ruby/object:Gem::Version
20
+ version: '1'
21
+ - - "<"
19
22
  - !ruby/object:Gem::Version
20
- version: '1.2'
23
+ version: '3'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">"
29
+ - !ruby/object:Gem::Version
30
+ version: '1'
31
+ - - "<"
26
32
  - !ruby/object:Gem::Version
27
- version: '1.2'
33
+ version: '3'
28
34
  - !ruby/object:Gem::Dependency
29
- name: multi_json
35
+ name: concurrent-ruby
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
38
  - - "~>"
@@ -40,67 +46,75 @@ dependencies:
40
46
  - !ruby/object:Gem::Version
41
47
  version: '1.0'
42
48
  - !ruby/object:Gem::Dependency
43
- name: rack
49
+ name: m
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: babel-transpiler
44
64
  requirement: !ruby/object:Gem::Requirement
45
65
  requirements:
46
66
  - - "~>"
47
67
  - !ruby/object:Gem::Version
48
- version: '1.0'
49
- type: :runtime
68
+ version: '0.6'
69
+ type: :development
50
70
  prerelease: false
51
71
  version_requirements: !ruby/object:Gem::Requirement
52
72
  requirements:
53
73
  - - "~>"
54
74
  - !ruby/object:Gem::Version
55
- version: '1.0'
75
+ version: '0.6'
56
76
  - !ruby/object:Gem::Dependency
57
- name: tilt
77
+ name: closure-compiler
58
78
  requirement: !ruby/object:Gem::Requirement
59
79
  requirements:
60
80
  - - "~>"
61
81
  - !ruby/object:Gem::Version
62
82
  version: '1.1'
63
- - - "!="
64
- - !ruby/object:Gem::Version
65
- version: 1.3.0
66
- type: :runtime
83
+ type: :development
67
84
  prerelease: false
68
85
  version_requirements: !ruby/object:Gem::Requirement
69
86
  requirements:
70
87
  - - "~>"
71
88
  - !ruby/object:Gem::Version
72
89
  version: '1.1'
73
- - - "!="
74
- - !ruby/object:Gem::Version
75
- version: 1.3.0
76
90
  - !ruby/object:Gem::Dependency
77
- name: coffee-script
91
+ name: coffee-script-source
78
92
  requirement: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '2.0'
96
+ version: '1.6'
83
97
  type: :development
84
98
  prerelease: false
85
99
  version_requirements: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '2.0'
103
+ version: '1.6'
90
104
  - !ruby/object:Gem::Dependency
91
- name: coffee-script-source
105
+ name: coffee-script
92
106
  requirement: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 1.2.0
110
+ version: '2.2'
97
111
  type: :development
98
112
  prerelease: false
99
113
  version_requirements: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 1.2.0
117
+ version: '2.2'
104
118
  - !ruby/object:Gem::Dependency
105
119
  name: eco
106
120
  requirement: !ruby/object:Gem::Requirement
@@ -135,58 +149,184 @@ dependencies:
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '1.0'
152
+ version: '2.0'
139
153
  type: :development
140
154
  prerelease: false
141
155
  version_requirements: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: '1.0'
159
+ version: '2.0'
146
160
  - !ruby/object:Gem::Dependency
147
- name: json
161
+ name: jsminc
148
162
  requirement: !ruby/object:Gem::Requirement
149
163
  requirements:
150
- - - ">="
164
+ - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: '0'
166
+ version: '1.1'
153
167
  type: :development
154
168
  prerelease: false
155
169
  version_requirements: !ruby/object:Gem::Requirement
156
170
  requirements:
157
- - - ">="
171
+ - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: '0'
173
+ version: '1.1'
174
+ - !ruby/object:Gem::Dependency
175
+ name: timecop
176
+ requirement: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.9.1
181
+ type: :development
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.9.1
188
+ - !ruby/object:Gem::Dependency
189
+ name: minitest
190
+ requirement: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '5.0'
195
+ type: :development
196
+ prerelease: false
197
+ version_requirements: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '5.0'
202
+ - !ruby/object:Gem::Dependency
203
+ name: nokogiri
204
+ requirement: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '1.3'
209
+ type: :development
210
+ prerelease: false
211
+ version_requirements: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '1.3'
160
216
  - !ruby/object:Gem::Dependency
161
217
  name: rack-test
162
218
  requirement: !ruby/object:Gem::Requirement
163
219
  requirements:
164
- - - ">="
220
+ - - "~>"
165
221
  - !ruby/object:Gem::Version
166
- version: '0'
222
+ version: '0.6'
167
223
  type: :development
168
224
  prerelease: false
169
225
  version_requirements: !ruby/object:Gem::Requirement
170
226
  requirements:
171
- - - ">="
227
+ - - "~>"
172
228
  - !ruby/object:Gem::Version
173
- version: '0'
229
+ version: '0.6'
174
230
  - !ruby/object:Gem::Dependency
175
231
  name: rake
232
+ requirement: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '12.0'
237
+ type: :development
238
+ prerelease: false
239
+ version_requirements: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '12.0'
244
+ - !ruby/object:Gem::Dependency
245
+ name: sass
246
+ requirement: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '3.4'
251
+ type: :development
252
+ prerelease: false
253
+ version_requirements: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '3.4'
258
+ - !ruby/object:Gem::Dependency
259
+ name: sassc
260
+ requirement: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '2.0'
265
+ type: :development
266
+ prerelease: false
267
+ version_requirements: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '2.0'
272
+ - !ruby/object:Gem::Dependency
273
+ name: uglifier
176
274
  requirement: !ruby/object:Gem::Requirement
177
275
  requirements:
178
276
  - - ">="
179
277
  - !ruby/object:Gem::Version
180
- version: '0'
278
+ version: '2.3'
181
279
  type: :development
182
280
  prerelease: false
183
281
  version_requirements: !ruby/object:Gem::Requirement
184
282
  requirements:
185
283
  - - ">="
186
284
  - !ruby/object:Gem::Version
187
- version: '0'
285
+ version: '2.3'
286
+ - !ruby/object:Gem::Dependency
287
+ name: yui-compressor
288
+ requirement: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '0.12'
293
+ type: :development
294
+ prerelease: false
295
+ version_requirements: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: '0.12'
300
+ - !ruby/object:Gem::Dependency
301
+ name: zopfli
302
+ requirement: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: 0.0.4
307
+ type: :development
308
+ prerelease: false
309
+ version_requirements: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: 0.0.4
314
+ - !ruby/object:Gem::Dependency
315
+ name: rubocop-performance
316
+ requirement: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: '1.3'
321
+ type: :development
322
+ prerelease: false
323
+ version_requirements: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - "~>"
326
+ - !ruby/object:Gem::Version
327
+ version: '1.3'
188
328
  description: Sprockets is a Rack-based asset packaging system that concatenates and
189
- serves JavaScript, CoffeeScript, CSS, LESS, Sass, and SCSS.
329
+ serves JavaScript, CoffeeScript, CSS, Sass, and SCSS.
190
330
  email:
191
331
  - sstephenson@gmail.com
192
332
  - josh@joshpeek.com
@@ -195,40 +335,92 @@ executables:
195
335
  extensions: []
196
336
  extra_rdoc_files: []
197
337
  files:
198
- - LICENSE
338
+ - CHANGELOG.md
199
339
  - README.md
200
340
  - bin/sprockets
201
341
  - lib/rake/sprocketstask.rb
202
342
  - lib/sprockets.rb
343
+ - lib/sprockets/add_source_map_comment_to_asset_processor.rb
203
344
  - lib/sprockets/asset.rb
204
- - lib/sprockets/asset_attributes.rb
345
+ - lib/sprockets/autoload.rb
346
+ - lib/sprockets/autoload/babel.rb
347
+ - lib/sprockets/autoload/closure.rb
348
+ - lib/sprockets/autoload/coffee_script.rb
349
+ - lib/sprockets/autoload/eco.rb
350
+ - lib/sprockets/autoload/ejs.rb
351
+ - lib/sprockets/autoload/jsminc.rb
352
+ - lib/sprockets/autoload/sass.rb
353
+ - lib/sprockets/autoload/sassc.rb
354
+ - lib/sprockets/autoload/uglifier.rb
355
+ - lib/sprockets/autoload/yui.rb
356
+ - lib/sprockets/autoload/zopfli.rb
357
+ - lib/sprockets/babel_processor.rb
205
358
  - lib/sprockets/base.rb
206
- - lib/sprockets/bundled_asset.rb
359
+ - lib/sprockets/bower.rb
360
+ - lib/sprockets/bundle.rb
361
+ - lib/sprockets/cache.rb
207
362
  - lib/sprockets/cache/file_store.rb
208
- - lib/sprockets/caching.rb
209
- - lib/sprockets/charset_normalizer.rb
363
+ - lib/sprockets/cache/memory_store.rb
364
+ - lib/sprockets/cache/null_store.rb
365
+ - lib/sprockets/cached_environment.rb
366
+ - lib/sprockets/closure_compressor.rb
367
+ - lib/sprockets/coffee_script_processor.rb
368
+ - lib/sprockets/compressing.rb
369
+ - lib/sprockets/configuration.rb
210
370
  - lib/sprockets/context.rb
371
+ - lib/sprockets/dependencies.rb
372
+ - lib/sprockets/digest_utils.rb
211
373
  - lib/sprockets/directive_processor.rb
212
- - lib/sprockets/eco_template.rb
213
- - lib/sprockets/ejs_template.rb
214
- - lib/sprockets/engines.rb
374
+ - lib/sprockets/eco_processor.rb
375
+ - lib/sprockets/ejs_processor.rb
376
+ - lib/sprockets/encoding_utils.rb
215
377
  - lib/sprockets/environment.rb
378
+ - lib/sprockets/erb_processor.rb
216
379
  - lib/sprockets/errors.rb
217
- - lib/sprockets/index.rb
380
+ - lib/sprockets/exporters/base.rb
381
+ - lib/sprockets/exporters/file_exporter.rb
382
+ - lib/sprockets/exporters/zlib_exporter.rb
383
+ - lib/sprockets/exporters/zopfli_exporter.rb
384
+ - lib/sprockets/exporting.rb
385
+ - lib/sprockets/file_reader.rb
386
+ - lib/sprockets/http_utils.rb
387
+ - lib/sprockets/jsminc_compressor.rb
218
388
  - lib/sprockets/jst_processor.rb
389
+ - lib/sprockets/loader.rb
219
390
  - lib/sprockets/manifest.rb
391
+ - lib/sprockets/manifest_utils.rb
220
392
  - lib/sprockets/mime.rb
221
- - lib/sprockets/processed_asset.rb
393
+ - lib/sprockets/npm.rb
394
+ - lib/sprockets/path_dependency_utils.rb
395
+ - lib/sprockets/path_digest_utils.rb
396
+ - lib/sprockets/path_utils.rb
397
+ - lib/sprockets/paths.rb
398
+ - lib/sprockets/preprocessors/default_source_map.rb
222
399
  - lib/sprockets/processing.rb
223
- - lib/sprockets/processor.rb
224
- - lib/sprockets/safety_colons.rb
400
+ - lib/sprockets/processor_utils.rb
401
+ - lib/sprockets/resolve.rb
402
+ - lib/sprockets/sass_cache_store.rb
403
+ - lib/sprockets/sass_compressor.rb
404
+ - lib/sprockets/sass_functions.rb
405
+ - lib/sprockets/sass_importer.rb
406
+ - lib/sprockets/sass_processor.rb
407
+ - lib/sprockets/sassc_compressor.rb
408
+ - lib/sprockets/sassc_processor.rb
225
409
  - lib/sprockets/server.rb
226
- - lib/sprockets/static_asset.rb
227
- - lib/sprockets/trail.rb
410
+ - lib/sprockets/source_map_processor.rb
411
+ - lib/sprockets/source_map_utils.rb
412
+ - lib/sprockets/transformers.rb
413
+ - lib/sprockets/uglifier_compressor.rb
414
+ - lib/sprockets/unloaded_asset.rb
415
+ - lib/sprockets/uri_tar.rb
416
+ - lib/sprockets/uri_utils.rb
228
417
  - lib/sprockets/utils.rb
418
+ - lib/sprockets/utils/gzip.rb
229
419
  - lib/sprockets/version.rb
230
- homepage: http://getsprockets.org/
231
- licenses: []
420
+ - lib/sprockets/yui_compressor.rb
421
+ homepage: https://github.com/rails/sprockets
422
+ licenses:
423
+ - MIT
232
424
  metadata: {}
233
425
  post_install_message:
234
426
  rdoc_options: []
@@ -238,15 +430,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
238
430
  requirements:
239
431
  - - ">="
240
432
  - !ruby/object:Gem::Version
241
- version: '0'
433
+ version: 2.5.0
242
434
  required_rubygems_version: !ruby/object:Gem::Requirement
243
435
  requirements:
244
436
  - - ">="
245
437
  - !ruby/object:Gem::Version
246
438
  version: '0'
247
439
  requirements: []
248
- rubyforge_project: sprockets
249
- rubygems_version: 2.2.2
440
+ rubygems_version: 3.0.3
250
441
  signing_key:
251
442
  specification_version: 4
252
443
  summary: Rack-based asset packaging system
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- Copyright (c) 2011 Sam Stephenson
2
- Copyright (c) 2011 Joshua Peek
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,126 +0,0 @@
1
- require 'pathname'
2
-
3
- module Sprockets
4
- # `AssetAttributes` is a wrapper similar to `Pathname` that provides
5
- # some helper accessors.
6
- #
7
- # These methods should be considered internalish.
8
- class AssetAttributes
9
- attr_reader :environment, :pathname
10
-
11
- def initialize(environment, path)
12
- @environment = environment
13
- @pathname = path.is_a?(Pathname) ? path : Pathname.new(path.to_s)
14
- end
15
-
16
- # Returns paths search the load path for.
17
- def search_paths
18
- paths = [pathname.to_s]
19
-
20
- if pathname.basename(extensions.join).to_s != 'index'
21
- path_without_extensions = extensions.inject(pathname) { |p, ext| p.sub(ext, '') }
22
- index_path = path_without_extensions.join("index#{extensions.join}").to_s
23
- paths << index_path
24
- end
25
-
26
- paths
27
- end
28
-
29
- # Reverse guess logical path for fully expanded path.
30
- #
31
- # This has some known issues. For an example if a file is
32
- # shaddowed in the path, but is required relatively, its logical
33
- # path will be incorrect.
34
- def logical_path
35
- if root_path = environment.paths.detect { |path| pathname.to_s[path] }
36
- path = pathname.to_s.sub("#{root_path}/", '')
37
- path = pathname.relative_path_from(Pathname.new(root_path)).to_s
38
- path = engine_extensions.inject(path) { |p, ext| p.sub(ext, '') }
39
- path = "#{path}#{engine_format_extension}" unless format_extension
40
- path
41
- else
42
- raise FileOutsidePaths, "#{pathname} isn't in paths: #{environment.paths.join(', ')}"
43
- end
44
- end
45
-
46
- # Returns `Array` of extension `String`s.
47
- #
48
- # "foo.js.coffee"
49
- # # => [".js", ".coffee"]
50
- #
51
- def extensions
52
- @extensions ||= @pathname.basename.to_s.scan(/\.[^.]+/)
53
- end
54
-
55
- # Returns the format extension.
56
- #
57
- # "foo.js.coffee"
58
- # # => ".js"
59
- #
60
- def format_extension
61
- extensions.reverse.detect { |ext|
62
- @environment.mime_types(ext) && !@environment.engines(ext)
63
- }
64
- end
65
-
66
- # Returns an `Array` of engine extensions.
67
- #
68
- # "foo.js.coffee.erb"
69
- # # => [".coffee", ".erb"]
70
- #
71
- def engine_extensions
72
- exts = extensions
73
-
74
- if offset = extensions.index(format_extension)
75
- exts = extensions[offset+1..-1]
76
- end
77
-
78
- exts.select { |ext| @environment.engines(ext) }
79
- end
80
-
81
- # Returns engine classes.
82
- def engines
83
- engine_extensions.map { |ext| @environment.engines(ext) }
84
- end
85
-
86
- # Returns all processors to run on the path.
87
- def processors
88
- environment.preprocessors(content_type) +
89
- engines.reverse +
90
- environment.postprocessors(content_type)
91
- end
92
-
93
- # Returns the content type for the pathname. Falls back to `application/octet-stream`.
94
- def content_type
95
- @content_type ||= begin
96
- if format_extension.nil?
97
- engine_content_type || 'application/octet-stream'
98
- else
99
- @environment.mime_types(format_extension) ||
100
- engine_content_type ||
101
- 'application/octet-stream'
102
- end
103
- end
104
- end
105
-
106
- private
107
- # Returns implicit engine content type.
108
- #
109
- # `.coffee` files carry an implicit `application/javascript`
110
- # content type.
111
- def engine_content_type
112
- engines.reverse.each do |engine|
113
- if engine.respond_to?(:default_mime_type) && engine.default_mime_type
114
- return engine.default_mime_type
115
- end
116
- end
117
- nil
118
- end
119
-
120
- def engine_format_extension
121
- if content_type = engine_content_type
122
- environment.extension_for_mime_type(content_type)
123
- end
124
- end
125
- end
126
- end
@@ -1,79 +0,0 @@
1
- require 'sprockets/asset'
2
- require 'sprockets/errors'
3
- require 'fileutils'
4
- require 'set'
5
- require 'zlib'
6
-
7
- module Sprockets
8
- # `BundledAsset`s are used for files that need to be processed and
9
- # concatenated with other assets. Use for `.js` and `.css` files.
10
- class BundledAsset < Asset
11
- attr_reader :source
12
-
13
- def initialize(environment, logical_path, pathname)
14
- super(environment, logical_path, pathname)
15
-
16
- @processed_asset = environment.find_asset(pathname, :bundle => false)
17
- @required_assets = @processed_asset.required_assets
18
-
19
- @source = ""
20
-
21
- # Explode Asset into parts and gather the dependency bodies
22
- to_a.each { |dependency| @source << dependency.to_s }
23
-
24
- # Run bundle processors on concatenated source
25
- context = environment.context_class.new(environment, logical_path, pathname)
26
- @source = context.evaluate(pathname, :data => @source,
27
- :processors => environment.bundle_processors(content_type))
28
-
29
- @mtime = to_a.map(&:mtime).max
30
- @length = Rack::Utils.bytesize(source)
31
- @digest = environment.digest.update(source).hexdigest
32
- end
33
-
34
- # Initialize `BundledAsset` from serialized `Hash`.
35
- def init_with(environment, coder)
36
- super
37
-
38
- @processed_asset = environment.find_asset(pathname, :bundle => false)
39
- @required_assets = @processed_asset.required_assets
40
-
41
- if @processed_asset.dependency_digest != coder['required_assets_digest']
42
- raise UnserializeError, "processed asset belongs to a stale environment"
43
- end
44
-
45
- @source = coder['source']
46
- end
47
-
48
- # Serialize custom attributes in `BundledAsset`.
49
- def encode_with(coder)
50
- super
51
-
52
- coder['source'] = source
53
- coder['required_assets_digest'] = @processed_asset.dependency_digest
54
- end
55
-
56
- # Get asset's own processed contents. Excludes any of its required
57
- # dependencies but does run any processors or engines on the
58
- # original file.
59
- def body
60
- @processed_asset.source
61
- end
62
-
63
- # Return an `Array` of `Asset` files that are declared dependencies.
64
- def dependencies
65
- to_a.reject { |a| a.eql?(@processed_asset) }
66
- end
67
-
68
- # Expand asset into an `Array` of parts.
69
- def to_a
70
- required_assets
71
- end
72
-
73
- # Checks if Asset is stale by comparing the actual mtime and
74
- # digest to the inmemory model.
75
- def fresh?(environment)
76
- @processed_asset.fresh?(environment)
77
- end
78
- end
79
- end