sprockets 2.12.5 → 3.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +296 -0
- data/LICENSE +2 -2
- data/README.md +235 -262
- data/bin/sprockets +1 -0
- data/lib/rake/sprocketstask.rb +5 -4
- data/lib/sprockets/asset.rb +143 -212
- data/lib/sprockets/autoload/closure.rb +7 -0
- data/lib/sprockets/autoload/coffee_script.rb +7 -0
- data/lib/sprockets/autoload/eco.rb +7 -0
- data/lib/sprockets/autoload/ejs.rb +7 -0
- data/lib/sprockets/autoload/sass.rb +7 -0
- data/lib/sprockets/autoload/uglifier.rb +7 -0
- data/lib/sprockets/autoload/yui.rb +7 -0
- data/lib/sprockets/autoload.rb +11 -0
- data/lib/sprockets/base.rb +56 -393
- data/lib/sprockets/bower.rb +58 -0
- data/lib/sprockets/bundle.rb +69 -0
- data/lib/sprockets/cache/file_store.rb +168 -14
- data/lib/sprockets/cache/memory_store.rb +66 -0
- data/lib/sprockets/cache/null_store.rb +46 -0
- data/lib/sprockets/cache.rb +236 -0
- data/lib/sprockets/cached_environment.rb +69 -0
- data/lib/sprockets/closure_compressor.rb +35 -10
- data/lib/sprockets/coffee_script_processor.rb +25 -0
- data/lib/sprockets/coffee_script_template.rb +17 -0
- data/lib/sprockets/compressing.rb +44 -23
- data/lib/sprockets/configuration.rb +83 -0
- data/lib/sprockets/context.rb +86 -144
- data/lib/sprockets/dependencies.rb +73 -0
- data/lib/sprockets/deprecation.rb +90 -0
- data/lib/sprockets/digest_utils.rb +180 -0
- data/lib/sprockets/directive_processor.rb +207 -211
- data/lib/sprockets/eco_processor.rb +32 -0
- data/lib/sprockets/eco_template.rb +9 -30
- data/lib/sprockets/ejs_processor.rb +31 -0
- data/lib/sprockets/ejs_template.rb +9 -29
- data/lib/sprockets/encoding_utils.rb +261 -0
- data/lib/sprockets/engines.rb +53 -35
- data/lib/sprockets/environment.rb +17 -64
- data/lib/sprockets/erb_processor.rb +30 -0
- data/lib/sprockets/erb_template.rb +11 -0
- data/lib/sprockets/errors.rb +4 -13
- data/lib/sprockets/file_reader.rb +15 -0
- data/lib/sprockets/http_utils.rb +117 -0
- data/lib/sprockets/jst_processor.rb +35 -15
- data/lib/sprockets/legacy.rb +330 -0
- data/lib/sprockets/legacy_proc_processor.rb +35 -0
- data/lib/sprockets/legacy_tilt_processor.rb +29 -0
- data/lib/sprockets/loader.rb +325 -0
- data/lib/sprockets/manifest.rb +202 -127
- data/lib/sprockets/manifest_utils.rb +45 -0
- data/lib/sprockets/mime.rb +112 -31
- data/lib/sprockets/path_dependency_utils.rb +85 -0
- data/lib/sprockets/path_digest_utils.rb +47 -0
- data/lib/sprockets/path_utils.rb +287 -0
- data/lib/sprockets/paths.rb +42 -19
- data/lib/sprockets/processing.rb +178 -126
- data/lib/sprockets/processor_utils.rb +180 -0
- data/lib/sprockets/resolve.rb +211 -0
- data/lib/sprockets/sass_cache_store.rb +22 -17
- data/lib/sprockets/sass_compressor.rb +39 -15
- data/lib/sprockets/sass_functions.rb +2 -70
- data/lib/sprockets/sass_importer.rb +2 -30
- data/lib/sprockets/sass_processor.rb +292 -0
- data/lib/sprockets/sass_template.rb +12 -59
- data/lib/sprockets/server.rb +129 -84
- data/lib/sprockets/transformers.rb +145 -0
- data/lib/sprockets/uglifier_compressor.rb +39 -12
- data/lib/sprockets/unloaded_asset.rb +137 -0
- data/lib/sprockets/uri_tar.rb +98 -0
- data/lib/sprockets/uri_utils.rb +188 -0
- data/lib/sprockets/utils/gzip.rb +67 -0
- data/lib/sprockets/utils.rb +210 -44
- data/lib/sprockets/version.rb +1 -1
- data/lib/sprockets/yui_compressor.rb +39 -11
- data/lib/sprockets.rb +142 -81
- metadata +96 -90
- data/lib/sprockets/asset_attributes.rb +0 -137
- data/lib/sprockets/bundled_asset.rb +0 -78
- data/lib/sprockets/caching.rb +0 -96
- data/lib/sprockets/charset_normalizer.rb +0 -41
- data/lib/sprockets/index.rb +0 -100
- data/lib/sprockets/processed_asset.rb +0 -152
- data/lib/sprockets/processor.rb +0 -32
- data/lib/sprockets/safety_colons.rb +0 -28
- data/lib/sprockets/scss_template.rb +0 -13
- data/lib/sprockets/static_asset.rb +0 -60
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:
|
4
|
+
version: 3.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -12,35 +12,27 @@ cert_chain: []
|
|
12
12
|
date: 2018-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: rack
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '1.2'
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
18
|
+
- - ">"
|
26
19
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1
|
28
|
-
-
|
29
|
-
name: multi_json
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - "~>"
|
20
|
+
version: '1'
|
21
|
+
- - "<"
|
33
22
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
23
|
+
version: '3'
|
35
24
|
type: :runtime
|
36
25
|
prerelease: false
|
37
26
|
version_requirements: !ruby/object:Gem::Requirement
|
38
27
|
requirements:
|
39
|
-
- - "
|
28
|
+
- - ">"
|
40
29
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1
|
30
|
+
version: '1'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
42
34
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
35
|
+
name: concurrent-ruby
|
44
36
|
requirement: !ruby/object:Gem::Requirement
|
45
37
|
requirements:
|
46
38
|
- - "~>"
|
@@ -54,69 +46,63 @@ dependencies:
|
|
54
46
|
- !ruby/object:Gem::Version
|
55
47
|
version: '1.0'
|
56
48
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
49
|
+
name: closure-compiler
|
58
50
|
requirement: !ruby/object:Gem::Requirement
|
59
51
|
requirements:
|
60
52
|
- - "~>"
|
61
53
|
- !ruby/object:Gem::Version
|
62
54
|
version: '1.1'
|
63
|
-
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: 1.3.0
|
66
|
-
type: :runtime
|
55
|
+
type: :development
|
67
56
|
prerelease: false
|
68
57
|
version_requirements: !ruby/object:Gem::Requirement
|
69
58
|
requirements:
|
70
59
|
- - "~>"
|
71
60
|
- !ruby/object:Gem::Version
|
72
61
|
version: '1.1'
|
73
|
-
- - "!="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.3.0
|
76
62
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
63
|
+
name: coffee-script-source
|
78
64
|
requirement: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
68
|
+
version: '1.6'
|
83
69
|
type: :development
|
84
70
|
prerelease: false
|
85
71
|
version_requirements: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - "
|
73
|
+
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
75
|
+
version: '1.6'
|
90
76
|
- !ruby/object:Gem::Dependency
|
91
77
|
name: coffee-script
|
92
78
|
requirement: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '2.
|
82
|
+
version: '2.2'
|
97
83
|
type: :development
|
98
84
|
prerelease: false
|
99
85
|
version_requirements: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2.
|
89
|
+
version: '2.2'
|
104
90
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
91
|
+
name: eco
|
106
92
|
requirement: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
96
|
+
version: '1.0'
|
111
97
|
type: :development
|
112
98
|
prerelease: false
|
113
99
|
version_requirements: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
103
|
+
version: '1.0'
|
118
104
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
105
|
+
name: ejs
|
120
106
|
requirement: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - "~>"
|
@@ -130,75 +116,75 @@ dependencies:
|
|
130
116
|
- !ruby/object:Gem::Version
|
131
117
|
version: '1.0'
|
132
118
|
- !ruby/object:Gem::Dependency
|
133
|
-
name:
|
119
|
+
name: execjs
|
134
120
|
requirement: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
124
|
+
version: '2.0'
|
139
125
|
type: :development
|
140
126
|
prerelease: false
|
141
127
|
version_requirements: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - "~>"
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
131
|
+
version: '2.0'
|
146
132
|
- !ruby/object:Gem::Dependency
|
147
|
-
name:
|
133
|
+
name: minitest
|
148
134
|
requirement: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
136
|
- - "~>"
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
138
|
+
version: '5.0'
|
153
139
|
type: :development
|
154
140
|
prerelease: false
|
155
141
|
version_requirements: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
143
|
- - "~>"
|
158
144
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
145
|
+
version: '5.0'
|
160
146
|
- !ruby/object:Gem::Dependency
|
161
|
-
name:
|
147
|
+
name: nokogiri
|
162
148
|
requirement: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
|
-
- - "
|
150
|
+
- - "~>"
|
165
151
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
152
|
+
version: '1.3'
|
167
153
|
type: :development
|
168
154
|
prerelease: false
|
169
155
|
version_requirements: !ruby/object:Gem::Requirement
|
170
156
|
requirements:
|
171
|
-
- - "
|
157
|
+
- - "~>"
|
172
158
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
159
|
+
version: '1.3'
|
174
160
|
- !ruby/object:Gem::Dependency
|
175
161
|
name: rack-test
|
176
162
|
requirement: !ruby/object:Gem::Requirement
|
177
163
|
requirements:
|
178
|
-
- - "
|
164
|
+
- - "~>"
|
179
165
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
166
|
+
version: '0.6'
|
181
167
|
type: :development
|
182
168
|
prerelease: false
|
183
169
|
version_requirements: !ruby/object:Gem::Requirement
|
184
170
|
requirements:
|
185
|
-
- - "
|
171
|
+
- - "~>"
|
186
172
|
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
173
|
+
version: '0.6'
|
188
174
|
- !ruby/object:Gem::Dependency
|
189
175
|
name: rake
|
190
176
|
requirement: !ruby/object:Gem::Requirement
|
191
177
|
requirements:
|
192
|
-
- - "
|
178
|
+
- - "~>"
|
193
179
|
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
180
|
+
version: '10.0'
|
195
181
|
type: :development
|
196
182
|
prerelease: false
|
197
183
|
version_requirements: !ruby/object:Gem::Requirement
|
198
184
|
requirements:
|
199
|
-
- - "
|
185
|
+
- - "~>"
|
200
186
|
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
187
|
+
version: '10.0'
|
202
188
|
- !ruby/object:Gem::Dependency
|
203
189
|
name: sass
|
204
190
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,44 +203,30 @@ dependencies:
|
|
217
203
|
name: uglifier
|
218
204
|
requirement: !ruby/object:Gem::Requirement
|
219
205
|
requirements:
|
220
|
-
- - "
|
206
|
+
- - "~>"
|
221
207
|
- !ruby/object:Gem::Version
|
222
|
-
version: '
|
208
|
+
version: '2.3'
|
223
209
|
type: :development
|
224
210
|
prerelease: false
|
225
211
|
version_requirements: !ruby/object:Gem::Requirement
|
226
212
|
requirements:
|
227
|
-
- - "
|
213
|
+
- - "~>"
|
228
214
|
- !ruby/object:Gem::Version
|
229
|
-
version: '
|
215
|
+
version: '2.3'
|
230
216
|
- !ruby/object:Gem::Dependency
|
231
217
|
name: yui-compressor
|
232
|
-
requirement: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ">="
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0'
|
237
|
-
type: :development
|
238
|
-
prerelease: false
|
239
|
-
version_requirements: !ruby/object:Gem::Requirement
|
240
|
-
requirements:
|
241
|
-
- - ">="
|
242
|
-
- !ruby/object:Gem::Version
|
243
|
-
version: '0'
|
244
|
-
- !ruby/object:Gem::Dependency
|
245
|
-
name: test-unit
|
246
218
|
requirement: !ruby/object:Gem::Requirement
|
247
219
|
requirements:
|
248
220
|
- - "~>"
|
249
221
|
- !ruby/object:Gem::Version
|
250
|
-
version: '
|
222
|
+
version: '0.12'
|
251
223
|
type: :development
|
252
224
|
prerelease: false
|
253
225
|
version_requirements: !ruby/object:Gem::Requirement
|
254
226
|
requirements:
|
255
227
|
- - "~>"
|
256
228
|
- !ruby/object:Gem::Version
|
257
|
-
version: '
|
229
|
+
version: '0.12'
|
258
230
|
description: Sprockets is a Rack-based asset packaging system that concatenates and
|
259
231
|
serves JavaScript, CoffeeScript, CSS, LESS, Sass, and SCSS.
|
260
232
|
email:
|
@@ -265,49 +237,83 @@ executables:
|
|
265
237
|
extensions: []
|
266
238
|
extra_rdoc_files: []
|
267
239
|
files:
|
240
|
+
- CHANGELOG.md
|
268
241
|
- LICENSE
|
269
242
|
- README.md
|
270
243
|
- bin/sprockets
|
271
244
|
- lib/rake/sprocketstask.rb
|
272
245
|
- lib/sprockets.rb
|
273
246
|
- lib/sprockets/asset.rb
|
274
|
-
- lib/sprockets/
|
247
|
+
- lib/sprockets/autoload.rb
|
248
|
+
- lib/sprockets/autoload/closure.rb
|
249
|
+
- lib/sprockets/autoload/coffee_script.rb
|
250
|
+
- lib/sprockets/autoload/eco.rb
|
251
|
+
- lib/sprockets/autoload/ejs.rb
|
252
|
+
- lib/sprockets/autoload/sass.rb
|
253
|
+
- lib/sprockets/autoload/uglifier.rb
|
254
|
+
- lib/sprockets/autoload/yui.rb
|
275
255
|
- lib/sprockets/base.rb
|
276
|
-
- lib/sprockets/
|
256
|
+
- lib/sprockets/bower.rb
|
257
|
+
- lib/sprockets/bundle.rb
|
258
|
+
- lib/sprockets/cache.rb
|
277
259
|
- lib/sprockets/cache/file_store.rb
|
278
|
-
- lib/sprockets/
|
279
|
-
- lib/sprockets/
|
260
|
+
- lib/sprockets/cache/memory_store.rb
|
261
|
+
- lib/sprockets/cache/null_store.rb
|
262
|
+
- lib/sprockets/cached_environment.rb
|
280
263
|
- lib/sprockets/closure_compressor.rb
|
264
|
+
- lib/sprockets/coffee_script_processor.rb
|
265
|
+
- lib/sprockets/coffee_script_template.rb
|
281
266
|
- lib/sprockets/compressing.rb
|
267
|
+
- lib/sprockets/configuration.rb
|
282
268
|
- lib/sprockets/context.rb
|
269
|
+
- lib/sprockets/dependencies.rb
|
270
|
+
- lib/sprockets/deprecation.rb
|
271
|
+
- lib/sprockets/digest_utils.rb
|
283
272
|
- lib/sprockets/directive_processor.rb
|
273
|
+
- lib/sprockets/eco_processor.rb
|
284
274
|
- lib/sprockets/eco_template.rb
|
275
|
+
- lib/sprockets/ejs_processor.rb
|
285
276
|
- lib/sprockets/ejs_template.rb
|
277
|
+
- lib/sprockets/encoding_utils.rb
|
286
278
|
- lib/sprockets/engines.rb
|
287
279
|
- lib/sprockets/environment.rb
|
280
|
+
- lib/sprockets/erb_processor.rb
|
281
|
+
- lib/sprockets/erb_template.rb
|
288
282
|
- lib/sprockets/errors.rb
|
289
|
-
- lib/sprockets/
|
283
|
+
- lib/sprockets/file_reader.rb
|
284
|
+
- lib/sprockets/http_utils.rb
|
290
285
|
- lib/sprockets/jst_processor.rb
|
286
|
+
- lib/sprockets/legacy.rb
|
287
|
+
- lib/sprockets/legacy_proc_processor.rb
|
288
|
+
- lib/sprockets/legacy_tilt_processor.rb
|
289
|
+
- lib/sprockets/loader.rb
|
291
290
|
- lib/sprockets/manifest.rb
|
291
|
+
- lib/sprockets/manifest_utils.rb
|
292
292
|
- lib/sprockets/mime.rb
|
293
|
+
- lib/sprockets/path_dependency_utils.rb
|
294
|
+
- lib/sprockets/path_digest_utils.rb
|
295
|
+
- lib/sprockets/path_utils.rb
|
293
296
|
- lib/sprockets/paths.rb
|
294
|
-
- lib/sprockets/processed_asset.rb
|
295
297
|
- lib/sprockets/processing.rb
|
296
|
-
- lib/sprockets/
|
297
|
-
- lib/sprockets/
|
298
|
+
- lib/sprockets/processor_utils.rb
|
299
|
+
- lib/sprockets/resolve.rb
|
298
300
|
- lib/sprockets/sass_cache_store.rb
|
299
301
|
- lib/sprockets/sass_compressor.rb
|
300
302
|
- lib/sprockets/sass_functions.rb
|
301
303
|
- lib/sprockets/sass_importer.rb
|
304
|
+
- lib/sprockets/sass_processor.rb
|
302
305
|
- lib/sprockets/sass_template.rb
|
303
|
-
- lib/sprockets/scss_template.rb
|
304
306
|
- lib/sprockets/server.rb
|
305
|
-
- lib/sprockets/
|
307
|
+
- lib/sprockets/transformers.rb
|
306
308
|
- lib/sprockets/uglifier_compressor.rb
|
309
|
+
- lib/sprockets/unloaded_asset.rb
|
310
|
+
- lib/sprockets/uri_tar.rb
|
311
|
+
- lib/sprockets/uri_utils.rb
|
307
312
|
- lib/sprockets/utils.rb
|
313
|
+
- lib/sprockets/utils/gzip.rb
|
308
314
|
- lib/sprockets/version.rb
|
309
315
|
- lib/sprockets/yui_compressor.rb
|
310
|
-
homepage:
|
316
|
+
homepage: https://github.com/rails/sprockets
|
311
317
|
licenses:
|
312
318
|
- MIT
|
313
319
|
metadata: {}
|
@@ -319,7 +325,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
319
325
|
requirements:
|
320
326
|
- - ">="
|
321
327
|
- !ruby/object:Gem::Version
|
322
|
-
version:
|
328
|
+
version: 1.9.3
|
323
329
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
324
330
|
requirements:
|
325
331
|
- - ">="
|
@@ -1,137 +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
|
-
extension = format_extension
|
21
|
-
path_without_extension = extension ?
|
22
|
-
pathname.sub(extension, '') :
|
23
|
-
pathname
|
24
|
-
|
25
|
-
# optimization: bower.json can only be nested one level deep
|
26
|
-
if !path_without_extension.to_s.index('/')
|
27
|
-
paths << path_without_extension.join(".bower.json").to_s
|
28
|
-
paths << path_without_extension.join("bower.json").to_s
|
29
|
-
# DEPRECATED bower configuration file
|
30
|
-
paths << path_without_extension.join("component.json").to_s
|
31
|
-
end
|
32
|
-
|
33
|
-
if pathname.basename(extension.to_s).to_s != 'index'
|
34
|
-
paths << path_without_extension.join("index#{extension}").to_s
|
35
|
-
end
|
36
|
-
|
37
|
-
paths
|
38
|
-
end
|
39
|
-
|
40
|
-
# Reverse guess logical path for fully expanded path.
|
41
|
-
#
|
42
|
-
# This has some known issues. For an example if a file is
|
43
|
-
# shaddowed in the path, but is required relatively, its logical
|
44
|
-
# path will be incorrect.
|
45
|
-
def logical_path
|
46
|
-
if root_path = environment.paths.detect { |path| pathname.to_s[path] }
|
47
|
-
path = pathname.to_s.sub("#{root_path}/", '')
|
48
|
-
path = pathname.relative_path_from(Pathname.new(root_path)).to_s
|
49
|
-
path = engine_extensions.inject(path) { |p, ext| p.sub(ext, '') }
|
50
|
-
path = "#{path}#{engine_format_extension}" unless format_extension
|
51
|
-
path
|
52
|
-
else
|
53
|
-
raise FileOutsidePaths, "#{pathname} isn't in paths: #{environment.paths.join(', ')}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Returns `Array` of extension `String`s.
|
58
|
-
#
|
59
|
-
# "foo.js.coffee"
|
60
|
-
# # => [".js", ".coffee"]
|
61
|
-
#
|
62
|
-
def extensions
|
63
|
-
@extensions ||= @pathname.basename.to_s.scan(/\.[^.]+/)
|
64
|
-
end
|
65
|
-
|
66
|
-
# Returns the format extension.
|
67
|
-
#
|
68
|
-
# "foo.js.coffee"
|
69
|
-
# # => ".js"
|
70
|
-
#
|
71
|
-
def format_extension
|
72
|
-
extensions.reverse.detect { |ext|
|
73
|
-
@environment.mime_types(ext) && !@environment.engines(ext)
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
# Returns an `Array` of engine extensions.
|
78
|
-
#
|
79
|
-
# "foo.js.coffee.erb"
|
80
|
-
# # => [".coffee", ".erb"]
|
81
|
-
#
|
82
|
-
def engine_extensions
|
83
|
-
exts = extensions
|
84
|
-
|
85
|
-
if offset = extensions.index(format_extension)
|
86
|
-
exts = extensions[offset+1..-1]
|
87
|
-
end
|
88
|
-
|
89
|
-
exts.select { |ext| @environment.engines(ext) }
|
90
|
-
end
|
91
|
-
|
92
|
-
# Returns engine classes.
|
93
|
-
def engines
|
94
|
-
engine_extensions.map { |ext| @environment.engines(ext) }
|
95
|
-
end
|
96
|
-
|
97
|
-
# Returns all processors to run on the path.
|
98
|
-
def processors
|
99
|
-
environment.preprocessors(content_type) +
|
100
|
-
engines.reverse +
|
101
|
-
environment.postprocessors(content_type)
|
102
|
-
end
|
103
|
-
|
104
|
-
# Returns the content type for the pathname. Falls back to `application/octet-stream`.
|
105
|
-
def content_type
|
106
|
-
@content_type ||= begin
|
107
|
-
if format_extension.nil?
|
108
|
-
engine_content_type || 'application/octet-stream'
|
109
|
-
else
|
110
|
-
@environment.mime_types(format_extension) ||
|
111
|
-
engine_content_type ||
|
112
|
-
'application/octet-stream'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
private
|
118
|
-
# Returns implicit engine content type.
|
119
|
-
#
|
120
|
-
# `.coffee` files carry an implicit `application/javascript`
|
121
|
-
# content type.
|
122
|
-
def engine_content_type
|
123
|
-
engines.reverse.each do |engine|
|
124
|
-
if engine.respond_to?(:default_mime_type) && engine.default_mime_type
|
125
|
-
return engine.default_mime_type
|
126
|
-
end
|
127
|
-
end
|
128
|
-
nil
|
129
|
-
end
|
130
|
-
|
131
|
-
def engine_format_extension
|
132
|
-
if content_type = engine_content_type
|
133
|
-
environment.extension_for_mime_type(content_type)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,78 +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
|
-
@dependency_paths = @processed_asset.dependency_paths
|
19
|
-
|
20
|
-
# Explode Asset into parts and gather the dependency bodies
|
21
|
-
@source = to_a.map { |dependency| dependency.to_s }.join
|
22
|
-
|
23
|
-
# Run bundle processors on concatenated source
|
24
|
-
context = environment.context_class.new(environment, logical_path, pathname)
|
25
|
-
@source = context.evaluate(pathname, :data => @source,
|
26
|
-
:processors => environment.bundle_processors(content_type))
|
27
|
-
|
28
|
-
@mtime = (to_a + @dependency_paths).map(&:mtime).max
|
29
|
-
@length = Rack::Utils.bytesize(source)
|
30
|
-
@digest = environment.digest.update(source).hexdigest
|
31
|
-
end
|
32
|
-
|
33
|
-
# Initialize `BundledAsset` from serialized `Hash`.
|
34
|
-
def init_with(environment, coder)
|
35
|
-
super
|
36
|
-
|
37
|
-
@processed_asset = environment.find_asset(pathname, :bundle => false)
|
38
|
-
@required_assets = @processed_asset.required_assets
|
39
|
-
|
40
|
-
if @processed_asset.dependency_digest != coder['required_assets_digest']
|
41
|
-
raise UnserializeError, "processed asset belongs to a stale environment"
|
42
|
-
end
|
43
|
-
|
44
|
-
@source = coder['source']
|
45
|
-
end
|
46
|
-
|
47
|
-
# Serialize custom attributes in `BundledAsset`.
|
48
|
-
def encode_with(coder)
|
49
|
-
super
|
50
|
-
|
51
|
-
coder['source'] = source
|
52
|
-
coder['required_assets_digest'] = @processed_asset.dependency_digest
|
53
|
-
end
|
54
|
-
|
55
|
-
# Get asset's own processed contents. Excludes any of its required
|
56
|
-
# dependencies but does run any processors or engines on the
|
57
|
-
# original file.
|
58
|
-
def body
|
59
|
-
@processed_asset.source
|
60
|
-
end
|
61
|
-
|
62
|
-
# Return an `Array` of `Asset` files that are declared dependencies.
|
63
|
-
def dependencies
|
64
|
-
to_a.reject { |a| a.eql?(@processed_asset) }
|
65
|
-
end
|
66
|
-
|
67
|
-
# Expand asset into an `Array` of parts.
|
68
|
-
def to_a
|
69
|
-
required_assets
|
70
|
-
end
|
71
|
-
|
72
|
-
# Checks if Asset is stale by comparing the actual mtime and
|
73
|
-
# digest to the inmemory model.
|
74
|
-
def fresh?(environment)
|
75
|
-
@processed_asset.fresh?(environment)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/lib/sprockets/caching.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
module Sprockets
|
2
|
-
# `Caching` is an internal mixin whose public methods are exposed on
|
3
|
-
# the `Environment` and `Index` classes.
|
4
|
-
module Caching
|
5
|
-
# Low level cache getter for `key`. Checks a number of supported
|
6
|
-
# cache interfaces.
|
7
|
-
def cache_get(key)
|
8
|
-
# `Cache#get(key)` for Memcache
|
9
|
-
if cache.respond_to?(:get)
|
10
|
-
cache.get(key)
|
11
|
-
|
12
|
-
# `Cache#[key]` so `Hash` can be used
|
13
|
-
elsif cache.respond_to?(:[])
|
14
|
-
cache[key]
|
15
|
-
|
16
|
-
# `Cache#read(key)` for `ActiveSupport::Cache` support
|
17
|
-
elsif cache.respond_to?(:read)
|
18
|
-
cache.read(key)
|
19
|
-
|
20
|
-
else
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Low level cache setter for `key`. Checks a number of supported
|
26
|
-
# cache interfaces.
|
27
|
-
def cache_set(key, value)
|
28
|
-
# `Cache#set(key, value)` for Memcache
|
29
|
-
if cache.respond_to?(:set)
|
30
|
-
cache.set(key, value)
|
31
|
-
|
32
|
-
# `Cache#[key]=value` so `Hash` can be used
|
33
|
-
elsif cache.respond_to?(:[]=)
|
34
|
-
cache[key] = value
|
35
|
-
|
36
|
-
# `Cache#write(key, value)` for `ActiveSupport::Cache` support
|
37
|
-
elsif cache.respond_to?(:write)
|
38
|
-
cache.write(key, value)
|
39
|
-
end
|
40
|
-
|
41
|
-
value
|
42
|
-
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
# Cache helper method. Takes a `path` argument which maybe a
|
46
|
-
# logical path or fully expanded path. The `&block` is passed
|
47
|
-
# for finding and building the asset if its not in cache.
|
48
|
-
def cache_asset(path)
|
49
|
-
# If `cache` is not set, return fast
|
50
|
-
if cache.nil?
|
51
|
-
yield
|
52
|
-
|
53
|
-
# Check cache for `path`
|
54
|
-
elsif (asset = Asset.from_hash(self, cache_get_hash(path.to_s))) && asset.fresh?(self)
|
55
|
-
asset
|
56
|
-
|
57
|
-
# Otherwise yield block that slowly finds and builds the asset
|
58
|
-
elsif asset = yield
|
59
|
-
hash = {}
|
60
|
-
asset.encode_with(hash)
|
61
|
-
|
62
|
-
# Save the asset to its path
|
63
|
-
cache_set_hash(path.to_s, hash)
|
64
|
-
|
65
|
-
# Since path maybe a logical or full pathname, save the
|
66
|
-
# asset its its full path too
|
67
|
-
if path.to_s != asset.pathname.to_s
|
68
|
-
cache_set_hash(asset.pathname.to_s, hash)
|
69
|
-
end
|
70
|
-
|
71
|
-
asset
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
# Strips `Environment#root` from key to make the key work
|
77
|
-
# consisently across different servers. The key is also hashed
|
78
|
-
# so it does not exceed 250 characters.
|
79
|
-
def expand_cache_key(key)
|
80
|
-
File.join('sprockets', digest_class.hexdigest(key.sub(root, '')))
|
81
|
-
end
|
82
|
-
|
83
|
-
def cache_get_hash(key)
|
84
|
-
hash = cache_get(expand_cache_key(key))
|
85
|
-
if hash.is_a?(Hash) && digest.hexdigest == hash['_version']
|
86
|
-
hash
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def cache_set_hash(key, hash)
|
91
|
-
hash['_version'] = digest.hexdigest
|
92
|
-
cache_set(expand_cache_key(key), hash)
|
93
|
-
hash
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|