sprockets 3.0.0.rc.1 → 3.0.0.rc.2
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 +1 -0
- data/lib/sprockets/base.rb +1 -1
- data/lib/sprockets/configuration.rb +3 -0
- data/lib/sprockets/engines.rb +2 -4
- data/lib/sprockets/loader.rb +6 -6
- data/lib/sprockets/mime.rb +7 -5
- data/lib/sprockets/path_utils.rb +4 -2
- data/lib/sprockets/resolve.rb +1 -1
- data/lib/sprockets/transformers.rb +7 -2
- data/lib/sprockets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 927a7d3d329ad614ee230b94912d3d2f64979382
|
4
|
+
data.tar.gz: 1b150071ee5ed020e9d0b3a7006e1f5b5553f4fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e326e611bdb66495f10b43cf890c420710fc00c4ac1f9f3c57fd8fba89c087561a680ce1733a6dfcbc92ffdfae1fa715a1e00e0f90822ea6304d49cde98fa46
|
7
|
+
data.tar.gz: 1529cd2dda83604b3505e744b88f74f6f71ffcf37dbc23449e571c1391347ee89e36cf62e5c186c4ec18c1e27a3ffadb8bbbee3d6dfb7543fc54f2c03f27ceab
|
data/lib/sprockets.rb
CHANGED
data/lib/sprockets/base.rb
CHANGED
@@ -50,7 +50,7 @@ module Sprockets
|
|
50
50
|
# negligently reset thus appearing as if the file hasn't changed on
|
51
51
|
# disk. Also, the mtime is only read to the nearest second. Its
|
52
52
|
# also possible the file was updated more than once in a given second.
|
53
|
-
cache.fetch(
|
53
|
+
cache.fetch("file_digest:#{path}:#{stat.mtime.to_i}") do
|
54
54
|
self.stat_digest(path, stat)
|
55
55
|
end
|
56
56
|
end
|
@@ -13,12 +13,15 @@ module Sprockets
|
|
13
13
|
|
14
14
|
def initialize_configuration(parent)
|
15
15
|
@config = parent.config
|
16
|
+
@computed_config = parent.computed_config
|
16
17
|
@logger = parent.logger
|
17
18
|
@context_class = Class.new(parent.context_class)
|
18
19
|
end
|
19
20
|
|
20
21
|
attr_reader :config
|
21
22
|
|
23
|
+
attr_accessor :computed_config
|
24
|
+
|
22
25
|
def config=(config)
|
23
26
|
raise TypeError, "can't assign mutable config" unless config.frozen?
|
24
27
|
@config = config
|
data/lib/sprockets/engines.rb
CHANGED
@@ -53,6 +53,8 @@ module Sprockets
|
|
53
53
|
def register_engine(ext, klass, options = {})
|
54
54
|
ext = Sprockets::Utils.normalize_extension(ext)
|
55
55
|
|
56
|
+
self.computed_config = {}
|
57
|
+
|
56
58
|
if klass.respond_to?(:call)
|
57
59
|
processor = klass
|
58
60
|
self.config = hash_reassoc(config, :engines) do |engines|
|
@@ -74,10 +76,6 @@ module Sprockets
|
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
77
|
-
|
78
|
-
self.config = hash_reassoc(config, :_extnames) do
|
79
|
-
compute_extname_map
|
80
|
-
end
|
81
79
|
end
|
82
80
|
end
|
83
81
|
end
|
data/lib/sprockets/loader.rb
CHANGED
@@ -26,15 +26,15 @@ module Sprockets
|
|
26
26
|
def load(uri)
|
27
27
|
filename, params = parse_asset_uri(uri)
|
28
28
|
if params.key?(:id)
|
29
|
-
asset = cache.fetch(
|
29
|
+
asset = cache.fetch("asset-uri:#{VERSION}#{uri}") do
|
30
30
|
load_asset_by_id_uri(uri, filename, params)
|
31
31
|
end
|
32
32
|
else
|
33
33
|
asset = fetch_asset_from_dependency_cache(uri, filename) do |paths|
|
34
34
|
if paths
|
35
35
|
digest = digest(resolve_dependencies(paths))
|
36
|
-
if id_uri = cache.get(
|
37
|
-
cache.get(
|
36
|
+
if id_uri = cache.get("asset-uri-digest:#{VERSION}:#{uri}:#{digest}", true)
|
37
|
+
cache.get("asset-uri:#{VERSION}:#{id_uri}", true)
|
38
38
|
end
|
39
39
|
else
|
40
40
|
load_asset_by_uri(uri, filename, params)
|
@@ -150,14 +150,14 @@ module Sprockets
|
|
150
150
|
end
|
151
151
|
}.max
|
152
152
|
|
153
|
-
cache.set(
|
154
|
-
cache.set(
|
153
|
+
cache.set("asset-uri:#{VERSION}:#{asset[:uri]}", asset, true)
|
154
|
+
cache.set("asset-uri-digest:#{VERSION}:#{uri}:#{asset[:dependencies_digest]}", asset[:uri], true)
|
155
155
|
|
156
156
|
asset
|
157
157
|
end
|
158
158
|
|
159
159
|
def fetch_asset_from_dependency_cache(uri, filename, limit = 3)
|
160
|
-
key =
|
160
|
+
key = "asset-uri-cache-dependencies:#{VERSION}:#{uri}:#{file_digest(filename)}"
|
161
161
|
history = cache.get(key) || []
|
162
162
|
|
163
163
|
history.each_with_index do |deps, index|
|
data/lib/sprockets/mime.rb
CHANGED
@@ -57,6 +57,8 @@ module Sprockets
|
|
57
57
|
charset ||= :default if mime_type.start_with?('text/')
|
58
58
|
charset = EncodingUtils::CHARSET_DETECT[charset] if charset.is_a?(Symbol)
|
59
59
|
|
60
|
+
self.computed_config = {}
|
61
|
+
|
60
62
|
self.config = hash_reassoc(config, :mime_exts) do |mime_exts|
|
61
63
|
extnames.each do |extname|
|
62
64
|
mime_exts[extname] = mime_type
|
@@ -69,10 +71,6 @@ module Sprockets
|
|
69
71
|
type[:charset] = charset if charset
|
70
72
|
mime_types.merge(mime_type => type)
|
71
73
|
end
|
72
|
-
|
73
|
-
self.config = hash_reassoc(config, :_extnames) do
|
74
|
-
compute_extname_map
|
75
|
-
end
|
76
74
|
end
|
77
75
|
|
78
76
|
# Internal: Get detecter function for MIME type.
|
@@ -106,13 +104,17 @@ module Sprockets
|
|
106
104
|
end
|
107
105
|
|
108
106
|
private
|
107
|
+
def extname_map
|
108
|
+
self.computed_config[:_extnames] ||= compute_extname_map
|
109
|
+
end
|
110
|
+
|
109
111
|
def compute_extname_map
|
110
112
|
graph = {}
|
111
113
|
|
112
114
|
([nil] + pipelines.keys.map(&:to_s)).each do |pipeline|
|
113
115
|
pipeline_extname = ".#{pipeline}" if pipeline
|
114
116
|
([[nil, nil]] + config[:mime_exts].to_a).each do |format_extname, format_type|
|
115
|
-
|
117
|
+
4.times do |n|
|
116
118
|
config[:engines].keys.permutation(n).each do |engine_extnames|
|
117
119
|
key = "#{pipeline_extname}#{format_extname}#{engine_extnames.join}"
|
118
120
|
type = format_type || config[:engine_mime_types][engine_extnames.first]
|
data/lib/sprockets/path_utils.rb
CHANGED
@@ -261,12 +261,14 @@ module Sprockets
|
|
261
261
|
#
|
262
262
|
# Returns nothing.
|
263
263
|
def atomic_write(filename)
|
264
|
-
|
265
|
-
|
264
|
+
dirname, basename = File.split(filename)
|
265
|
+
basename = [
|
266
|
+
basename,
|
266
267
|
Thread.current.object_id,
|
267
268
|
Process.pid,
|
268
269
|
rand(1000000)
|
269
270
|
].join('.')
|
271
|
+
tmpname = File.join(dirname, basename)
|
270
272
|
|
271
273
|
File.open(tmpname, 'wb+') do |f|
|
272
274
|
yield f
|
data/lib/sprockets/resolve.rb
CHANGED
@@ -94,17 +94,22 @@ module Sprockets
|
|
94
94
|
raise ArgumentError, "too few transform types: #{types.inspect}"
|
95
95
|
end
|
96
96
|
|
97
|
+
i = 0
|
97
98
|
processors = []
|
98
|
-
enum = types.each
|
99
99
|
|
100
100
|
loop do
|
101
|
-
src
|
101
|
+
src = types[i]
|
102
|
+
dst = types[i+1]
|
103
|
+
break unless src && dst
|
104
|
+
|
102
105
|
unless processor = transformers[src][dst]
|
103
106
|
raise ArgumentError, "missing transformer for type: #{src} to #{dst}"
|
104
107
|
end
|
105
108
|
processors.concat config[:postprocessors][src]
|
106
109
|
processors << processor
|
107
110
|
processors.concat config[:preprocessors][dst]
|
111
|
+
|
112
|
+
i += 1
|
108
113
|
end
|
109
114
|
|
110
115
|
if processors.size > 1
|
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.rc.
|
4
|
+
version: 3.0.0.rc.2
|
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: 2015-
|
12
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|