sprockets 3.0.3 → 3.1.0
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 +4 -4
- data/lib/sprockets/cache.rb +1 -1
- data/lib/sprockets/closure_compressor.rb +3 -10
- data/lib/sprockets/coffee_script_processor.rb +2 -2
- data/lib/sprockets/digest_utils.rb +3 -8
- data/lib/sprockets/eco_processor.rb +2 -2
- data/lib/sprockets/ejs_processor.rb +2 -2
- data/lib/sprockets/legacy.rb +16 -0
- data/lib/sprockets/loader.rb +1 -2
- data/lib/sprockets/manifest.rb +6 -2
- data/lib/sprockets/resolve.rb +0 -6
- data/lib/sprockets/sass_compressor.rb +9 -17
- data/lib/sprockets/sass_processor.rb +1 -6
- data/lib/sprockets/uglifier_compressor.rb +3 -11
- data/lib/sprockets/uri_utils.rb +0 -3
- data/lib/sprockets/version.rb +1 -1
- data/lib/sprockets/yui_compressor.rb +4 -14
- 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: 903635fd1ccad435c06561c0d825f78aae55f281
|
4
|
+
data.tar.gz: 65c2850077f1066e37b98e1be0ead819c3ce096f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee9453dfe28d48cdd749e3457ad244289641d4c8d0fcc7bb3912b8db3889d5a1a90298341f93767bcd2994041ee6ad3b2c024772f2450112197c41733706fc48
|
7
|
+
data.tar.gz: ddf7f195f3e04ed21b8416dc6312d1a2daaf896af1fa45c67427c0e03a55f0def0c3f7bb1aa96798269fef046dfebf627fcd6ee8314969683ef59c33ead8b507
|
data/lib/sprockets/cache.rb
CHANGED
@@ -60,7 +60,7 @@ module Sprockets
|
|
60
60
|
# cache - A compatible backend cache store instance.
|
61
61
|
def initialize(cache = nil, logger = self.class.default_logger)
|
62
62
|
@cache_wrapper = get_cache_wrapper(cache)
|
63
|
-
@fetch_cache = Cache::MemoryStore.new(
|
63
|
+
@fetch_cache = Cache::MemoryStore.new(1024)
|
64
64
|
@logger = logger
|
65
65
|
end
|
66
66
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'sprockets/autoload'
|
2
|
+
require 'sprockets/digest_utils'
|
2
3
|
|
3
4
|
module Sprockets
|
4
5
|
# Public: Closure Compiler minifier.
|
@@ -35,19 +36,11 @@ module Sprockets
|
|
35
36
|
|
36
37
|
def initialize(options = {})
|
37
38
|
@compiler = Autoload::Closure::Compiler.new(options)
|
38
|
-
@cache_key =
|
39
|
-
self.class.name,
|
40
|
-
Autoload::Closure::VERSION,
|
41
|
-
Autoload::Closure::COMPILER_VERSION,
|
42
|
-
VERSION,
|
43
|
-
options
|
44
|
-
].freeze
|
39
|
+
@cache_key = "#{self.class.name}:#{Autoload::Closure::VERSION}:#{Autoload::Closure::COMPILER_VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
|
45
40
|
end
|
46
41
|
|
47
42
|
def call(input)
|
48
|
-
|
49
|
-
@compiler.compile(input[:data])
|
50
|
-
end
|
43
|
+
@compiler.compile(input[:data])
|
51
44
|
end
|
52
45
|
end
|
53
46
|
end
|
@@ -12,12 +12,12 @@ module Sprockets
|
|
12
12
|
VERSION = '1'
|
13
13
|
|
14
14
|
def self.cache_key
|
15
|
-
@cache_key ||=
|
15
|
+
@cache_key ||= "#{name}:#{Autoload::CoffeeScript::Source.version}:#{VERSION}".freeze
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.call(input)
|
19
19
|
data = input[:data]
|
20
|
-
input[:cache].fetch(self.cache_key
|
20
|
+
input[:cache].fetch([self.cache_key, data]) do
|
21
21
|
Autoload::CoffeeScript.compile(data)
|
22
22
|
end
|
23
23
|
end
|
@@ -129,13 +129,10 @@ module Sprockets
|
|
129
129
|
# Internal: Generate a "named information" URI for use in the `integrity`
|
130
130
|
# attribute of an asset tag as per the subresource integrity specification.
|
131
131
|
#
|
132
|
-
# digest
|
133
|
-
# content_type - The content-type the asset will be served with. This *must*
|
134
|
-
# be accurate if provided. Otherwise, subresource integrity
|
135
|
-
# will block the loading of the asset.
|
132
|
+
# digest - The String byte digest of the asset content.
|
136
133
|
#
|
137
134
|
# Returns a String or nil if hash algorithm is incompatible.
|
138
|
-
def integrity_uri(digest
|
135
|
+
def integrity_uri(digest)
|
139
136
|
case digest
|
140
137
|
when Digest::Base
|
141
138
|
digest_class = digest.class
|
@@ -147,9 +144,7 @@ module Sprockets
|
|
147
144
|
end
|
148
145
|
|
149
146
|
if hash_name = NI_HASH_ALGORITHMS[digest_class]
|
150
|
-
|
151
|
-
uri << "?ct=#{content_type}" if content_type
|
152
|
-
uri
|
147
|
+
"#{hash_name}-#{pack_base64digest(digest)}"
|
153
148
|
end
|
154
149
|
end
|
155
150
|
end
|
@@ -12,7 +12,7 @@ module Sprockets
|
|
12
12
|
VERSION = '1'
|
13
13
|
|
14
14
|
def self.cache_key
|
15
|
-
@cache_key ||=
|
15
|
+
@cache_key ||= "#{name}:#{Autoload::Eco::Source::VERSION}:#{VERSION}".freeze
|
16
16
|
end
|
17
17
|
|
18
18
|
# Compile template data with Eco compiler.
|
@@ -24,7 +24,7 @@ module Sprockets
|
|
24
24
|
#
|
25
25
|
def self.call(input)
|
26
26
|
data = input[:data]
|
27
|
-
input[:cache].fetch(cache_key
|
27
|
+
input[:cache].fetch([cache_key, data]) do
|
28
28
|
Autoload::Eco.compile(data)
|
29
29
|
end
|
30
30
|
end
|
@@ -11,7 +11,7 @@ module Sprockets
|
|
11
11
|
VERSION = '1'
|
12
12
|
|
13
13
|
def self.cache_key
|
14
|
-
@cache_key ||=
|
14
|
+
@cache_key ||= "#{name}:#{VERSION}".freeze
|
15
15
|
end
|
16
16
|
|
17
17
|
# Compile template data with EJS compiler.
|
@@ -23,7 +23,7 @@ module Sprockets
|
|
23
23
|
#
|
24
24
|
def self.call(input)
|
25
25
|
data = input[:data]
|
26
|
-
input[:cache].fetch(cache_key
|
26
|
+
input[:cache].fetch([cache_key, data]) do
|
27
27
|
Autoload::EJS.compile(data)
|
28
28
|
end
|
29
29
|
end
|
data/lib/sprockets/legacy.rb
CHANGED
@@ -128,6 +128,12 @@ module Sprockets
|
|
128
128
|
cache.set(key, value)
|
129
129
|
end
|
130
130
|
|
131
|
+
def normalize_logical_path(path)
|
132
|
+
dirname, basename = File.split(path)
|
133
|
+
path = dirname if basename == 'index'
|
134
|
+
path
|
135
|
+
end
|
136
|
+
|
131
137
|
private
|
132
138
|
# Deprecated: Seriously.
|
133
139
|
def matches_filter(filters, logical_path, filename)
|
@@ -297,6 +303,16 @@ module Sprockets
|
|
297
303
|
str !~ /\*|\*\*|\?|\[|\]|\{|\}/
|
298
304
|
end
|
299
305
|
|
306
|
+
def self.compute_alias_logical_path(path)
|
307
|
+
dirname, basename = File.split(path)
|
308
|
+
extname = File.extname(basename)
|
309
|
+
if File.basename(basename, extname) == 'index'
|
310
|
+
"#{dirname}#{extname}"
|
311
|
+
else
|
312
|
+
nil
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
300
316
|
# Deprecated: Filter logical paths in environment. Useful for selecting what
|
301
317
|
# files you want to compile.
|
302
318
|
#
|
data/lib/sprockets/loader.rb
CHANGED
@@ -62,7 +62,6 @@ module Sprockets
|
|
62
62
|
end
|
63
63
|
|
64
64
|
logical_path, file_type, engine_extnames, _ = parse_path_extnames(logical_path)
|
65
|
-
logical_path = normalize_logical_path(logical_path)
|
66
65
|
name = logical_path
|
67
66
|
|
68
67
|
if pipeline = params[:pipeline]
|
@@ -119,7 +118,7 @@ module Sprockets
|
|
119
118
|
content_type: type,
|
120
119
|
source: source,
|
121
120
|
metadata: metadata,
|
122
|
-
integrity: integrity_uri(metadata[:digest]
|
121
|
+
integrity: integrity_uri(metadata[:digest]),
|
123
122
|
dependencies_digest: digest(resolve_dependencies(metadata[:dependencies]))
|
124
123
|
}
|
125
124
|
|
data/lib/sprockets/manifest.rb
CHANGED
@@ -169,6 +169,10 @@ module Sprockets
|
|
169
169
|
}
|
170
170
|
assets[asset.logical_path] = asset.digest_path
|
171
171
|
|
172
|
+
if alias_logical_path = self.class.compute_alias_logical_path(asset.logical_path)
|
173
|
+
assets[alias_logical_path] = asset.digest_path
|
174
|
+
end
|
175
|
+
|
172
176
|
target = File.join(dir, asset.digest_path)
|
173
177
|
|
174
178
|
if File.exist?(target)
|
@@ -230,9 +234,9 @@ module Sprockets
|
|
230
234
|
# Sort by timestamp
|
231
235
|
Time.parse(attrs['mtime'])
|
232
236
|
}.reverse.each_with_index.drop_while { |(_, attrs), index|
|
233
|
-
|
237
|
+
_age = [0, Time.now - Time.parse(attrs['mtime'])].max
|
234
238
|
# Keep if under age or within the count limit
|
235
|
-
|
239
|
+
_age < age || index < count
|
236
240
|
}.each { |(path, _), _|
|
237
241
|
# Remove old assets
|
238
242
|
remove(path)
|
data/lib/sprockets/resolve.rb
CHANGED
@@ -151,12 +151,6 @@ module Sprockets
|
|
151
151
|
accepts
|
152
152
|
end
|
153
153
|
|
154
|
-
def normalize_logical_path(path)
|
155
|
-
dirname, basename = File.split(path)
|
156
|
-
path = dirname if basename == 'index'
|
157
|
-
path
|
158
|
-
end
|
159
|
-
|
160
154
|
def path_matches(load_path, logical_name, logical_basename)
|
161
155
|
dirname = File.dirname(File.join(load_path, logical_name))
|
162
156
|
candidates = dirname_matches(dirname, logical_basename)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'sprockets/autoload'
|
2
|
+
require 'sprockets/digest_utils'
|
2
3
|
|
3
4
|
module Sprockets
|
4
5
|
# Public: Sass CSS minifier.
|
@@ -34,26 +35,17 @@ module Sprockets
|
|
34
35
|
attr_reader :cache_key
|
35
36
|
|
36
37
|
def initialize(options = {})
|
37
|
-
@options =
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
@options = {
|
39
|
+
syntax: :scss,
|
40
|
+
cache: false,
|
41
|
+
read_cache: false,
|
42
|
+
style: :compressed
|
43
|
+
}.merge(options).freeze
|
44
|
+
@cache_key = "#{self.class.name}:#{Autoload::Sass::VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
|
44
45
|
end
|
45
46
|
|
46
47
|
def call(input)
|
47
|
-
|
48
|
-
input[:cache].fetch(@cache_key + [data]) do
|
49
|
-
options = {
|
50
|
-
syntax: :scss,
|
51
|
-
cache: false,
|
52
|
-
read_cache: false,
|
53
|
-
style: :compressed
|
54
|
-
}.merge(@options)
|
55
|
-
Autoload::Sass::Engine.new(data, options).render
|
56
|
-
end
|
48
|
+
Autoload::Sass::Engine.new(input[:data], @options).render
|
57
49
|
end
|
58
50
|
end
|
59
51
|
end
|
@@ -44,12 +44,7 @@ module Sprockets
|
|
44
44
|
#
|
45
45
|
def initialize(options = {}, &block)
|
46
46
|
@cache_version = options[:cache_version]
|
47
|
-
@cache_key =
|
48
|
-
self.class.name,
|
49
|
-
VERSION,
|
50
|
-
Autoload::Sass::VERSION,
|
51
|
-
@cache_version
|
52
|
-
].freeze
|
47
|
+
@cache_key = "#{self.class.name}:#{VERSION}:#{Autoload::Sass::VERSION}:#{@cache_version}".freeze
|
53
48
|
|
54
49
|
@functions = Module.new do
|
55
50
|
include Functions
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'sprockets/autoload'
|
2
|
+
require 'sprockets/digest_utils'
|
2
3
|
|
3
4
|
module Sprockets
|
4
5
|
# Public: Uglifier/Uglify compressor.
|
@@ -44,20 +45,11 @@ module Sprockets
|
|
44
45
|
end
|
45
46
|
|
46
47
|
@uglifier = Autoload::Uglifier.new(options)
|
47
|
-
|
48
|
-
@cache_key = [
|
49
|
-
self.class.name,
|
50
|
-
Autoload::Uglifier::VERSION,
|
51
|
-
VERSION,
|
52
|
-
options
|
53
|
-
].freeze
|
48
|
+
@cache_key = "#{self.class.name}:#{Autoload::Uglifier::VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
|
54
49
|
end
|
55
50
|
|
56
51
|
def call(input)
|
57
|
-
|
58
|
-
input[:cache].fetch(@cache_key + [data]) do
|
59
|
-
@uglifier.compile(data)
|
60
|
-
end
|
52
|
+
@uglifier.compile(input[:data])
|
61
53
|
end
|
62
54
|
end
|
63
55
|
end
|
data/lib/sprockets/uri_utils.rb
CHANGED
data/lib/sprockets/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'sprockets/autoload'
|
2
|
+
require 'sprockets/digest_utils'
|
2
3
|
|
3
4
|
module Sprockets
|
4
5
|
# Public: YUI compressor.
|
@@ -35,12 +36,7 @@ module Sprockets
|
|
35
36
|
|
36
37
|
def initialize(options = {})
|
37
38
|
@options = options
|
38
|
-
@cache_key =
|
39
|
-
self.class.name,
|
40
|
-
Autoload::YUI::Compressor::VERSION,
|
41
|
-
VERSION,
|
42
|
-
options
|
43
|
-
].freeze
|
39
|
+
@cache_key = "#{self.class.name}:#{Autoload::YUI::Compressor::VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
|
44
40
|
end
|
45
41
|
|
46
42
|
def call(input)
|
@@ -48,15 +44,9 @@ module Sprockets
|
|
48
44
|
|
49
45
|
case input[:content_type]
|
50
46
|
when 'application/javascript'
|
51
|
-
|
52
|
-
input[:cache].fetch(key) do
|
53
|
-
Autoload::YUI::JavaScriptCompressor.new(@options).compress(data)
|
54
|
-
end
|
47
|
+
Autoload::YUI::JavaScriptCompressor.new(@options).compress(data)
|
55
48
|
when 'text/css'
|
56
|
-
|
57
|
-
input[:cache].fetch(key) do
|
58
|
-
Autoload::YUI::CssCompressor.new(@options).compress(data)
|
59
|
-
end
|
49
|
+
Autoload::YUI::CssCompressor.new(@options).compress(data)
|
60
50
|
else
|
61
51
|
data
|
62
52
|
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: 3.0
|
4
|
+
version: 3.1.0
|
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-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|