sprockets 3.0.0.beta.3 → 3.0.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sprockets.rb +22 -19
- data/lib/sprockets/asset.rb +24 -12
- data/lib/sprockets/asset_uri.rb +0 -1
- data/lib/sprockets/base.rb +14 -127
- data/lib/sprockets/bundle.rb +9 -2
- data/lib/sprockets/cached_environment.rb +35 -16
- data/lib/sprockets/configuration.rb +19 -18
- data/lib/sprockets/context.rb +41 -20
- data/lib/sprockets/directive_processor.rb +36 -19
- data/lib/sprockets/environment.rb +1 -0
- data/lib/sprockets/legacy.rb +67 -0
- data/lib/sprockets/loader.rb +168 -0
- data/lib/sprockets/mime.rb +1 -4
- data/lib/sprockets/path_digest_utils.rb +47 -0
- data/lib/sprockets/path_utils.rb +22 -0
- data/lib/sprockets/paths.rb +21 -0
- data/lib/sprockets/processing.rb +4 -48
- data/lib/sprockets/resolve.rb +73 -181
- data/lib/sprockets/transformers.rb +36 -2
- data/lib/sprockets/version.rb +1 -1
- metadata +4 -2
@@ -10,6 +10,16 @@ module Sprockets
|
|
10
10
|
#
|
11
11
|
attr_reader :transformers
|
12
12
|
|
13
|
+
# Public: Two level mapping of target mime type to source mime type.
|
14
|
+
#
|
15
|
+
# environment.inverted_transformers
|
16
|
+
# # => { 'application/javascript' => {
|
17
|
+
# 'text/coffeescript' => ConvertCoffeeScriptToJavaScript
|
18
|
+
# }
|
19
|
+
# }
|
20
|
+
#
|
21
|
+
attr_reader :inverted_transformers
|
22
|
+
|
13
23
|
# Public: Register a transformer from and to a mime type.
|
14
24
|
#
|
15
25
|
# from - String mime type
|
@@ -28,9 +38,12 @@ module Sprockets
|
|
28
38
|
mutate_hash_config(:transformers, from) do |transformers|
|
29
39
|
transformers.merge(to => proc)
|
30
40
|
end
|
41
|
+
mutate_hash_config(:inverted_transformers, to) do |transformers|
|
42
|
+
transformers.merge(from => proc)
|
43
|
+
end
|
31
44
|
end
|
32
45
|
|
33
|
-
#
|
46
|
+
# Internal: Resolve target mime type that the source type should be
|
34
47
|
# transformed to.
|
35
48
|
#
|
36
49
|
# type - String from mime type
|
@@ -48,10 +61,31 @@ module Sprockets
|
|
48
61
|
# # => nil
|
49
62
|
#
|
50
63
|
# Returns String mime type or nil is no type satisfied the accept value.
|
51
|
-
def resolve_transform_type(type, accept
|
64
|
+
def resolve_transform_type(type, accept)
|
52
65
|
find_best_mime_type_match(accept || '*/*', [type].compact + transformers[type].keys)
|
53
66
|
end
|
54
67
|
|
68
|
+
# Internal: Expand accept type list to include possible transformed types.
|
69
|
+
#
|
70
|
+
# parsed_accepts - Array of accept q values
|
71
|
+
#
|
72
|
+
# Examples
|
73
|
+
#
|
74
|
+
# expand_transform_accepts([['application/javascript', 1.0]])
|
75
|
+
# # => [['application/javascript', 1.0], ['text/coffeescript', 0.8]]
|
76
|
+
#
|
77
|
+
# Returns an expanded Array of q values.
|
78
|
+
def expand_transform_accepts(parsed_accepts)
|
79
|
+
accepts = []
|
80
|
+
parsed_accepts.each do |(type, q)|
|
81
|
+
accepts.push([type, q])
|
82
|
+
inverted_transformers[type].keys.each do |subtype|
|
83
|
+
accepts.push([subtype, q * 0.8])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
accepts
|
87
|
+
end
|
88
|
+
|
55
89
|
# Internal: Find and load transformer by from and to mime type.
|
56
90
|
#
|
57
91
|
# from - String mime type
|
data/lib/sprockets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.beta.
|
4
|
+
version: 3.0.0.beta.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -252,8 +252,10 @@ files:
|
|
252
252
|
- lib/sprockets/legacy.rb
|
253
253
|
- lib/sprockets/legacy_proc_processor.rb
|
254
254
|
- lib/sprockets/legacy_tilt_processor.rb
|
255
|
+
- lib/sprockets/loader.rb
|
255
256
|
- lib/sprockets/manifest.rb
|
256
257
|
- lib/sprockets/mime.rb
|
258
|
+
- lib/sprockets/path_digest_utils.rb
|
257
259
|
- lib/sprockets/path_utils.rb
|
258
260
|
- lib/sprockets/paths.rb
|
259
261
|
- lib/sprockets/processing.rb
|