activesupport 6.1.7 → 7.0.0.alpha1
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 +151 -608
- data/MIT-LICENSE +1 -1
- data/lib/active_support/actionable_error.rb +1 -1
- data/lib/active_support/array_inquirer.rb +0 -2
- data/lib/active_support/benchmarkable.rb +2 -2
- data/lib/active_support/cache/file_store.rb +15 -9
- data/lib/active_support/cache/mem_cache_store.rb +119 -28
- data/lib/active_support/cache/memory_store.rb +21 -13
- data/lib/active_support/cache/null_store.rb +10 -2
- data/lib/active_support/cache/redis_cache_store.rb +39 -59
- data/lib/active_support/cache/strategy/local_cache.rb +29 -49
- data/lib/active_support/cache.rb +189 -45
- data/lib/active_support/callbacks.rb +35 -31
- data/lib/active_support/concern.rb +5 -5
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +2 -4
- data/lib/active_support/concurrency/share_lock.rb +2 -2
- data/lib/active_support/configurable.rb +6 -3
- data/lib/active_support/configuration_file.rb +1 -1
- data/lib/active_support/core_ext/array/access.rb +1 -5
- data/lib/active_support/core_ext/array/conversions.rb +6 -6
- data/lib/active_support/core_ext/array/grouping.rb +6 -6
- data/lib/active_support/core_ext/big_decimal/conversions.rb +1 -1
- data/lib/active_support/core_ext/date/blank.rb +1 -1
- data/lib/active_support/core_ext/date/calculations.rb +2 -2
- data/lib/active_support/core_ext/date_time/blank.rb +1 -1
- data/lib/active_support/core_ext/digest/uuid.rb +13 -13
- data/lib/active_support/core_ext/enumerable.rb +64 -12
- data/lib/active_support/core_ext/file/atomic.rb +1 -1
- data/lib/active_support/core_ext/hash/keys.rb +1 -1
- data/lib/active_support/core_ext/kernel/reporting.rb +4 -4
- data/lib/active_support/core_ext/module/delegation.rb +2 -8
- data/lib/active_support/core_ext/name_error.rb +2 -8
- data/lib/active_support/core_ext/numeric/conversions.rb +2 -2
- data/lib/active_support/core_ext/object/blank.rb +2 -2
- data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
- data/lib/active_support/core_ext/object/duplicable.rb +11 -0
- data/lib/active_support/core_ext/object/json.rb +29 -24
- data/lib/active_support/core_ext/object/to_query.rb +2 -2
- data/lib/active_support/core_ext/object/try.rb +20 -20
- data/lib/active_support/core_ext/range/compare_range.rb +0 -25
- data/lib/active_support/core_ext/range/each.rb +1 -1
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +1 -1
- data/lib/active_support/core_ext/string/filters.rb +1 -1
- data/lib/active_support/core_ext/string/inflections.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +60 -64
- data/lib/active_support/core_ext/symbol/starts_ends_with.rb +0 -8
- data/lib/active_support/core_ext/time/calculations.rb +4 -5
- data/lib/active_support/core_ext/time/zones.rb +2 -17
- data/lib/active_support/core_ext/uri.rb +0 -14
- data/lib/active_support/current_attributes.rb +17 -2
- data/lib/active_support/dependencies/interlock.rb +10 -18
- data/lib/active_support/dependencies/require_dependency.rb +28 -0
- data/lib/active_support/dependencies.rb +58 -788
- data/lib/active_support/deprecation/behaviors.rb +4 -1
- data/lib/active_support/deprecation/method_wrappers.rb +3 -3
- data/lib/active_support/deprecation/proxy_wrappers.rb +1 -1
- data/lib/active_support/deprecation.rb +1 -1
- data/lib/active_support/descendants_tracker.rb +12 -9
- data/lib/active_support/digest.rb +4 -4
- data/lib/active_support/duration/iso8601_parser.rb +3 -3
- data/lib/active_support/duration/iso8601_serializer.rb +9 -1
- data/lib/active_support/duration.rb +80 -52
- data/lib/active_support/encrypted_configuration.rb +11 -1
- data/lib/active_support/encrypted_file.rb +1 -1
- data/lib/active_support/environment_inquirer.rb +1 -1
- data/lib/active_support/evented_file_update_checker.rb +1 -1
- data/lib/active_support/execution_wrapper.rb +13 -16
- data/lib/active_support/fork_tracker.rb +2 -4
- data/lib/active_support/gem_version.rb +4 -4
- data/lib/active_support/hash_with_indifferent_access.rb +3 -1
- data/lib/active_support/i18n.rb +1 -0
- data/lib/active_support/inflector/inflections.rb +11 -4
- data/lib/active_support/inflector/methods.rb +23 -47
- data/lib/active_support/json/encoding.rb +3 -3
- data/lib/active_support/key_generator.rb +18 -1
- data/lib/active_support/locale/en.yml +1 -1
- data/lib/active_support/log_subscriber.rb +13 -3
- data/lib/active_support/logger_thread_safe_level.rb +5 -13
- data/lib/active_support/message_encryptor.rb +3 -3
- data/lib/active_support/message_verifier.rb +4 -4
- data/lib/active_support/messages/metadata.rb +2 -2
- data/lib/active_support/multibyte/chars.rb +10 -11
- data/lib/active_support/multibyte.rb +1 -1
- data/lib/active_support/notifications/fanout.rb +31 -11
- data/lib/active_support/notifications/instrumenter.rb +17 -0
- data/lib/active_support/notifications.rb +10 -0
- data/lib/active_support/number_helper/number_converter.rb +1 -3
- data/lib/active_support/number_helper/number_to_currency_converter.rb +11 -6
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -1
- data/lib/active_support/number_helper/rounding_helper.rb +1 -5
- data/lib/active_support/number_helper.rb +0 -2
- data/lib/active_support/option_merger.rb +4 -16
- data/lib/active_support/ordered_hash.rb +1 -1
- data/lib/active_support/parameter_filter.rb +5 -0
- data/lib/active_support/per_thread_registry.rb +1 -1
- data/lib/active_support/railtie.rb +33 -10
- data/lib/active_support/reloader.rb +1 -1
- data/lib/active_support/rescuable.rb +2 -2
- data/lib/active_support/secure_compare_rotator.rb +1 -1
- data/lib/active_support/string_inquirer.rb +0 -2
- data/lib/active_support/subscriber.rb +5 -0
- data/lib/active_support/test_case.rb +9 -21
- data/lib/active_support/testing/assertions.rb +34 -4
- data/lib/active_support/testing/deprecation.rb +1 -1
- data/lib/active_support/testing/isolation.rb +1 -1
- data/lib/active_support/testing/method_call_assertions.rb +5 -5
- data/lib/active_support/testing/parallelization/server.rb +4 -0
- data/lib/active_support/testing/parallelization/worker.rb +3 -0
- data/lib/active_support/testing/parallelization.rb +4 -0
- data/lib/active_support/testing/parallelize_executor.rb +76 -0
- data/lib/active_support/testing/stream.rb +3 -5
- data/lib/active_support/testing/tagged_logging.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +13 -2
- data/lib/active_support/time_with_zone.rb +19 -6
- data/lib/active_support/values/time_zone.rb +25 -11
- data/lib/active_support/xml_mini/jdom.rb +1 -1
- data/lib/active_support/xml_mini/libxml.rb +5 -5
- data/lib/active_support/xml_mini/libxmlsax.rb +1 -1
- data/lib/active_support/xml_mini/nokogiri.rb +4 -4
- data/lib/active_support/xml_mini/nokogirisax.rb +1 -1
- data/lib/active_support/xml_mini/rexml.rb +1 -1
- data/lib/active_support/xml_mini.rb +2 -1
- data/lib/active_support.rb +14 -1
- metadata +14 -29
- data/lib/active_support/core_ext/marshal.rb +0 -26
- data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -120
data/CHANGELOG.md
CHANGED
@@ -1,732 +1,275 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 7.0.0.alpha1 (September 15, 2021) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* `ActiveSupport::Dependencies` no longer installs a `const_missing` hook. Before this, you could push to the autoload paths and have constants autoloaded. This feature, known as the `classic` autoloader, has been removed.
|
4
4
|
|
5
|
+
*Xavier Noria*
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
* No changes.
|
9
|
-
|
10
|
-
|
11
|
-
## Rails 6.1.6 (May 09, 2022) ##
|
12
|
-
|
13
|
-
* No changes.
|
14
|
-
|
15
|
-
|
16
|
-
## Rails 6.1.5.1 (April 26, 2022) ##
|
17
|
-
|
18
|
-
* Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
|
19
|
-
|
20
|
-
Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
|
21
|
-
in names of tags and names of attributes, following the specification of XML.
|
22
|
-
|
23
|
-
*Álvaro Martín Fraguas*
|
24
|
-
|
25
|
-
## Rails 6.1.5 (March 09, 2022) ##
|
26
|
-
|
27
|
-
* Fix `ActiveSupport::Duration.build` to support negative values.
|
28
|
-
|
29
|
-
The algorithm to collect the `parts` of the `ActiveSupport::Duration`
|
30
|
-
ignored the sign of the `value` and accumulated incorrect part values. This
|
31
|
-
impacted `ActiveSupport::Duration#sum` (which is dependent on `parts`) but
|
32
|
-
not `ActiveSupport::Duration#eql?` (which is dependent on `value`).
|
33
|
-
|
34
|
-
*Caleb Buxton*, *Braden Staudacher*
|
35
|
-
|
36
|
-
* `Time#change` and methods that call it (eg. `Time#advance`) will now
|
37
|
-
return a `Time` with the timezone argument provided, if the caller was
|
38
|
-
initialized with a timezone argument.
|
39
|
-
|
40
|
-
Fixes [#42467](https://github.com/rails/rails/issues/42467).
|
41
|
-
|
42
|
-
*Alex Ghiculescu*
|
43
|
-
|
44
|
-
* Clone to keep extended Logger methods for tagged logger.
|
45
|
-
|
46
|
-
*Orhan Toy*
|
47
|
-
|
48
|
-
* `assert_changes` works on including `ActiveSupport::Assertions` module.
|
49
|
-
|
50
|
-
*Pedro Medeiros*
|
51
|
-
|
52
|
-
|
53
|
-
## Rails 6.1.4.7 (March 08, 2022) ##
|
54
|
-
|
55
|
-
* No changes.
|
56
|
-
|
57
|
-
|
58
|
-
## Rails 6.1.4.6 (February 11, 2022) ##
|
59
|
-
|
60
|
-
* Fix Reloader method signature to work with the new Executor signature
|
61
|
-
|
62
|
-
|
63
|
-
## Rails 6.1.4.5 (February 11, 2022) ##
|
64
|
-
|
65
|
-
* No changes.
|
66
|
-
|
67
|
-
|
68
|
-
## Rails 6.1.4.4 (December 15, 2021) ##
|
69
|
-
|
70
|
-
* No changes.
|
71
|
-
|
72
|
-
|
73
|
-
## Rails 6.1.4.3 (December 14, 2021) ##
|
74
|
-
|
75
|
-
* No changes.
|
76
|
-
|
77
|
-
|
78
|
-
## Rails 6.1.4.2 (December 14, 2021) ##
|
79
|
-
|
80
|
-
* No changes.
|
81
|
-
|
82
|
-
|
83
|
-
## Rails 6.1.4.1 (August 19, 2021) ##
|
84
|
-
|
85
|
-
* No changes.
|
86
|
-
|
87
|
-
|
88
|
-
## Rails 6.1.4 (June 24, 2021) ##
|
89
|
-
|
90
|
-
* MemCacheStore: convert any underlying value (including `false`) to an `Entry`.
|
91
|
-
|
92
|
-
See [#42559](https://github.com/rails/rails/pull/42559).
|
93
|
-
|
94
|
-
*Alex Ghiculescu*
|
95
|
-
|
96
|
-
* Fix bug in `number_with_precision` when using large `BigDecimal` values.
|
97
|
-
|
98
|
-
Fixes #42302.
|
99
|
-
|
100
|
-
*Federico Aldunate*, *Zachary Scott*
|
101
|
-
|
102
|
-
* Check byte size instead of length on `secure_compare`.
|
103
|
-
|
104
|
-
*Tietew*
|
105
|
-
|
106
|
-
* Fix `Time.at` to not lose `:in` option.
|
107
|
-
|
108
|
-
*Ryuta Kamizono*
|
109
|
-
|
110
|
-
* Require a path for `config.cache_store = :file_store`.
|
111
|
-
|
112
|
-
*Alex Ghiculescu*
|
113
|
-
|
114
|
-
* Avoid having to store complex object in the default translation file.
|
115
|
-
|
116
|
-
*Rafael Mendonça França*
|
117
|
-
|
118
|
-
|
119
|
-
## Rails 6.1.3.2 (May 05, 2021) ##
|
120
|
-
|
121
|
-
* No changes.
|
122
|
-
|
123
|
-
|
124
|
-
## Rails 6.1.3.1 (March 26, 2021) ##
|
125
|
-
|
126
|
-
* No changes.
|
127
|
-
|
128
|
-
|
129
|
-
## Rails 6.1.3 (February 17, 2021) ##
|
130
|
-
|
131
|
-
* No changes.
|
132
|
-
|
133
|
-
|
134
|
-
## Rails 6.1.2.1 (February 10, 2021) ##
|
135
|
-
|
136
|
-
* No changes.
|
137
|
-
|
138
|
-
|
139
|
-
## Rails 6.1.2 (February 09, 2021) ##
|
140
|
-
|
141
|
-
* `ActiveSupport::Cache::MemCacheStore` now accepts an explicit `nil` for its `addresses` argument.
|
142
|
-
|
143
|
-
```ruby
|
144
|
-
config.cache_store = :mem_cache_store, nil
|
7
|
+
* Private internal classes of `ActiveSupport::Dependencies` have been deleted, like `ActiveSupport::Dependencies::Reference`, `ActiveSupport::Dependencies::Blamable`, and others.
|
145
8
|
|
146
|
-
|
9
|
+
*Xavier Noria*
|
147
10
|
|
148
|
-
|
11
|
+
* The private API of `ActiveSupport::Dependencies` has been deleted. That includes methods like `hook!`, `unhook!`, `depend_on`, `require_or_load`, `mechanism`, and many others.
|
149
12
|
|
150
|
-
|
13
|
+
*Xavier Noria*
|
151
14
|
|
152
|
-
|
15
|
+
* Improves the performance of `ActiveSupport::NumberHelper` formatters by avoiding the use of exceptions as flow control.
|
153
16
|
|
154
|
-
|
155
|
-
```
|
17
|
+
*Mike Dalessio*
|
156
18
|
|
157
|
-
|
19
|
+
* Removed rescue block from `ActiveSupport::Cache::RedisCacheStore#handle_exception`
|
158
20
|
|
159
|
-
|
21
|
+
Previously, if you provided a `error_handler` to `redis_cache_store`, any errors thrown by
|
22
|
+
the error handler would be rescued and logged only. Removed the `rescue` clause from `handle_exception`
|
23
|
+
to allow these to be thrown.
|
160
24
|
|
25
|
+
*Nicholas A. Stuart*
|
161
26
|
|
162
|
-
|
27
|
+
* Allow entirely opting out of deprecation warnings.
|
163
28
|
|
164
|
-
|
165
|
-
|
29
|
+
Previously if you did `app.config.active_support.deprecation = :silence`, some work would
|
30
|
+
still be done on each call to `ActiveSupport::Deprecation.warn`. In very hot paths, this could
|
31
|
+
cause performance issues.
|
166
32
|
|
167
|
-
|
33
|
+
Now, you can make `ActiveSupport::Deprecation.warn` a no-op:
|
168
34
|
|
169
35
|
```ruby
|
170
|
-
|
171
|
-
# => "{\"addr\":2130706433,\"family\":2,\"mask_addr\":4294967295}"
|
36
|
+
config.active_support.report_deprecations = false
|
172
37
|
```
|
173
38
|
|
174
|
-
|
39
|
+
This is the default in production for new apps. It is the equivalent to:
|
175
40
|
|
176
41
|
```ruby
|
177
|
-
|
178
|
-
|
42
|
+
config.active_support.deprecation = :silence
|
43
|
+
config.active_support.disallowed_deprecation = :silence
|
179
44
|
```
|
180
45
|
|
46
|
+
but will take a more optimised code path.
|
181
47
|
|
182
|
-
|
183
|
-
|
184
|
-
* Ensure `MemoryStore` disables compression by default. Reverts behavior of
|
185
|
-
`MemoryStore` to its prior rails `5.1` behavior.
|
186
|
-
|
187
|
-
*Max Gurewitz*
|
188
|
-
|
189
|
-
* Calling `iso8601` on negative durations retains the negative sign on individual
|
190
|
-
digits instead of prepending it.
|
191
|
-
|
192
|
-
This change is required so we can interoperate with PostgreSQL, which prefers
|
193
|
-
negative signs for each component.
|
194
|
-
|
195
|
-
Compatibility with other iso8601 parsers which support leading negatives as well
|
196
|
-
as negatives per component is still retained.
|
197
|
-
|
198
|
-
Before:
|
199
|
-
|
200
|
-
(-1.year - 1.day).iso8601
|
201
|
-
# => "-P1Y1D"
|
202
|
-
|
203
|
-
After:
|
204
|
-
|
205
|
-
(-1.year - 1.day).iso8601
|
206
|
-
# => "P-1Y-1D"
|
207
|
-
|
208
|
-
*Vipul A M*
|
209
|
-
|
210
|
-
* Remove deprecated `ActiveSupport::Notifications::Instrumenter#end=`.
|
211
|
-
|
212
|
-
*Rafael Mendonça França*
|
213
|
-
|
214
|
-
* Deprecate `ActiveSupport::Multibyte::Unicode.default_normalization_form`.
|
215
|
-
|
216
|
-
*Rafael Mendonça França*
|
217
|
-
|
218
|
-
* Remove deprecated `ActiveSupport::Multibyte::Unicode.pack_graphemes`,
|
219
|
-
`ActiveSupport::Multibyte::Unicode.unpack_graphemes`,
|
220
|
-
`ActiveSupport::Multibyte::Unicode.normalize`,
|
221
|
-
`ActiveSupport::Multibyte::Unicode.downcase`,
|
222
|
-
`ActiveSupport::Multibyte::Unicode.upcase` and `ActiveSupport::Multibyte::Unicode.swapcase`.
|
223
|
-
|
224
|
-
*Rafael Mendonça França*
|
225
|
-
|
226
|
-
* Remove deprecated `ActiveSupport::Multibyte::Chars#consumes?` and `ActiveSupport::Multibyte::Chars#normalize`.
|
227
|
-
|
228
|
-
*Rafael Mendonça França*
|
229
|
-
|
230
|
-
* Remove deprecated file `active_support/core_ext/range/include_range`.
|
231
|
-
|
232
|
-
*Rafael Mendonça França*
|
233
|
-
|
234
|
-
* Remove deprecated file `active_support/core_ext/hash/transform_values`.
|
235
|
-
|
236
|
-
*Rafael Mendonça França*
|
237
|
-
|
238
|
-
* Remove deprecated file `active_support/core_ext/hash/compact`.
|
239
|
-
|
240
|
-
*Rafael Mendonça França*
|
241
|
-
|
242
|
-
* Remove deprecated file `active_support/core_ext/array/prepend_and_append`.
|
243
|
-
|
244
|
-
*Rafael Mendonça França*
|
245
|
-
|
246
|
-
* Remove deprecated file `active_support/core_ext/numeric/inquiry`.
|
247
|
-
|
248
|
-
*Rafael Mendonça França*
|
249
|
-
|
250
|
-
* Remove deprecated file `active_support/core_ext/module/reachable`.
|
251
|
-
|
252
|
-
*Rafael Mendonça França*
|
253
|
-
|
254
|
-
* Remove deprecated `Module#parent_name`, `Module#parent` and `Module#parents`.
|
255
|
-
|
256
|
-
*Rafael Mendonça França*
|
257
|
-
|
258
|
-
* Remove deprecated `ActiveSupport::LoggerThreadSafeLevel#after_initialize`.
|
259
|
-
|
260
|
-
*Rafael Mendonça França*
|
261
|
-
|
262
|
-
* Remove deprecated `LoggerSilence` constant.
|
263
|
-
|
264
|
-
*Rafael Mendonça França*
|
265
|
-
|
266
|
-
* Remove deprecated fallback to `I18n.default_local` when `config.i18n.fallbacks` is empty.
|
267
|
-
|
268
|
-
*Rafael Mendonça França*
|
269
|
-
|
270
|
-
* Remove entries from local cache on `RedisCacheStore#delete_matched`
|
271
|
-
|
272
|
-
Fixes #38627
|
273
|
-
|
274
|
-
*ojab*
|
48
|
+
*Alex Ghiculescu*
|
275
49
|
|
276
|
-
*
|
277
|
-
|
50
|
+
* Faster tests by parallelizing only when overhead is justified by the number
|
51
|
+
of them.
|
278
52
|
|
279
|
-
|
53
|
+
Running tests in parallel adds overhead in terms of database
|
54
|
+
setup and fixture loading. Now, Rails will only parallelize test executions when
|
55
|
+
there are enough tests to make it worth it.
|
280
56
|
|
281
|
-
|
57
|
+
This threshold is 50 by default, and is configurable via config setting in
|
58
|
+
your test.rb:
|
282
59
|
|
283
60
|
```ruby
|
284
|
-
config.
|
285
|
-
|
286
|
-
# is now equivalent to
|
287
|
-
|
288
|
-
config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
|
289
|
-
|
290
|
-
# instead of
|
291
|
-
|
292
|
-
config.cache_store = :mem_cache_store, "localhost:11211" # ignores ENV["MEMCACHE_SERVERS"]
|
61
|
+
config.active_support.test_parallelization_threshold = 100
|
293
62
|
```
|
294
63
|
|
295
|
-
|
296
|
-
|
297
|
-
* `ActiveSupport::Subscriber#attach_to` now accepts an `inherit_all:` argument. When set to true,
|
298
|
-
it allows a subscriber to receive events for methods defined in the subscriber's ancestor class(es).
|
64
|
+
It's also configurable at the test case level:
|
299
65
|
|
300
66
|
```ruby
|
301
|
-
class
|
302
|
-
|
303
|
-
|
304
|
-
def start_processing(event)
|
305
|
-
info "Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}"
|
306
|
-
end
|
307
|
-
|
308
|
-
def redirect_to(event)
|
309
|
-
info { "Redirected to #{event.payload[:location]}" }
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
# We detach ActionControllerSubscriber from the :action_controller namespace so that our CustomActionControllerSubscriber
|
314
|
-
# can provide its own instrumentation for certain events in the namespace
|
315
|
-
ActionControllerSubscriber.detach_from(:action_controller)
|
316
|
-
|
317
|
-
class CustomActionControllerSubscriber < ActionControllerSubscriber
|
318
|
-
attach_to :action_controller, inherit_all: true
|
319
|
-
|
320
|
-
def start_processing(event)
|
321
|
-
info "A custom response to start_processing events"
|
322
|
-
end
|
323
|
-
|
324
|
-
# => CustomActionControllerSubscriber will process events for "start_processing.action_controller" notifications
|
325
|
-
# using its own #start_processing implementation, while retaining ActionControllerSubscriber's instrumentation
|
326
|
-
# for "redirect_to.action_controller" notifications
|
67
|
+
class ActiveSupport::TestCase
|
68
|
+
parallelize threshold: 100
|
327
69
|
end
|
328
70
|
```
|
329
71
|
|
330
|
-
*
|
72
|
+
*Jorge Manrubia*
|
331
73
|
|
332
|
-
*
|
333
|
-
|
334
|
-
`config.active_support.use_sha1_digests` is deprecated in favour of `config.active_support.hash_digest_class = ::Digest::SHA1`.
|
74
|
+
* OpenSSL constants are now used for Digest computations.
|
335
75
|
|
336
76
|
*Dirkjan Bussink*
|
337
77
|
|
338
|
-
*
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
* Add `ActiveSupport::Duration` conversion methods
|
78
|
+
* `TimeZone.iso8601` now accepts valid ordinal values similar to Ruby's `Date._iso8601` method.
|
79
|
+
A valid ordinal value will be converted to an instance of `TimeWithZone` using the `:year`
|
80
|
+
and `:yday` fragments returned from `Date._iso8601`.
|
343
81
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
* Fixed issue in `ActiveSupport::Cache::RedisCacheStore` not passing options
|
349
|
-
to `read_multi` causing `fetch_multi` to not work properly
|
350
|
-
|
351
|
-
*Rajesh Sharma*
|
352
|
-
|
353
|
-
* Fixed issue in `ActiveSupport::Cache::MemCacheStore` which caused duplicate compression,
|
354
|
-
and caused the provided `compression_threshold` to not be respected.
|
355
|
-
|
356
|
-
*Max Gurewitz*
|
357
|
-
|
358
|
-
* Prevent `RedisCacheStore` and `MemCacheStore` from performing compression
|
359
|
-
when reading entries written with `raw: true`.
|
360
|
-
|
361
|
-
*Max Gurewitz*
|
362
|
-
|
363
|
-
* `URI.parser` is deprecated and will be removed in Rails 7.0. Use
|
364
|
-
`URI::DEFAULT_PARSER` instead.
|
82
|
+
```ruby
|
83
|
+
twz = ActiveSupport::TimeZone["Eastern Time (US & Canada)"].iso8601("21087")
|
84
|
+
twz.to_a[0, 6] == [0, 0, 0, 28, 03, 2021]
|
85
|
+
```
|
365
86
|
|
366
|
-
*
|
87
|
+
*Steve Laing*
|
367
88
|
|
368
|
-
* `
|
369
|
-
|
370
|
-
|
89
|
+
* `Time#change` and methods that call it (e.g. `Time#advance`) will now
|
90
|
+
return a `Time` with the timezone argument provided, if the caller was
|
91
|
+
initialized with a timezone argument.
|
371
92
|
|
372
|
-
|
373
|
-
defensive with load order. Just refer to classes and modules normally. If
|
374
|
-
the constant name is dynamic, camelize if needed, and constantize.
|
93
|
+
Fixes [#42467](https://github.com/rails/rails/issues/42467).
|
375
94
|
|
376
|
-
*
|
95
|
+
*Alex Ghiculescu*
|
377
96
|
|
378
|
-
*
|
97
|
+
* Allow serializing any module or class to JSON by name.
|
379
98
|
|
380
|
-
|
381
|
-
:foo.starts_with?("f") # => true
|
382
|
-
:foo.ends_with?("o") # => true
|
383
|
-
```
|
99
|
+
*Tyler Rick*, *Zachary Scott*
|
384
100
|
|
385
|
-
|
101
|
+
* Raise `ActiveSupport::EncryptedFile::MissingKeyError` when the
|
102
|
+
`RAILS_MASTER_KEY` environment variable is blank (e.g. `""`).
|
386
103
|
|
387
|
-
*
|
104
|
+
*Sunny Ripert*
|
388
105
|
|
389
|
-
|
390
|
-
where a seemingly innocent change of formatting leads to a change in the code behavior.
|
106
|
+
* The `from:` option is added to `ActiveSupport::TestCase#assert_no_changes`.
|
391
107
|
|
392
|
-
|
393
|
-
```ruby
|
394
|
-
+1.second.class
|
395
|
-
# => ActiveSupport::Duration
|
396
|
-
(+ 1.second).class
|
397
|
-
# => Integer
|
398
|
-
```
|
108
|
+
It permits asserting on the initial value that is expected not to change.
|
399
109
|
|
400
|
-
After:
|
401
110
|
```ruby
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
# => ActiveSupport::Duration
|
111
|
+
assert_no_changes -> { Status.all_good? }, from: true do
|
112
|
+
post :create, params: { status: { ok: true } }
|
113
|
+
end
|
406
114
|
```
|
407
115
|
|
408
|
-
|
409
|
-
|
410
|
-
*Roman Kushnir*
|
411
|
-
|
412
|
-
* Add subsec to `ActiveSupport::TimeWithZone#inspect`.
|
116
|
+
*George Claghorn*
|
413
117
|
|
414
|
-
|
118
|
+
* Deprecate `ActiveSupport::SafeBuffer`'s incorrect implicit conversion of objects into string.
|
415
119
|
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
# => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
|
120
|
+
Except for a few methods like `String#%`, objects must implement `#to_str`
|
121
|
+
to be implicitly converted to a String in string operations. In some
|
122
|
+
circumstances `ActiveSupport::SafeBuffer` was incorrectly calling the
|
123
|
+
explicit conversion method (`#to_s`) on them. This behavior is now
|
124
|
+
deprecated.
|
422
125
|
|
423
|
-
|
126
|
+
*Jean Boussier*
|
424
127
|
|
425
|
-
|
426
|
-
# => "Thu, 22 Jun 2017 02:39:00.000000000 UTC +00:00"
|
427
|
-
Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
|
428
|
-
# => "Thu, 22 Jun 2017 02:39:00.123456780 UTC +00:00"
|
429
|
-
Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
|
430
|
-
# => "Thu, 22 Jun 2017 02:39:00.333333333 UTC +00:00"
|
128
|
+
* Allow nested access to keys on `Rails.application.credentials`.
|
431
129
|
|
432
|
-
|
130
|
+
Previously only top level keys in `credentials.yml.enc` could be accessed with method calls. Now any key can.
|
433
131
|
|
434
|
-
|
132
|
+
For example, given these secrets:
|
435
133
|
|
436
|
-
```
|
437
|
-
|
134
|
+
```yml
|
135
|
+
aws:
|
136
|
+
access_key_id: 123
|
137
|
+
secret_access_key: 345
|
438
138
|
```
|
439
139
|
|
440
|
-
|
441
|
-
|
442
|
-
* Align `Range#cover?` extension behavior with Ruby behavior for backwards ranges.
|
443
|
-
|
444
|
-
`(1..10).cover?(5..3)` now returns `false`, as it does in plain Ruby.
|
140
|
+
`Rails.application.credentials.aws.access_key_id` will now return the same thing as
|
141
|
+
`Rails.application.credentials.aws[:access_key_id]`.
|
445
142
|
|
446
|
-
|
447
|
-
|
448
|
-
*Michael Groeneman*
|
143
|
+
*Alex Ghiculescu*
|
449
144
|
|
450
|
-
*
|
145
|
+
* Added a faster and more compact `ActiveSupport::Cache` serialization format.
|
451
146
|
|
452
|
-
|
453
|
-
|
454
|
-
|
147
|
+
It can be enabled with `config.active_support.cache_format_version = 7.0` or
|
148
|
+
`config.load_defaults 7.0`. Regardless of the configuration Active Support
|
149
|
+
7.0 can read cache entries serialized by Active Support 6.1 which allows to
|
150
|
+
upgrade without invalidating the cache. However Rails 6.1 can't read the
|
151
|
+
new format, so all readers must be upgraded before the new format is enabled.
|
455
152
|
|
456
|
-
|
457
|
-
via the config in config/initializers/new_framework_defaults_6_1.rb
|
153
|
+
*Jean Boussier*
|
458
154
|
|
459
|
-
|
155
|
+
* Add `Enumerable#sole`, per `ActiveRecord::FinderMethods#sole`. Returns the
|
156
|
+
sole item of the enumerable, raising if no items are found, or if more than
|
157
|
+
one is.
|
460
158
|
|
461
|
-
*
|
159
|
+
*Asherah Connor*
|
462
160
|
|
463
|
-
*
|
161
|
+
* Freeze `ActiveSupport::Duration#parts` and remove writer methods.
|
464
162
|
|
465
|
-
|
163
|
+
Durations are meant to be value objects and should not be mutated.
|
466
164
|
|
467
|
-
*
|
165
|
+
*Andrew White*
|
468
166
|
|
469
|
-
*
|
167
|
+
* Fix `ActiveSupport::TimeZone#utc_to_local` with fractional seconds.
|
470
168
|
|
471
|
-
|
169
|
+
When `utc_to_local_returns_utc_offset_times` is false and the time
|
170
|
+
instance had fractional seconds the new UTC time instance was out by
|
171
|
+
a factor of 1,000,000 as the `Time.utc` constructor takes a usec
|
172
|
+
value and not a fractional second value.
|
472
173
|
|
473
|
-
*
|
174
|
+
*Andrew White*
|
474
175
|
|
475
|
-
|
476
|
-
being halted as second argument.
|
477
|
-
This change will allow you to differentiate which callbacks halted the chain
|
478
|
-
and act accordingly.
|
176
|
+
* Add `expires_at` argument to `ActiveSupport::Cache` `write` and `fetch` to set a cache entry TTL as an absolute time.
|
479
177
|
|
480
178
|
```ruby
|
481
|
-
|
482
|
-
before_save { throw(:abort) }
|
483
|
-
before_create { throw(:abort) }
|
484
|
-
|
485
|
-
def halted_callback_hook(filter, callback_name)
|
486
|
-
Rails.logger.info("Book couldn't be #{callback_name}d")
|
487
|
-
end
|
488
|
-
|
489
|
-
Book.create # => "Book couldn't be created"
|
490
|
-
book.save # => "Book couldn't be saved"
|
491
|
-
end
|
179
|
+
Rails.cache.write(key, value, expires_at: Time.now.at_end_of_hour)
|
492
180
|
```
|
493
181
|
|
494
|
-
*
|
495
|
-
|
496
|
-
* Support `prepend` with `ActiveSupport::Concern`.
|
497
|
-
|
498
|
-
Allows a module with `extend ActiveSupport::Concern` to be prepended.
|
499
|
-
|
500
|
-
module Imposter
|
501
|
-
extend ActiveSupport::Concern
|
502
|
-
|
503
|
-
# Same as `included`, except only run when prepended.
|
504
|
-
prepended do
|
505
|
-
end
|
506
|
-
end
|
507
|
-
|
508
|
-
class Person
|
509
|
-
prepend Imposter
|
510
|
-
end
|
511
|
-
|
512
|
-
Class methods are prepended to the base class, concerning is also
|
513
|
-
updated: `concerning :Imposter, prepend: true do`.
|
182
|
+
*Jean Boussier*
|
514
183
|
|
515
|
-
|
184
|
+
* Deprecate `ActiveSupport::TimeWithZone.name` so that from Rails 7.1 it will use the default implementation.
|
516
185
|
|
517
|
-
*
|
518
|
-
in a date time range. It is recommended to use `Range#cover?` method
|
519
|
-
instead of `Range#include?` to check the inclusion of a value
|
520
|
-
in a date time range.
|
186
|
+
*Andrew White*
|
521
187
|
|
522
|
-
|
188
|
+
* Deprecates Rails custom `Enumerable#sum` and `Array#sum` in favor of Ruby's native implementation which
|
189
|
+
is considerably faster.
|
523
190
|
|
524
|
-
|
191
|
+
Ruby requires an initializer for non-numeric type as per examples below:
|
525
192
|
|
526
193
|
```ruby
|
527
|
-
|
528
|
-
|
529
|
-
number_to_rounded(389.32314, precision: 0, round_mode: :ceil) # => "390"
|
530
|
-
number_to_human_size(483989, precision: 2, round_mode: :up) # => "480 KB"
|
531
|
-
number_to_human(489939, precision: 2, round_mode: :floor) # => "480 Thousand"
|
194
|
+
%w[foo bar].sum('')
|
195
|
+
# instead of %w[foo bar].sum
|
532
196
|
|
533
|
-
|
197
|
+
[[1, 2], [3, 4, 5]].sum([])
|
198
|
+
# instead of [[1, 2], [3, 4, 5]].sum
|
534
199
|
```
|
535
200
|
|
536
|
-
*
|
537
|
-
|
538
|
-
* `Array#to_sentence` no longer returns a frozen string.
|
201
|
+
*Alberto Mota*
|
539
202
|
|
540
|
-
|
203
|
+
* Tests parallelization is now disabled when running individual files to prevent the setup overhead.
|
541
204
|
|
542
|
-
|
543
|
-
# => true
|
205
|
+
It can still be enforced if the environment variable `PARALLEL_WORKERS` is present and set to a value greater than 1.
|
544
206
|
|
545
|
-
|
207
|
+
*Ricardo Díaz*
|
546
208
|
|
547
|
-
|
548
|
-
# => false
|
209
|
+
* Fix proxying keyword arguments in `ActiveSupport::CurrentAttributes`.
|
549
210
|
|
550
|
-
*
|
211
|
+
*Marcin Kołodziej*
|
551
212
|
|
552
|
-
*
|
553
|
-
|
213
|
+
* Add `Enumerable#maximum` and `Enumerable#minimum` to easily calculate the maximum or minimum from extracted
|
214
|
+
elements of an enumerable.
|
554
215
|
|
555
216
|
```ruby
|
556
|
-
|
557
|
-
# 1 week, 4 days, 13 hours, 46 minutes, and 40.0 seconds
|
558
|
-
|
559
|
-
duration_iso = duration.iso8601
|
560
|
-
# P11DT13H46M40S
|
561
|
-
|
562
|
-
ActiveSupport::Duration.parse(duration_iso)
|
563
|
-
# 11 days, 13 hours, 46 minutes, and 40 seconds
|
217
|
+
payments = [Payment.new(5), Payment.new(15), Payment.new(10)]
|
564
218
|
|
565
|
-
|
566
|
-
#
|
567
|
-
|
568
|
-
duration_iso = duration.iso8601
|
569
|
-
# P1W
|
570
|
-
|
571
|
-
ActiveSupport::Duration.parse(duration_iso)
|
572
|
-
# 1 week
|
219
|
+
payments.minimum(:price) # => 5
|
220
|
+
payments.maximum(:price) # => 15
|
573
221
|
```
|
574
222
|
|
575
|
-
|
576
|
-
|
577
|
-
* Add block support to `ActiveSupport::Testing::TimeHelpers#travel_back`.
|
578
|
-
|
579
|
-
*Tim Masliuchenko*
|
580
|
-
|
581
|
-
* Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
|
582
|
-
`ActiveSupport.parse_json_times = true`.
|
583
|
-
|
584
|
-
*Christian Gregg*
|
585
|
-
|
586
|
-
* Support symbolic links for `content_path` in `ActiveSupport::EncryptedFile`.
|
587
|
-
|
588
|
-
*Takumi Shotoku*
|
589
|
-
|
590
|
-
* Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
|
591
|
-
and endless range targets.
|
592
|
-
|
593
|
-
*Allen Hsu*, *Andrew Hodgkinson*
|
594
|
-
|
595
|
-
* Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
|
596
|
-
|
597
|
-
*Iain Beeston*
|
598
|
-
|
599
|
-
* Prevent `ActiveSupport::Duration.build(value)` from creating instances of
|
600
|
-
`ActiveSupport::Duration` unless `value` is of type `Numeric`.
|
601
|
-
|
602
|
-
Addresses the errant set of behaviours described in #37012 where
|
603
|
-
`ActiveSupport::Duration` comparisons would fail confusingly
|
604
|
-
or return unexpected results when comparing durations built from instances of `String`.
|
605
|
-
|
606
|
-
Before:
|
607
|
-
|
608
|
-
small_duration_from_string = ActiveSupport::Duration.build('9')
|
609
|
-
large_duration_from_string = ActiveSupport::Duration.build('100000000000000')
|
610
|
-
small_duration_from_int = ActiveSupport::Duration.build(9)
|
611
|
-
|
612
|
-
large_duration_from_string > small_duration_from_string
|
613
|
-
# => false
|
614
|
-
|
615
|
-
small_duration_from_string == small_duration_from_int
|
616
|
-
# => false
|
617
|
-
|
618
|
-
small_duration_from_int < large_duration_from_string
|
619
|
-
# => ArgumentError (comparison of ActiveSupport::Duration::Scalar with ActiveSupport::Duration failed)
|
223
|
+
This also allows passing enumerables to `fresh_when` and `stale?` in Action Controller.
|
224
|
+
See PR [#41404](https://github.com/rails/rails/pull/41404) for an example.
|
620
225
|
|
621
|
-
|
622
|
-
# => ArgumentError (comparison of String with ActiveSupport::Duration failed)
|
226
|
+
*Ayrton De Craene*
|
623
227
|
|
624
|
-
|
625
|
-
|
626
|
-
small_duration_from_string = ActiveSupport::Duration.build('9')
|
627
|
-
# => TypeError (can't build an ActiveSupport::Duration from a String)
|
628
|
-
|
629
|
-
*Alexei Emam*
|
630
|
-
|
631
|
-
* Add `ActiveSupport::Cache::Store#delete_multi` method to delete multiple keys from the cache store.
|
632
|
-
|
633
|
-
*Peter Zhu*
|
634
|
-
|
635
|
-
* Support multiple arguments in `HashWithIndifferentAccess` for `merge` and `update` methods, to
|
636
|
-
follow Ruby 2.6 addition.
|
637
|
-
|
638
|
-
*Wojciech Wnętrzak*
|
639
|
-
|
640
|
-
* Allow initializing `thread_mattr_*` attributes via `:default` option.
|
641
|
-
|
642
|
-
class Scraper
|
643
|
-
thread_mattr_reader :client, default: Api::Client.new
|
644
|
-
end
|
645
|
-
|
646
|
-
*Guilherme Mansur*
|
647
|
-
|
648
|
-
* Add `compact_blank` for those times when you want to remove #blank? values from
|
649
|
-
an Enumerable (also `compact_blank!` on Hash, Array, ActionController::Parameters).
|
650
|
-
|
651
|
-
*Dana Sherson*
|
652
|
-
|
653
|
-
* Make ActiveSupport::Logger Fiber-safe.
|
654
|
-
|
655
|
-
Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
|
656
|
-
to make log level local to Ruby Fibers in addition to Threads.
|
657
|
-
|
658
|
-
Example:
|
659
|
-
|
660
|
-
logger = ActiveSupport::Logger.new(STDOUT)
|
661
|
-
logger.level = 1
|
662
|
-
puts "Main is debug? #{logger.debug?}"
|
663
|
-
|
664
|
-
Fiber.new {
|
665
|
-
logger.local_level = 0
|
666
|
-
puts "Thread is debug? #{logger.debug?}"
|
667
|
-
}.resume
|
668
|
-
|
669
|
-
puts "Main is debug? #{logger.debug?}"
|
228
|
+
* `ActiveSupport::Cache::MemCacheStore` now accepts an explicit `nil` for its `addresses` argument.
|
670
229
|
|
671
|
-
|
230
|
+
```ruby
|
231
|
+
config.cache_store = :mem_cache_store, nil
|
672
232
|
|
673
|
-
|
674
|
-
Thread is debug? true
|
675
|
-
Main is debug? true
|
233
|
+
# is now equivalent to
|
676
234
|
|
677
|
-
|
235
|
+
config.cache_store = :mem_cache_store
|
678
236
|
|
679
|
-
|
680
|
-
Thread is debug? true
|
681
|
-
Main is debug? false
|
237
|
+
# and is also equivalent to
|
682
238
|
|
683
|
-
|
239
|
+
config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
|
684
240
|
|
685
|
-
|
241
|
+
# which is the fallback behavior of Dalli
|
242
|
+
```
|
686
243
|
|
687
|
-
|
688
|
-
passed at the constructor level.
|
244
|
+
This helps those migrating from `:dalli_store`, where an explicit `nil` was permitted.
|
689
245
|
|
690
|
-
|
246
|
+
*Michael Overmeyer*
|
691
247
|
|
692
|
-
|
693
|
-
crypt.decrypt_and_verify(encrypted_message, on_rotation: proc { ... })
|
694
|
-
crypt.decrypt_and_verify(another_encrypted_message, on_rotation: proc { ... })
|
248
|
+
* Add `Enumerable#in_order_of` to put an Enumerable in a certain order by a key.
|
695
249
|
|
696
|
-
|
250
|
+
*DHH*
|
697
251
|
|
698
|
-
|
699
|
-
|
700
|
-
crypt.decrypt_and_verify(another_encrypted_message)
|
252
|
+
* `ActiveSupport::Inflector.camelize` behaves expected when provided a symbol `:upper` or `:lower` argument. Matches
|
253
|
+
`String#camelize` behavior.
|
701
254
|
|
702
|
-
*
|
255
|
+
*Alex Ghiculescu*
|
703
256
|
|
704
|
-
* `
|
705
|
-
|
706
|
-
the user to specify they want `nil` returned in this case.
|
257
|
+
* Raises an `ArgumentError` when the first argument of `ActiveSupport::Notification.subscribe` is
|
258
|
+
invalid.
|
707
259
|
|
708
|
-
*
|
260
|
+
*Vipul A M*
|
709
261
|
|
710
|
-
* `
|
711
|
-
and a frozen string if it were long enough to be truncated. Now truncate will
|
712
|
-
consistently return an unfrozen string regardless. This behavior is consistent
|
713
|
-
with `gsub` and `strip`.
|
262
|
+
* `HashWithIndifferentAccess#deep_transform_keys` now returns a `HashWithIndifferentAccess` instead of a `Hash`.
|
714
263
|
|
715
|
-
|
264
|
+
*Nathaniel Woodthorpe*
|
716
265
|
|
717
|
-
|
718
|
-
# => true
|
719
|
-
'foobar'.truncate(6).frozen?
|
720
|
-
# => false
|
266
|
+
* Consume dalli’s `cache_nils` configuration as `ActiveSupport::Cache`'s `skip_nil` when using `MemCacheStore`.
|
721
267
|
|
722
|
-
|
268
|
+
*Ritikesh G*
|
723
269
|
|
724
|
-
|
725
|
-
# => false
|
726
|
-
'foobar'.truncate(6).frozen?
|
727
|
-
# => false
|
270
|
+
* Add `RedisCacheStore#stats` method similar to `MemCacheStore#stats`. Calls `redis#info` internally.
|
728
271
|
|
729
|
-
*
|
272
|
+
*Ritikesh G*
|
730
273
|
|
731
274
|
|
732
|
-
Please check [6-
|
275
|
+
Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/activesupport/CHANGELOG.md) for previous changes.
|