sprockets 2.12.5 → 3.0.0.beta.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 +5 -5
- data/LICENSE +2 -2
- data/README.md +61 -34
- data/lib/rake/sprocketstask.rb +5 -4
- data/lib/sprockets.rb +123 -85
- data/lib/sprockets/asset.rb +161 -200
- data/lib/sprockets/asset_uri.rb +64 -0
- data/lib/sprockets/base.rb +138 -373
- data/lib/sprockets/bower.rb +56 -0
- data/lib/sprockets/bundle.rb +32 -0
- data/lib/sprockets/cache.rb +220 -0
- data/lib/sprockets/cache/file_store.rb +145 -13
- data/lib/sprockets/cache/memory_store.rb +66 -0
- data/lib/sprockets/cache/null_store.rb +46 -0
- data/lib/sprockets/cached_environment.rb +103 -0
- data/lib/sprockets/closure_compressor.rb +30 -12
- data/lib/sprockets/coffee_script_template.rb +23 -0
- data/lib/sprockets/compressing.rb +20 -25
- data/lib/sprockets/configuration.rb +95 -0
- data/lib/sprockets/context.rb +68 -131
- data/lib/sprockets/directive_processor.rb +138 -179
- data/lib/sprockets/eco_template.rb +10 -19
- data/lib/sprockets/ejs_template.rb +10 -19
- data/lib/sprockets/encoding_utils.rb +246 -0
- data/lib/sprockets/engines.rb +40 -29
- data/lib/sprockets/environment.rb +10 -66
- data/lib/sprockets/erb_template.rb +23 -0
- data/lib/sprockets/errors.rb +5 -13
- data/lib/sprockets/http_utils.rb +97 -0
- data/lib/sprockets/jst_processor.rb +28 -15
- data/lib/sprockets/lazy_processor.rb +15 -0
- data/lib/sprockets/legacy.rb +23 -0
- data/lib/sprockets/legacy_proc_processor.rb +35 -0
- data/lib/sprockets/legacy_tilt_processor.rb +29 -0
- data/lib/sprockets/manifest.rb +128 -99
- data/lib/sprockets/mime.rb +114 -33
- data/lib/sprockets/path_utils.rb +179 -0
- data/lib/sprockets/paths.rb +13 -26
- data/lib/sprockets/processing.rb +198 -107
- data/lib/sprockets/resolve.rb +289 -0
- data/lib/sprockets/sass_compressor.rb +36 -17
- data/lib/sprockets/sass_template.rb +269 -46
- data/lib/sprockets/server.rb +113 -83
- data/lib/sprockets/transformers.rb +69 -0
- data/lib/sprockets/uglifier_compressor.rb +36 -15
- data/lib/sprockets/utils.rb +161 -44
- data/lib/sprockets/version.rb +1 -1
- data/lib/sprockets/yui_compressor.rb +37 -12
- metadata +64 -106
- 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/sass_cache_store.rb +0 -29
- data/lib/sprockets/sass_functions.rb +0 -70
- data/lib/sprockets/sass_importer.rb +0 -30
- data/lib/sprockets/scss_template.rb +0 -13
- data/lib/sprockets/static_asset.rb +0 -60
data/lib/sprockets/version.rb
CHANGED
@@ -1,24 +1,49 @@
|
|
1
|
-
require '
|
1
|
+
require 'yui/compressor'
|
2
2
|
|
3
3
|
module Sprockets
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
# Public: YUI compressor.
|
5
|
+
#
|
6
|
+
# To accept the default options
|
7
|
+
#
|
8
|
+
# environment.register_bundle_processor 'application/javascript',
|
9
|
+
# Sprockets::YUICompressor
|
10
|
+
#
|
11
|
+
# Or to pass options to the YUI::JavaScriptCompressor class.
|
12
|
+
#
|
13
|
+
# environment.register_bundle_processor 'application/javascript',
|
14
|
+
# Sprockets::YUICompressor.new(munge: true)
|
15
|
+
#
|
16
|
+
class YUICompressor
|
17
|
+
VERSION = '1'
|
8
18
|
|
9
|
-
def
|
10
|
-
|
19
|
+
def self.call(*args)
|
20
|
+
new.call(*args)
|
11
21
|
end
|
12
22
|
|
13
|
-
def
|
23
|
+
def initialize(options = {})
|
24
|
+
@options = options
|
25
|
+
@cache_key = [
|
26
|
+
'YUICompressor',
|
27
|
+
::YUI::Compressor::VERSION,
|
28
|
+
VERSION,
|
29
|
+
options
|
30
|
+
]
|
14
31
|
end
|
15
32
|
|
16
|
-
def
|
17
|
-
|
33
|
+
def call(input)
|
34
|
+
data = input[:data]
|
35
|
+
|
36
|
+
case input[:content_type]
|
18
37
|
when 'application/javascript'
|
19
|
-
|
38
|
+
key = @cache_key + [input[:content_type], input[:data]]
|
39
|
+
input[:cache].fetch(key) do
|
40
|
+
::YUI::JavaScriptCompressor.new(@options).compress(data)
|
41
|
+
end
|
20
42
|
when 'text/css'
|
21
|
-
|
43
|
+
key = @cache_key + [input[:content_type], input[:data]]
|
44
|
+
input[:cache].fetch(key) do
|
45
|
+
::YUI::CssCompressor.new(@options).compress(data)
|
46
|
+
end
|
22
47
|
else
|
23
48
|
data
|
24
49
|
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:
|
4
|
+
version: 3.0.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -9,36 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: hike
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
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
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '1.2'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: multi_json
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - "~>"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '1.0'
|
35
|
-
type: :runtime
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '1.0'
|
42
14
|
- !ruby/object:Gem::Dependency
|
43
15
|
name: rack
|
44
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,69 +26,63 @@ dependencies:
|
|
54
26
|
- !ruby/object:Gem::Version
|
55
27
|
version: '1.0'
|
56
28
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
29
|
+
name: closure-compiler
|
58
30
|
requirement: !ruby/object:Gem::Requirement
|
59
31
|
requirements:
|
60
32
|
- - "~>"
|
61
33
|
- !ruby/object:Gem::Version
|
62
34
|
version: '1.1'
|
63
|
-
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: 1.3.0
|
66
|
-
type: :runtime
|
35
|
+
type: :development
|
67
36
|
prerelease: false
|
68
37
|
version_requirements: !ruby/object:Gem::Requirement
|
69
38
|
requirements:
|
70
39
|
- - "~>"
|
71
40
|
- !ruby/object:Gem::Version
|
72
41
|
version: '1.1'
|
73
|
-
- - "!="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.3.0
|
76
42
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
43
|
+
name: coffee-script-source
|
78
44
|
requirement: !ruby/object:Gem::Requirement
|
79
45
|
requirements:
|
80
|
-
- - "
|
46
|
+
- - "~>"
|
81
47
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
48
|
+
version: '1.6'
|
83
49
|
type: :development
|
84
50
|
prerelease: false
|
85
51
|
version_requirements: !ruby/object:Gem::Requirement
|
86
52
|
requirements:
|
87
|
-
- - "
|
53
|
+
- - "~>"
|
88
54
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
55
|
+
version: '1.6'
|
90
56
|
- !ruby/object:Gem::Dependency
|
91
57
|
name: coffee-script
|
92
58
|
requirement: !ruby/object:Gem::Requirement
|
93
59
|
requirements:
|
94
60
|
- - "~>"
|
95
61
|
- !ruby/object:Gem::Version
|
96
|
-
version: '2.
|
62
|
+
version: '2.2'
|
97
63
|
type: :development
|
98
64
|
prerelease: false
|
99
65
|
version_requirements: !ruby/object:Gem::Requirement
|
100
66
|
requirements:
|
101
67
|
- - "~>"
|
102
68
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2.
|
69
|
+
version: '2.2'
|
104
70
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
71
|
+
name: eco
|
106
72
|
requirement: !ruby/object:Gem::Requirement
|
107
73
|
requirements:
|
108
74
|
- - "~>"
|
109
75
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
76
|
+
version: '1.0'
|
111
77
|
type: :development
|
112
78
|
prerelease: false
|
113
79
|
version_requirements: !ruby/object:Gem::Requirement
|
114
80
|
requirements:
|
115
81
|
- - "~>"
|
116
82
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
83
|
+
version: '1.0'
|
118
84
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
85
|
+
name: ejs
|
120
86
|
requirement: !ruby/object:Gem::Requirement
|
121
87
|
requirements:
|
122
88
|
- - "~>"
|
@@ -130,75 +96,75 @@ dependencies:
|
|
130
96
|
- !ruby/object:Gem::Version
|
131
97
|
version: '1.0'
|
132
98
|
- !ruby/object:Gem::Dependency
|
133
|
-
name:
|
99
|
+
name: execjs
|
134
100
|
requirement: !ruby/object:Gem::Requirement
|
135
101
|
requirements:
|
136
102
|
- - "~>"
|
137
103
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
104
|
+
version: '2.0'
|
139
105
|
type: :development
|
140
106
|
prerelease: false
|
141
107
|
version_requirements: !ruby/object:Gem::Requirement
|
142
108
|
requirements:
|
143
109
|
- - "~>"
|
144
110
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
111
|
+
version: '2.0'
|
146
112
|
- !ruby/object:Gem::Dependency
|
147
|
-
name:
|
113
|
+
name: minitest
|
148
114
|
requirement: !ruby/object:Gem::Requirement
|
149
115
|
requirements:
|
150
116
|
- - "~>"
|
151
117
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
118
|
+
version: '5.0'
|
153
119
|
type: :development
|
154
120
|
prerelease: false
|
155
121
|
version_requirements: !ruby/object:Gem::Requirement
|
156
122
|
requirements:
|
157
123
|
- - "~>"
|
158
124
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
125
|
+
version: '5.0'
|
160
126
|
- !ruby/object:Gem::Dependency
|
161
|
-
name:
|
127
|
+
name: nokogiri
|
162
128
|
requirement: !ruby/object:Gem::Requirement
|
163
129
|
requirements:
|
164
|
-
- - "
|
130
|
+
- - "~>"
|
165
131
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
132
|
+
version: '1.3'
|
167
133
|
type: :development
|
168
134
|
prerelease: false
|
169
135
|
version_requirements: !ruby/object:Gem::Requirement
|
170
136
|
requirements:
|
171
|
-
- - "
|
137
|
+
- - "~>"
|
172
138
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
139
|
+
version: '1.3'
|
174
140
|
- !ruby/object:Gem::Dependency
|
175
141
|
name: rack-test
|
176
142
|
requirement: !ruby/object:Gem::Requirement
|
177
143
|
requirements:
|
178
|
-
- - "
|
144
|
+
- - "~>"
|
179
145
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
146
|
+
version: '0.6'
|
181
147
|
type: :development
|
182
148
|
prerelease: false
|
183
149
|
version_requirements: !ruby/object:Gem::Requirement
|
184
150
|
requirements:
|
185
|
-
- - "
|
151
|
+
- - "~>"
|
186
152
|
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
153
|
+
version: '0.6'
|
188
154
|
- !ruby/object:Gem::Dependency
|
189
155
|
name: rake
|
190
156
|
requirement: !ruby/object:Gem::Requirement
|
191
157
|
requirements:
|
192
|
-
- - "
|
158
|
+
- - "~>"
|
193
159
|
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
160
|
+
version: '10.0'
|
195
161
|
type: :development
|
196
162
|
prerelease: false
|
197
163
|
version_requirements: !ruby/object:Gem::Requirement
|
198
164
|
requirements:
|
199
|
-
- - "
|
165
|
+
- - "~>"
|
200
166
|
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
167
|
+
version: '10.0'
|
202
168
|
- !ruby/object:Gem::Dependency
|
203
169
|
name: sass
|
204
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,44 +183,30 @@ dependencies:
|
|
217
183
|
name: uglifier
|
218
184
|
requirement: !ruby/object:Gem::Requirement
|
219
185
|
requirements:
|
220
|
-
- - "
|
186
|
+
- - "~>"
|
221
187
|
- !ruby/object:Gem::Version
|
222
|
-
version: '
|
188
|
+
version: '2.3'
|
223
189
|
type: :development
|
224
190
|
prerelease: false
|
225
191
|
version_requirements: !ruby/object:Gem::Requirement
|
226
192
|
requirements:
|
227
|
-
- - "
|
193
|
+
- - "~>"
|
228
194
|
- !ruby/object:Gem::Version
|
229
|
-
version: '
|
195
|
+
version: '2.3'
|
230
196
|
- !ruby/object:Gem::Dependency
|
231
197
|
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
198
|
requirement: !ruby/object:Gem::Requirement
|
247
199
|
requirements:
|
248
200
|
- - "~>"
|
249
201
|
- !ruby/object:Gem::Version
|
250
|
-
version: '
|
202
|
+
version: '0.12'
|
251
203
|
type: :development
|
252
204
|
prerelease: false
|
253
205
|
version_requirements: !ruby/object:Gem::Requirement
|
254
206
|
requirements:
|
255
207
|
- - "~>"
|
256
208
|
- !ruby/object:Gem::Version
|
257
|
-
version: '
|
209
|
+
version: '0.12'
|
258
210
|
description: Sprockets is a Rack-based asset packaging system that concatenates and
|
259
211
|
serves JavaScript, CoffeeScript, CSS, LESS, Sass, and SCSS.
|
260
212
|
email:
|
@@ -271,43 +223,49 @@ files:
|
|
271
223
|
- lib/rake/sprocketstask.rb
|
272
224
|
- lib/sprockets.rb
|
273
225
|
- lib/sprockets/asset.rb
|
274
|
-
- lib/sprockets/
|
226
|
+
- lib/sprockets/asset_uri.rb
|
275
227
|
- lib/sprockets/base.rb
|
276
|
-
- lib/sprockets/
|
228
|
+
- lib/sprockets/bower.rb
|
229
|
+
- lib/sprockets/bundle.rb
|
230
|
+
- lib/sprockets/cache.rb
|
277
231
|
- lib/sprockets/cache/file_store.rb
|
278
|
-
- lib/sprockets/
|
279
|
-
- lib/sprockets/
|
232
|
+
- lib/sprockets/cache/memory_store.rb
|
233
|
+
- lib/sprockets/cache/null_store.rb
|
234
|
+
- lib/sprockets/cached_environment.rb
|
280
235
|
- lib/sprockets/closure_compressor.rb
|
236
|
+
- lib/sprockets/coffee_script_template.rb
|
281
237
|
- lib/sprockets/compressing.rb
|
238
|
+
- lib/sprockets/configuration.rb
|
282
239
|
- lib/sprockets/context.rb
|
283
240
|
- lib/sprockets/directive_processor.rb
|
284
241
|
- lib/sprockets/eco_template.rb
|
285
242
|
- lib/sprockets/ejs_template.rb
|
243
|
+
- lib/sprockets/encoding_utils.rb
|
286
244
|
- lib/sprockets/engines.rb
|
287
245
|
- lib/sprockets/environment.rb
|
246
|
+
- lib/sprockets/erb_template.rb
|
288
247
|
- lib/sprockets/errors.rb
|
289
|
-
- lib/sprockets/
|
248
|
+
- lib/sprockets/http_utils.rb
|
290
249
|
- lib/sprockets/jst_processor.rb
|
250
|
+
- lib/sprockets/lazy_processor.rb
|
251
|
+
- lib/sprockets/legacy.rb
|
252
|
+
- lib/sprockets/legacy_proc_processor.rb
|
253
|
+
- lib/sprockets/legacy_tilt_processor.rb
|
291
254
|
- lib/sprockets/manifest.rb
|
292
255
|
- lib/sprockets/mime.rb
|
256
|
+
- lib/sprockets/path_utils.rb
|
293
257
|
- lib/sprockets/paths.rb
|
294
|
-
- lib/sprockets/processed_asset.rb
|
295
258
|
- lib/sprockets/processing.rb
|
296
|
-
- lib/sprockets/
|
297
|
-
- lib/sprockets/safety_colons.rb
|
298
|
-
- lib/sprockets/sass_cache_store.rb
|
259
|
+
- lib/sprockets/resolve.rb
|
299
260
|
- lib/sprockets/sass_compressor.rb
|
300
|
-
- lib/sprockets/sass_functions.rb
|
301
|
-
- lib/sprockets/sass_importer.rb
|
302
261
|
- lib/sprockets/sass_template.rb
|
303
|
-
- lib/sprockets/scss_template.rb
|
304
262
|
- lib/sprockets/server.rb
|
305
|
-
- lib/sprockets/
|
263
|
+
- lib/sprockets/transformers.rb
|
306
264
|
- lib/sprockets/uglifier_compressor.rb
|
307
265
|
- lib/sprockets/utils.rb
|
308
266
|
- lib/sprockets/version.rb
|
309
267
|
- lib/sprockets/yui_compressor.rb
|
310
|
-
homepage:
|
268
|
+
homepage: https://github.com/sstephenson/sprockets
|
311
269
|
licenses:
|
312
270
|
- MIT
|
313
271
|
metadata: {}
|
@@ -319,15 +277,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
319
277
|
requirements:
|
320
278
|
- - ">="
|
321
279
|
- !ruby/object:Gem::Version
|
322
|
-
version:
|
280
|
+
version: 1.9.3
|
323
281
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
324
282
|
requirements:
|
325
|
-
- - "
|
283
|
+
- - ">"
|
326
284
|
- !ruby/object:Gem::Version
|
327
|
-
version:
|
285
|
+
version: 1.3.1
|
328
286
|
requirements: []
|
329
287
|
rubyforge_project: sprockets
|
330
|
-
rubygems_version: 2.
|
288
|
+
rubygems_version: 2.2.2
|
331
289
|
signing_key:
|
332
290
|
specification_version: 4
|
333
291
|
summary: Rack-based asset packaging system
|
@@ -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
|