activesupport 6.0.0.rc1 → 6.0.3.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +165 -2
- data/README.rdoc +1 -1
- data/lib/active_support/backtrace_cleaner.rb +0 -1
- data/lib/active_support/cache.rb +29 -28
- data/lib/active_support/cache/file_store.rb +7 -8
- data/lib/active_support/cache/mem_cache_store.rb +8 -8
- data/lib/active_support/cache/memory_store.rb +8 -7
- data/lib/active_support/cache/null_store.rb +3 -3
- data/lib/active_support/cache/redis_cache_store.rb +8 -8
- data/lib/active_support/cache/strategy/local_cache.rb +23 -23
- data/lib/active_support/callbacks.rb +0 -3
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
- data/lib/active_support/concurrency/share_lock.rb +0 -1
- data/lib/active_support/core_ext/array/conversions.rb +5 -5
- data/lib/active_support/core_ext/date_and_time/calculations.rb +0 -30
- data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
- data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
- data/lib/active_support/core_ext/digest.rb +3 -0
- data/lib/active_support/core_ext/hash/conversions.rb +1 -1
- data/lib/active_support/core_ext/hash/deep_transform_values.rb +2 -2
- data/lib/active_support/core_ext/module/delegation.rb +14 -1
- data/lib/active_support/core_ext/module/introspection.rb +1 -0
- data/lib/active_support/core_ext/object/duplicable.rb +7 -117
- data/lib/active_support/core_ext/object/try.rb +2 -0
- data/lib/active_support/core_ext/range/compare_range.rb +9 -3
- data/lib/active_support/core_ext/range/each.rb +0 -1
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +2 -2
- data/lib/active_support/core_ext/string/filters.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +2 -1
- data/lib/active_support/core_ext/time/calculations.rb +30 -0
- data/lib/active_support/dependencies.rb +35 -6
- data/lib/active_support/dependencies/zeitwerk_integration.rb +22 -4
- data/lib/active_support/deprecation/method_wrappers.rb +12 -6
- data/lib/active_support/deprecation/proxy_wrappers.rb +28 -3
- data/lib/active_support/descendants_tracker.rb +0 -1
- data/lib/active_support/duration.rb +15 -13
- data/lib/active_support/duration/iso8601_parser.rb +0 -1
- data/lib/active_support/duration/iso8601_serializer.rb +0 -1
- data/lib/active_support/encrypted_file.rb +1 -1
- data/lib/active_support/evented_file_update_checker.rb +11 -2
- data/lib/active_support/file_update_checker.rb +0 -1
- data/lib/active_support/gem_version.rb +1 -1
- data/lib/active_support/i18n_railtie.rb +4 -0
- data/lib/active_support/inflector/inflections.rb +0 -1
- data/lib/active_support/inflector/methods.rb +1 -2
- data/lib/active_support/inflector/transliterate.rb +27 -1
- data/lib/active_support/json/decoding.rb +0 -1
- data/lib/active_support/lazy_load_hooks.rb +0 -1
- data/lib/active_support/locale/en.rb +4 -2
- data/lib/active_support/log_subscriber.rb +0 -1
- data/lib/active_support/logger.rb +1 -1
- data/lib/active_support/logger_thread_safe_level.rb +2 -1
- data/lib/active_support/message_encryptor.rb +1 -1
- data/lib/active_support/message_verifier.rb +2 -2
- data/lib/active_support/messages/metadata.rb +3 -2
- data/lib/active_support/messages/rotator.rb +4 -4
- data/lib/active_support/multibyte/chars.rb +1 -2
- data/lib/active_support/multibyte/unicode.rb +0 -1
- data/lib/active_support/notifications/fanout.rb +2 -2
- data/lib/active_support/notifications/instrumenter.rb +4 -4
- data/lib/active_support/number_helper.rb +4 -0
- data/lib/active_support/number_helper/number_converter.rb +4 -5
- data/lib/active_support/number_helper/number_to_currency_converter.rb +7 -8
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_human_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +0 -1
- data/lib/active_support/option_merger.rb +21 -3
- data/lib/active_support/ordered_hash.rb +1 -1
- data/lib/active_support/ordered_options.rb +5 -1
- data/lib/active_support/parameter_filter.rb +7 -3
- data/lib/active_support/string_inquirer.rb +0 -1
- data/lib/active_support/testing/parallelization.rb +16 -2
- data/lib/active_support/testing/stream.rb +0 -1
- data/lib/active_support/testing/time_helpers.rb +0 -2
- data/lib/active_support/xml_mini.rb +0 -1
- data/lib/active_support/xml_mini/jdom.rb +0 -1
- metadata +13 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9a3640584c7bec116a2753b05a7bce56fe1f8c20792cd0a203c27b7f32cbc4c
|
4
|
+
data.tar.gz: 4250f2f8de4fd670f64fd3bb7b92c35cf494ad54bc8bc7aa6e9e37509ae49892
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebeefc050565be0566159148f0e4fdcf1735c0538f8b3c79f7f865522497284e7c298929b9d78c2f60bda713323ae3fe8119a2b52578f3679e992538b1cb318f
|
7
|
+
data.tar.gz: 102293ec9dbc84dbff803c972960684d73edb62b06e8028618825976ee83e90629bc8075ba66f21837dc322568b053f2063a3935d11a14e02d885a72a1dc5ba3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,166 @@
|
|
1
|
+
## Rails 6.0.3.rc1 (April 30, 2020) ##
|
2
|
+
|
3
|
+
* `Array#to_sentence` no longer returns a frozen string.
|
4
|
+
|
5
|
+
Before:
|
6
|
+
|
7
|
+
['one', 'two'].to_sentence.frozen?
|
8
|
+
# => true
|
9
|
+
|
10
|
+
After:
|
11
|
+
|
12
|
+
['one', 'two'].to_sentence.frozen?
|
13
|
+
# => false
|
14
|
+
|
15
|
+
*Nicolas Dular*
|
16
|
+
|
17
|
+
* Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
|
18
|
+
`ActiveSupport.parse_json_times = true`.
|
19
|
+
|
20
|
+
*Christian Gregg*
|
21
|
+
|
22
|
+
|
23
|
+
## Rails 6.0.2.2 (March 19, 2020) ##
|
24
|
+
|
25
|
+
* No changes.
|
26
|
+
|
27
|
+
|
28
|
+
## Rails 6.0.2.1 (December 18, 2019) ##
|
29
|
+
|
30
|
+
* No changes.
|
31
|
+
|
32
|
+
|
33
|
+
## Rails 6.0.2 (December 13, 2019) ##
|
34
|
+
|
35
|
+
* Eager load translations during initialization.
|
36
|
+
|
37
|
+
*Diego Plentz*
|
38
|
+
|
39
|
+
* Use per-thread CPU time clock on `ActiveSupport::Notifications`.
|
40
|
+
|
41
|
+
*George Claghorn*
|
42
|
+
|
43
|
+
|
44
|
+
## Rails 6.0.1 (November 5, 2019) ##
|
45
|
+
|
46
|
+
* `ActiveSupport::SafeBuffer` supports `Enumerator` methods.
|
47
|
+
|
48
|
+
*Shugo Maeda*
|
49
|
+
|
50
|
+
* The Redis cache store fails gracefully when the server returns a "max number
|
51
|
+
of clients reached" error.
|
52
|
+
|
53
|
+
*Brandon Medenwald*
|
54
|
+
|
55
|
+
* Fixed that mutating a value returned by a memory cache store would
|
56
|
+
unexpectedly change the cached value.
|
57
|
+
|
58
|
+
*Jonathan Hyman*
|
59
|
+
|
60
|
+
* The default inflectors in `zeitwerk` mode support overrides:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
# config/initializers/zeitwerk.rb
|
64
|
+
Rails.autoloaders.each do |autoloader|
|
65
|
+
autoloader.inflector.inflect(
|
66
|
+
"html_parser" => "HTMLParser",
|
67
|
+
"ssl_error" => "SSLError"
|
68
|
+
)
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
That way, you can tweak how individual basenames are inflected without touching Active Support inflection rules, which are global. These inflectors fallback to `String#camelize`, so existing inflection rules are still taken into account for non-overridden basenames.
|
73
|
+
|
74
|
+
Please, check the [autoloading guide for `zeitwerk` mode](https://guides.rubyonrails.org/v6.0/autoloading_and_reloading_constants.html#customizing-inflections) if you prefer not to depend on `String#camelize` at all.
|
75
|
+
|
76
|
+
*Xavier Noria*
|
77
|
+
|
78
|
+
* Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
|
79
|
+
and endless range targets.
|
80
|
+
|
81
|
+
*Allen Hsu*, *Andrew Hodgkinson*
|
82
|
+
|
83
|
+
* Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
|
84
|
+
|
85
|
+
*Iain Beeston*
|
86
|
+
|
87
|
+
|
88
|
+
## Rails 6.0.0 (August 16, 2019) ##
|
89
|
+
|
90
|
+
* Let `require_dependency` in `zeitwerk` mode look the autoload paths up for
|
91
|
+
better backwards compatibility.
|
92
|
+
|
93
|
+
*Xavier Noria*
|
94
|
+
|
95
|
+
* Let `require_dependency` in `zeitwerk` mode support arguments that respond
|
96
|
+
to `to_path` for better backwards compatibility.
|
97
|
+
|
98
|
+
*Xavier Noria*
|
99
|
+
|
100
|
+
* Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
|
101
|
+
|
102
|
+
Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
|
103
|
+
to make log level local to Ruby Fibers in addition to Threads.
|
104
|
+
|
105
|
+
Example:
|
106
|
+
|
107
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
108
|
+
logger.level = 1
|
109
|
+
p "Main is debug? #{logger.debug?}"
|
110
|
+
|
111
|
+
Fiber.new {
|
112
|
+
logger.local_level = 0
|
113
|
+
p "Thread is debug? #{logger.debug?}"
|
114
|
+
}.resume
|
115
|
+
|
116
|
+
p "Main is debug? #{logger.debug?}"
|
117
|
+
|
118
|
+
Before:
|
119
|
+
|
120
|
+
Main is debug? false
|
121
|
+
Thread is debug? true
|
122
|
+
Main is debug? true
|
123
|
+
|
124
|
+
After:
|
125
|
+
|
126
|
+
Main is debug? false
|
127
|
+
Thread is debug? true
|
128
|
+
Main is debug? false
|
129
|
+
|
130
|
+
*Alexander Varnin*
|
131
|
+
|
132
|
+
* Do not delegate missing `marshal_dump` and `_dump` methods via the
|
133
|
+
`delegate_missing_to` extension. This avoids unintentionally adding instance
|
134
|
+
variables when calling `Marshal.dump(object)`, should the delegation target of
|
135
|
+
`object` be a method which would otherwise add them. Fixes #36522.
|
136
|
+
|
137
|
+
*Aaron Lipman*
|
138
|
+
|
139
|
+
|
140
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
141
|
+
|
142
|
+
* `truncate` would return the original string if it was too short to be truncated
|
143
|
+
and a frozen string if it were long enough to be truncated. Now truncate will
|
144
|
+
consistently return an unfrozen string regardless. This behavior is consistent
|
145
|
+
with `gsub` and `strip`.
|
146
|
+
|
147
|
+
Before:
|
148
|
+
|
149
|
+
'foobar'.truncate(5).frozen?
|
150
|
+
# => true
|
151
|
+
'foobar'.truncate(6).frozen?
|
152
|
+
# => false
|
153
|
+
|
154
|
+
After:
|
155
|
+
|
156
|
+
'foobar'.truncate(5).frozen?
|
157
|
+
# => false
|
158
|
+
'foobar'.truncate(6).frozen?
|
159
|
+
# => false
|
160
|
+
|
161
|
+
*Jordan Thomas*
|
162
|
+
|
163
|
+
|
1
164
|
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
2
165
|
|
3
166
|
* Introduce `ActiveSupport::ActionableError`.
|
@@ -212,7 +375,7 @@
|
|
212
375
|
|
213
376
|
*Jan Habermann*, *Xavier Noria*
|
214
377
|
|
215
|
-
* Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `
|
378
|
+
* Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSupport::Multibyte::Unicode#unpack_graphemes(string)`
|
216
379
|
in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
|
217
380
|
|
218
381
|
*Francesco Rodríguez*
|
@@ -230,7 +393,7 @@
|
|
230
393
|
|
231
394
|
*Edouard Chin*
|
232
395
|
|
233
|
-
* Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `
|
396
|
+
* Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSupport::Multibyte::Chars#normalize`
|
234
397
|
in favor of `String#unicode_normalize`
|
235
398
|
|
236
399
|
*Francesco Rodríguez*
|
data/README.rdoc
CHANGED
@@ -37,4 +37,4 @@ Bug reports for the Ruby on Rails project can be filed here:
|
|
37
37
|
|
38
38
|
Feature requests should be discussed on the rails-core mailing list here:
|
39
39
|
|
40
|
-
* https://
|
40
|
+
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
data/lib/active_support/cache.rb
CHANGED
@@ -52,12 +52,13 @@ module ActiveSupport
|
|
52
52
|
#
|
53
53
|
# ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
|
54
54
|
# # => returns MyOwnCacheStore.new
|
55
|
-
def lookup_store(*
|
56
|
-
store, *parameters = *Array.wrap(store_option).flatten
|
57
|
-
|
55
|
+
def lookup_store(store = nil, *parameters)
|
58
56
|
case store
|
59
57
|
when Symbol
|
60
|
-
|
58
|
+
options = parameters.extract_options!
|
59
|
+
retrieve_store_class(store).new(*parameters, **options)
|
60
|
+
when Array
|
61
|
+
lookup_store(*store)
|
61
62
|
when nil
|
62
63
|
ActiveSupport::Cache::MemoryStore.new
|
63
64
|
else
|
@@ -318,7 +319,7 @@ module ActiveSupport
|
|
318
319
|
|
319
320
|
entry = nil
|
320
321
|
instrument(:read, name, options) do |payload|
|
321
|
-
cached_entry = read_entry(key, options) unless options[:force]
|
322
|
+
cached_entry = read_entry(key, **options) unless options[:force]
|
322
323
|
entry = handle_expired_entry(cached_entry, key, options)
|
323
324
|
entry = nil if entry && entry.mismatched?(normalize_version(name, options))
|
324
325
|
payload[:super_operation] = :fetch if payload
|
@@ -326,9 +327,9 @@ module ActiveSupport
|
|
326
327
|
end
|
327
328
|
|
328
329
|
if entry
|
329
|
-
get_entry_value(entry, name, options)
|
330
|
+
get_entry_value(entry, name, **options)
|
330
331
|
else
|
331
|
-
save_block_result_to_cache(name, options) { |_name| yield _name }
|
332
|
+
save_block_result_to_cache(name, **options) { |_name| yield _name }
|
332
333
|
end
|
333
334
|
elsif options && options[:force]
|
334
335
|
raise ArgumentError, "Missing block: Calling `Cache#fetch` with `force: true` requires a block."
|
@@ -352,11 +353,11 @@ module ActiveSupport
|
|
352
353
|
version = normalize_version(name, options)
|
353
354
|
|
354
355
|
instrument(:read, name, options) do |payload|
|
355
|
-
entry = read_entry(key, options)
|
356
|
+
entry = read_entry(key, **options)
|
356
357
|
|
357
358
|
if entry
|
358
359
|
if entry.expired?
|
359
|
-
delete_entry(key, options)
|
360
|
+
delete_entry(key, **options)
|
360
361
|
payload[:hit] = false if payload
|
361
362
|
nil
|
362
363
|
elsif entry.mismatched?(version)
|
@@ -384,7 +385,7 @@ module ActiveSupport
|
|
384
385
|
options = merged_options(options)
|
385
386
|
|
386
387
|
instrument :read_multi, names, options do |payload|
|
387
|
-
read_multi_entries(names, options).tap do |results|
|
388
|
+
read_multi_entries(names, **options).tap do |results|
|
388
389
|
payload[:hits] = results.keys
|
389
390
|
end
|
390
391
|
end
|
@@ -396,10 +397,10 @@ module ActiveSupport
|
|
396
397
|
|
397
398
|
instrument :write_multi, hash, options do |payload|
|
398
399
|
entries = hash.each_with_object({}) do |(name, value), memo|
|
399
|
-
memo[normalize_key(name, options)] = Entry.new(value, options.merge(version: normalize_version(name, options)))
|
400
|
+
memo[normalize_key(name, options)] = Entry.new(value, **options.merge(version: normalize_version(name, options)))
|
400
401
|
end
|
401
402
|
|
402
|
-
write_multi_entries entries, options
|
403
|
+
write_multi_entries entries, **options
|
403
404
|
end
|
404
405
|
end
|
405
406
|
|
@@ -438,7 +439,7 @@ module ActiveSupport
|
|
438
439
|
options = merged_options(options)
|
439
440
|
|
440
441
|
instrument :read_multi, names, options do |payload|
|
441
|
-
reads = read_multi_entries(names, options)
|
442
|
+
reads = read_multi_entries(names, **options)
|
442
443
|
writes = {}
|
443
444
|
ordered = names.each_with_object({}) do |name, hash|
|
444
445
|
hash[name] = reads.fetch(name) { writes[name] = yield(name) }
|
@@ -447,7 +448,7 @@ module ActiveSupport
|
|
447
448
|
payload[:hits] = reads.keys
|
448
449
|
payload[:super_operation] = :fetch_multi
|
449
450
|
|
450
|
-
write_multi(writes, options)
|
451
|
+
write_multi(writes, **options)
|
451
452
|
|
452
453
|
ordered
|
453
454
|
end
|
@@ -460,8 +461,8 @@ module ActiveSupport
|
|
460
461
|
options = merged_options(options)
|
461
462
|
|
462
463
|
instrument(:write, name, options) do
|
463
|
-
entry = Entry.new(value, options.merge(version: normalize_version(name, options)))
|
464
|
-
write_entry(normalize_key(name, options), entry, options)
|
464
|
+
entry = Entry.new(value, **options.merge(version: normalize_version(name, options)))
|
465
|
+
write_entry(normalize_key(name, options), entry, **options)
|
465
466
|
end
|
466
467
|
end
|
467
468
|
|
@@ -472,7 +473,7 @@ module ActiveSupport
|
|
472
473
|
options = merged_options(options)
|
473
474
|
|
474
475
|
instrument(:delete, name) do
|
475
|
-
delete_entry(normalize_key(name, options), options)
|
476
|
+
delete_entry(normalize_key(name, options), **options)
|
476
477
|
end
|
477
478
|
end
|
478
479
|
|
@@ -483,7 +484,7 @@ module ActiveSupport
|
|
483
484
|
options = merged_options(options)
|
484
485
|
|
485
486
|
instrument(:exist?, name) do
|
486
|
-
entry = read_entry(normalize_key(name, options), options)
|
487
|
+
entry = read_entry(normalize_key(name, options), **options)
|
487
488
|
(entry && !entry.expired? && !entry.mismatched?(normalize_version(name, options))) || false
|
488
489
|
end
|
489
490
|
end
|
@@ -556,28 +557,28 @@ module ActiveSupport
|
|
556
557
|
|
557
558
|
# Reads an entry from the cache implementation. Subclasses must implement
|
558
559
|
# this method.
|
559
|
-
def read_entry(key, options)
|
560
|
+
def read_entry(key, **options)
|
560
561
|
raise NotImplementedError.new
|
561
562
|
end
|
562
563
|
|
563
564
|
# Writes an entry to the cache implementation. Subclasses must implement
|
564
565
|
# this method.
|
565
|
-
def write_entry(key, entry, options)
|
566
|
+
def write_entry(key, entry, **options)
|
566
567
|
raise NotImplementedError.new
|
567
568
|
end
|
568
569
|
|
569
570
|
# Reads multiple entries from the cache implementation. Subclasses MAY
|
570
571
|
# implement this method.
|
571
|
-
def read_multi_entries(names, options)
|
572
|
+
def read_multi_entries(names, **options)
|
572
573
|
results = {}
|
573
574
|
names.each do |name|
|
574
575
|
key = normalize_key(name, options)
|
575
576
|
version = normalize_version(name, options)
|
576
|
-
entry = read_entry(key, options)
|
577
|
+
entry = read_entry(key, **options)
|
577
578
|
|
578
579
|
if entry
|
579
580
|
if entry.expired?
|
580
|
-
delete_entry(key, options)
|
581
|
+
delete_entry(key, **options)
|
581
582
|
elsif entry.mismatched?(version)
|
582
583
|
# Skip mismatched versions
|
583
584
|
else
|
@@ -590,15 +591,15 @@ module ActiveSupport
|
|
590
591
|
|
591
592
|
# Writes multiple entries to the cache implementation. Subclasses MAY
|
592
593
|
# implement this method.
|
593
|
-
def write_multi_entries(hash, options)
|
594
|
+
def write_multi_entries(hash, **options)
|
594
595
|
hash.each do |key, entry|
|
595
|
-
write_entry key, entry, options
|
596
|
+
write_entry key, entry, **options
|
596
597
|
end
|
597
598
|
end
|
598
599
|
|
599
600
|
# Deletes an entry from the cache implementation. Subclasses must
|
600
601
|
# implement this method.
|
601
|
-
def delete_entry(key, options)
|
602
|
+
def delete_entry(key, **options)
|
602
603
|
raise NotImplementedError.new
|
603
604
|
end
|
604
605
|
|
@@ -699,7 +700,7 @@ module ActiveSupport
|
|
699
700
|
entry.expires_at = Time.now + race_ttl
|
700
701
|
write_entry(key, entry, expires_in: race_ttl * 2)
|
701
702
|
else
|
702
|
-
delete_entry(key, options)
|
703
|
+
delete_entry(key, **options)
|
703
704
|
end
|
704
705
|
entry = nil
|
705
706
|
end
|
@@ -711,7 +712,7 @@ module ActiveSupport
|
|
711
712
|
entry.value
|
712
713
|
end
|
713
714
|
|
714
|
-
def save_block_result_to_cache(name, options)
|
715
|
+
def save_block_result_to_cache(name, **options)
|
715
716
|
result = instrument(:generate, name, options) do
|
716
717
|
yield(name)
|
717
718
|
end
|
@@ -36,15 +36,15 @@ module ActiveSupport
|
|
36
36
|
def clear(options = nil)
|
37
37
|
root_dirs = (Dir.children(cache_path) - GITKEEP_FILES)
|
38
38
|
FileUtils.rm_r(root_dirs.collect { |f| File.join(cache_path, f) })
|
39
|
-
rescue Errno::ENOENT
|
39
|
+
rescue Errno::ENOENT, Errno::ENOTEMPTY
|
40
40
|
end
|
41
41
|
|
42
42
|
# Preemptively iterates through all stored keys and removes the ones which have expired.
|
43
43
|
def cleanup(options = nil)
|
44
44
|
options = merged_options(options)
|
45
45
|
search_dir(cache_path) do |fname|
|
46
|
-
entry = read_entry(fname, options)
|
47
|
-
delete_entry(fname, options) if entry && entry.expired?
|
46
|
+
entry = read_entry(fname, **options)
|
47
|
+
delete_entry(fname, **options) if entry && entry.expired?
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -66,14 +66,13 @@ module ActiveSupport
|
|
66
66
|
matcher = key_matcher(matcher, options)
|
67
67
|
search_dir(cache_path) do |path|
|
68
68
|
key = file_path_key(path)
|
69
|
-
delete_entry(path, options) if key.match(matcher)
|
69
|
+
delete_entry(path, **options) if key.match(matcher)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
private
|
75
|
-
|
76
|
-
def read_entry(key, options)
|
75
|
+
def read_entry(key, **options)
|
77
76
|
if File.exist?(key)
|
78
77
|
File.open(key) { |f| Marshal.load(f) }
|
79
78
|
end
|
@@ -82,14 +81,14 @@ module ActiveSupport
|
|
82
81
|
nil
|
83
82
|
end
|
84
83
|
|
85
|
-
def write_entry(key, entry, options)
|
84
|
+
def write_entry(key, entry, **options)
|
86
85
|
return false if options[:unless_exist] && File.exist?(key)
|
87
86
|
ensure_cache_path(File.dirname(key))
|
88
87
|
File.atomic_write(key, cache_path) { |f| Marshal.dump(entry, f) }
|
89
88
|
true
|
90
89
|
end
|
91
90
|
|
92
|
-
def delete_entry(key, options)
|
91
|
+
def delete_entry(key, **options)
|
93
92
|
if File.exist?(key)
|
94
93
|
begin
|
95
94
|
File.delete(key)
|