sprockets 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/sprockets/base.rb +18 -7
- data/lib/sprockets/cache/file_store.rb +6 -4
- data/lib/sprockets/cache/memory_store.rb +2 -2
- data/lib/sprockets/path_utils.rb +3 -1
- data/lib/sprockets/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e90597d41c004cb5a71036473da429c30f7fea114de88b48f8c5b0bbd1e82531
|
|
4
|
+
data.tar.gz: 496cf47db6004a4335fe2afa6e5c0c70f8322be6a57dbed5c7a4f1976717df93
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5665dc8d05a3aafbff29fe6287c9732f1b51a3dd5164a38d5ba0a289cd660a18ef061fdc3560f3f2b481da450beb5e0864279394e1f8164b859b0e15dafb531
|
|
7
|
+
data.tar.gz: 80a297f58bf9d94f4d78f21898477ffa2a7a9bf8f00d0cdb7d4a6351d0c28646cbcba97cdd491472fd329c170ca013bb9defe14fd5e43003eb1022377e396573
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md
|
|
4
4
|
|
|
5
|
+
## 4.4.0
|
|
6
|
+
|
|
7
|
+
- Implement `ignore_mtime` option. [#831](https://github.com/rails/sprockets/pull/832)
|
|
8
|
+
- Allow disabling cache limits. [#831](https://github.com/rails/sprockets/pull/831)
|
|
9
|
+
|
|
5
10
|
## 4.3.0
|
|
6
11
|
|
|
7
12
|
- Fixed compatibility with `json` 3+.
|
data/lib/sprockets/base.rb
CHANGED
|
@@ -55,6 +55,13 @@ module Sprockets
|
|
|
55
55
|
end
|
|
56
56
|
alias_method :index, :cached
|
|
57
57
|
|
|
58
|
+
# By default sprockets tries to quickly revalidate the cache for a source file
|
|
59
|
+
# by comparing its last modified time.
|
|
60
|
+
# This is efficient in development, but in some CI or producton environments
|
|
61
|
+
# where the source files are restored from version control, the last modified time
|
|
62
|
+
# tend to be somewhat random, and checking it is just needless overhead.
|
|
63
|
+
attr_accessor :ignore_mtime
|
|
64
|
+
|
|
58
65
|
# Internal: Compute digest for path.
|
|
59
66
|
#
|
|
60
67
|
# path - String filename or directory path.
|
|
@@ -62,14 +69,18 @@ module Sprockets
|
|
|
62
69
|
# Returns a String digest or nil.
|
|
63
70
|
def file_digest(path)
|
|
64
71
|
if stat = self.stat(path)
|
|
65
|
-
|
|
66
|
-
# for a files contents to have changed and its mtime to have been
|
|
67
|
-
# negligently reset thus appearing as if the file hasn't changed on
|
|
68
|
-
# disk. Also, the mtime is only read to the nearest second. It's
|
|
69
|
-
# also possible the file was updated more than once in a given second.
|
|
70
|
-
key = UnloadedAsset.new(path, self).file_digest_key(stat.mtime.to_i)
|
|
71
|
-
cache.fetch(key) do
|
|
72
|
+
if ignore_mtime
|
|
72
73
|
self.stat_digest(path, stat)
|
|
74
|
+
else
|
|
75
|
+
# Caveat: Digests are cached by the path's current mtime. Its possible
|
|
76
|
+
# for a files contents to have changed and its mtime to have been
|
|
77
|
+
# negligently reset thus appearing as if the file hasn't changed on
|
|
78
|
+
# disk. Also, the mtime is only read to the nearest second. It's
|
|
79
|
+
# also possible the file was updated more than once in a given second.
|
|
80
|
+
key = UnloadedAsset.new(path, self).file_digest_key(stat.mtime.to_i)
|
|
81
|
+
cache.fetch(key) do
|
|
82
|
+
self.stat_digest(path, stat)
|
|
83
|
+
end
|
|
73
84
|
end
|
|
74
85
|
end
|
|
75
86
|
end
|
|
@@ -36,13 +36,13 @@ module Sprockets
|
|
|
36
36
|
#
|
|
37
37
|
# root - A String path to a directory to persist cached values to.
|
|
38
38
|
# max_size - A Integer of the maximum size the store will hold (in bytes).
|
|
39
|
-
# (default: 25MB).
|
|
39
|
+
# (default: 25MB). Can be set to +false+ for no limit.
|
|
40
40
|
# logger - The logger to which some info will be printed.
|
|
41
41
|
# (default logger level is FATAL and won't output anything).
|
|
42
42
|
def initialize(root, max_size = DEFAULT_MAX_SIZE, logger = self.class.default_logger)
|
|
43
43
|
@root = root
|
|
44
44
|
@max_size = max_size
|
|
45
|
-
@gc_size = max_size * 0.75
|
|
45
|
+
@gc_size = max_size * 0.75 if max_size
|
|
46
46
|
@logger = logger
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -111,11 +111,13 @@ module Sprockets
|
|
|
111
111
|
# Write data
|
|
112
112
|
PathUtils.atomic_write(path) do |f|
|
|
113
113
|
f.write(raw)
|
|
114
|
-
@size
|
|
114
|
+
if defined?(@size) && !exists
|
|
115
|
+
@size += f.size
|
|
116
|
+
end
|
|
115
117
|
end
|
|
116
118
|
|
|
117
119
|
# GC if necessary
|
|
118
|
-
gc! if size > @max_size
|
|
120
|
+
gc! if @max_size && size > @max_size
|
|
119
121
|
|
|
120
122
|
value
|
|
121
123
|
end
|
|
@@ -18,7 +18,7 @@ module Sprockets
|
|
|
18
18
|
# Public: Initialize the cache store.
|
|
19
19
|
#
|
|
20
20
|
# max_size - A Integer of the maximum number of keys the store will hold.
|
|
21
|
-
# (default: 1000).
|
|
21
|
+
# (default: 1000). Can be set to +false+ for no limit.
|
|
22
22
|
def initialize(max_size = DEFAULT_MAX_SIZE)
|
|
23
23
|
@max_size = max_size
|
|
24
24
|
@cache = {}
|
|
@@ -56,7 +56,7 @@ module Sprockets
|
|
|
56
56
|
@mutex.synchronize do
|
|
57
57
|
@cache.delete(key)
|
|
58
58
|
@cache[key] = value
|
|
59
|
-
@cache.shift if @cache.size > @max_size
|
|
59
|
+
@cache.shift if @max_size && @cache.size > @max_size
|
|
60
60
|
end
|
|
61
61
|
value
|
|
62
62
|
end
|
data/lib/sprockets/path_utils.rb
CHANGED
|
@@ -91,6 +91,8 @@ module Sprockets
|
|
|
91
91
|
SEPARATOR_PATTERN = "#{Regexp.quote(File::SEPARATOR)}"
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
+
RELATIVE_PATH_PATTERN = /^\.\.?($|#{SEPARATOR_PATTERN})/
|
|
95
|
+
|
|
94
96
|
# Public: Check if path is explicitly relative.
|
|
95
97
|
# Starts with "./" or "../".
|
|
96
98
|
#
|
|
@@ -98,7 +100,7 @@ module Sprockets
|
|
|
98
100
|
#
|
|
99
101
|
# Returns true if path is relative, otherwise false.
|
|
100
102
|
def relative_path?(path)
|
|
101
|
-
path.match?(
|
|
103
|
+
path.match?(RELATIVE_PATH_PATTERN) ? true : false
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
# Public: Get relative path from `start` to `dest`.
|
data/lib/sprockets/version.rb
CHANGED