activesupport 6.0.5.1 → 6.1.7.2

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.

Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +430 -458
  3. data/MIT-LICENSE +1 -1
  4. data/lib/active_support/array_inquirer.rb +4 -2
  5. data/lib/active_support/backtrace_cleaner.rb +3 -3
  6. data/lib/active_support/benchmarkable.rb +1 -1
  7. data/lib/active_support/cache/file_store.rb +3 -3
  8. data/lib/active_support/cache/mem_cache_store.rb +28 -18
  9. data/lib/active_support/cache/memory_store.rb +46 -26
  10. data/lib/active_support/cache/redis_cache_store.rb +25 -25
  11. data/lib/active_support/cache/strategy/local_cache.rb +20 -5
  12. data/lib/active_support/cache.rb +87 -40
  13. data/lib/active_support/callbacks.rb +65 -56
  14. data/lib/active_support/concern.rb +46 -2
  15. data/lib/active_support/configurable.rb +3 -3
  16. data/lib/active_support/configuration_file.rb +51 -0
  17. data/lib/active_support/core_ext/benchmark.rb +2 -2
  18. data/lib/active_support/core_ext/class/attribute.rb +34 -44
  19. data/lib/active_support/core_ext/class/subclasses.rb +17 -38
  20. data/lib/active_support/core_ext/date/conversions.rb +2 -1
  21. data/lib/active_support/core_ext/date_and_time/calculations.rb +13 -0
  22. data/lib/active_support/core_ext/date_and_time/compatibility.rb +15 -0
  23. data/lib/active_support/core_ext/digest/uuid.rb +1 -0
  24. data/lib/active_support/core_ext/enumerable.rb +76 -4
  25. data/lib/active_support/core_ext/hash/conversions.rb +2 -2
  26. data/lib/active_support/core_ext/hash/deep_transform_values.rb +1 -1
  27. data/lib/active_support/core_ext/hash/keys.rb +1 -1
  28. data/lib/active_support/core_ext/hash/slice.rb +3 -2
  29. data/lib/active_support/core_ext/load_error.rb +1 -1
  30. data/lib/active_support/core_ext/marshal.rb +2 -0
  31. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  32. data/lib/active_support/core_ext/module/attribute_accessors.rb +23 -29
  33. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +8 -4
  34. data/lib/active_support/core_ext/module/concerning.rb +8 -2
  35. data/lib/active_support/core_ext/module/delegation.rb +38 -28
  36. data/lib/active_support/core_ext/module/introspection.rb +1 -25
  37. data/lib/active_support/core_ext/name_error.rb +29 -2
  38. data/lib/active_support/core_ext/numeric/conversions.rb +22 -18
  39. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  40. data/lib/active_support/core_ext/object/json.rb +12 -1
  41. data/lib/active_support/core_ext/object/try.rb +2 -2
  42. data/lib/active_support/core_ext/range/compare_range.rb +9 -3
  43. data/lib/active_support/core_ext/range/include_time_with_zone.rb +8 -3
  44. data/lib/active_support/core_ext/regexp.rb +8 -1
  45. data/lib/active_support/core_ext/string/access.rb +5 -24
  46. data/lib/active_support/core_ext/string/conversions.rb +1 -0
  47. data/lib/active_support/core_ext/string/inflections.rb +38 -4
  48. data/lib/active_support/core_ext/string/inquiry.rb +1 -0
  49. data/lib/active_support/core_ext/string/multibyte.rb +2 -2
  50. data/lib/active_support/core_ext/string/output_safety.rb +3 -4
  51. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -2
  52. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +14 -0
  53. data/lib/active_support/core_ext/symbol.rb +3 -0
  54. data/lib/active_support/core_ext/time/calculations.rb +19 -0
  55. data/lib/active_support/core_ext/time/conversions.rb +2 -0
  56. data/lib/active_support/core_ext/uri.rb +5 -1
  57. data/lib/active_support/core_ext.rb +1 -1
  58. data/lib/active_support/current_attributes/test_helper.rb +13 -0
  59. data/lib/active_support/current_attributes.rb +9 -2
  60. data/lib/active_support/dependencies/zeitwerk_integration.rb +4 -1
  61. data/lib/active_support/dependencies.rb +37 -18
  62. data/lib/active_support/deprecation/behaviors.rb +15 -2
  63. data/lib/active_support/deprecation/disallowed.rb +56 -0
  64. data/lib/active_support/deprecation/instance_delegator.rb +0 -1
  65. data/lib/active_support/deprecation/method_wrappers.rb +3 -2
  66. data/lib/active_support/deprecation/proxy_wrappers.rb +2 -2
  67. data/lib/active_support/deprecation/reporting.rb +50 -7
  68. data/lib/active_support/deprecation.rb +6 -1
  69. data/lib/active_support/descendants_tracker.rb +6 -2
  70. data/lib/active_support/digest.rb +2 -0
  71. data/lib/active_support/duration/iso8601_serializer.rb +15 -9
  72. data/lib/active_support/duration.rb +75 -25
  73. data/lib/active_support/encrypted_file.rb +19 -2
  74. data/lib/active_support/environment_inquirer.rb +20 -0
  75. data/lib/active_support/evented_file_update_checker.rb +69 -133
  76. data/lib/active_support/fork_tracker.rb +64 -0
  77. data/lib/active_support/gem_version.rb +3 -3
  78. data/lib/active_support/hash_with_indifferent_access.rb +48 -24
  79. data/lib/active_support/i18n_railtie.rb +14 -19
  80. data/lib/active_support/inflector/inflections.rb +1 -2
  81. data/lib/active_support/inflector/methods.rb +36 -33
  82. data/lib/active_support/inflector/transliterate.rb +4 -4
  83. data/lib/active_support/json/decoding.rb +4 -4
  84. data/lib/active_support/json/encoding.rb +5 -1
  85. data/lib/active_support/key_generator.rb +1 -1
  86. data/lib/active_support/locale/en.yml +7 -3
  87. data/lib/active_support/log_subscriber.rb +8 -0
  88. data/lib/active_support/logger.rb +1 -1
  89. data/lib/active_support/logger_silence.rb +2 -26
  90. data/lib/active_support/logger_thread_safe_level.rb +34 -12
  91. data/lib/active_support/message_encryptor.rb +4 -7
  92. data/lib/active_support/message_verifier.rb +5 -5
  93. data/lib/active_support/messages/rotation_configuration.rb +2 -1
  94. data/lib/active_support/messages/rotator.rb +6 -5
  95. data/lib/active_support/multibyte/chars.rb +4 -42
  96. data/lib/active_support/multibyte/unicode.rb +9 -83
  97. data/lib/active_support/notifications/fanout.rb +23 -8
  98. data/lib/active_support/notifications/instrumenter.rb +6 -15
  99. data/lib/active_support/notifications.rb +32 -5
  100. data/lib/active_support/number_helper/number_converter.rb +1 -1
  101. data/lib/active_support/number_helper/number_to_human_converter.rb +1 -1
  102. data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -1
  103. data/lib/active_support/number_helper/number_to_rounded_converter.rb +9 -5
  104. data/lib/active_support/number_helper/rounding_helper.rb +12 -28
  105. data/lib/active_support/number_helper.rb +29 -14
  106. data/lib/active_support/option_merger.rb +2 -1
  107. data/lib/active_support/ordered_options.rb +8 -2
  108. data/lib/active_support/parameter_filter.rb +16 -11
  109. data/lib/active_support/per_thread_registry.rb +2 -1
  110. data/lib/active_support/rails.rb +1 -4
  111. data/lib/active_support/railtie.rb +23 -1
  112. data/lib/active_support/rescuable.rb +4 -4
  113. data/lib/active_support/secure_compare_rotator.rb +51 -0
  114. data/lib/active_support/security_utils.rb +19 -12
  115. data/lib/active_support/string_inquirer.rb +4 -2
  116. data/lib/active_support/subscriber.rb +12 -7
  117. data/lib/active_support/tagged_logging.rb +30 -5
  118. data/lib/active_support/testing/assertions.rb +18 -11
  119. data/lib/active_support/testing/parallelization/server.rb +78 -0
  120. data/lib/active_support/testing/parallelization/worker.rb +100 -0
  121. data/lib/active_support/testing/parallelization.rb +12 -95
  122. data/lib/active_support/testing/time_helpers.rb +40 -3
  123. data/lib/active_support/time_with_zone.rb +67 -43
  124. data/lib/active_support/values/time_zone.rb +22 -10
  125. data/lib/active_support/xml_mini/rexml.rb +8 -1
  126. data/lib/active_support.rb +13 -1
  127. metadata +34 -36
  128. data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -5
  129. data/lib/active_support/core_ext/hash/compact.rb +0 -5
  130. data/lib/active_support/core_ext/hash/transform_values.rb +0 -5
  131. data/lib/active_support/core_ext/module/reachable.rb +0 -6
  132. data/lib/active_support/core_ext/numeric/inquiry.rb +0 -5
  133. data/lib/active_support/core_ext/range/include_range.rb +0 -9
data/CHANGELOG.md CHANGED
@@ -1,772 +1,744 @@
1
- ## Rails 6.0.5.1 (July 12, 2022) ##
1
+ ## Rails 6.1.7.2 (January 24, 2023) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 6.0.5 (May 09, 2022) ##
6
+ ## Rails 6.1.7.1 (January 17, 2023) ##
7
7
 
8
- * No changes.
9
-
10
-
11
- ## Rails 6.0.4.8 (April 26, 2022) ##
12
-
13
- * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
14
-
15
- Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
16
- in names of tags and names of attributes, following the specification of XML.
8
+ * Avoid regex backtracking in Inflector.underscore
17
9
 
18
- *Álvaro Martín Fraguas*
10
+ [CVE-2023-22796]
19
11
 
20
12
 
21
- ## Rails 6.0.4.7 (March 08, 2022) ##
13
+ ## Rails 6.1.7 (September 09, 2022) ##
22
14
 
23
15
  * No changes.
24
16
 
25
17
 
26
- ## Rails 6.0.4.6 (February 11, 2022) ##
27
-
28
- * Fix Reloader method signature to work with the new Executor signature
29
-
30
-
31
- ## Rails 6.0.4.5 (February 11, 2022) ##
18
+ ## Rails 6.1.6.1 (July 12, 2022) ##
32
19
 
33
20
  * No changes.
34
21
 
35
22
 
36
- ## Rails 6.0.4.4 (December 15, 2021) ##
23
+ ## Rails 6.1.6 (May 09, 2022) ##
37
24
 
38
25
  * No changes.
39
26
 
40
27
 
41
- ## Rails 6.0.4.3 (December 14, 2021) ##
28
+ ## Rails 6.1.5.1 (April 26, 2022) ##
42
29
 
43
- * No changes.
30
+ * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
44
31
 
32
+ Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
33
+ in names of tags and names of attributes, following the specification of XML.
45
34
 
46
- ## Rails 6.0.4.2 (December 14, 2021) ##
35
+ *Álvaro Martín Fraguas*
47
36
 
48
- * No changes.
37
+ ## Rails 6.1.5 (March 09, 2022) ##
49
38
 
39
+ * Fix `ActiveSupport::Duration.build` to support negative values.
50
40
 
51
- ## Rails 6.0.4.1 (August 19, 2021) ##
41
+ The algorithm to collect the `parts` of the `ActiveSupport::Duration`
42
+ ignored the sign of the `value` and accumulated incorrect part values. This
43
+ impacted `ActiveSupport::Duration#sum` (which is dependent on `parts`) but
44
+ not `ActiveSupport::Duration#eql?` (which is dependent on `value`).
52
45
 
53
- * No changes.
46
+ *Caleb Buxton*, *Braden Staudacher*
54
47
 
48
+ * `Time#change` and methods that call it (eg. `Time#advance`) will now
49
+ return a `Time` with the timezone argument provided, if the caller was
50
+ initialized with a timezone argument.
55
51
 
56
- ## Rails 6.0.4 (June 15, 2021) ##
52
+ Fixes [#42467](https://github.com/rails/rails/issues/42467).
57
53
 
58
- * Fixed issue in `ActiveSupport::Cache::RedisCacheStore` not passing options
59
- to `read_multi` causing `fetch_multi` to not work properly.
54
+ *Alex Ghiculescu*
60
55
 
61
- *Rajesh Sharma*
56
+ * Clone to keep extended Logger methods for tagged logger.
62
57
 
63
- * `with_options` copies its options hash again to avoid leaking mutations.
58
+ *Orhan Toy*
64
59
 
65
- Fixes #39343.
60
+ * `assert_changes` works on including `ActiveSupport::Assertions` module.
66
61
 
67
- *Eugene Kenny*
62
+ *Pedro Medeiros*
68
63
 
69
64
 
70
- ## Rails 6.0.3.7 (May 05, 2021) ##
65
+ ## Rails 6.1.4.7 (March 08, 2022) ##
71
66
 
72
67
  * No changes.
73
68
 
74
69
 
75
- ## Rails 6.0.3.6 (March 26, 2021) ##
70
+ ## Rails 6.1.4.6 (February 11, 2022) ##
76
71
 
77
- * No changes.
72
+ * Fix Reloader method signature to work with the new Executor signature
78
73
 
79
74
 
80
- ## Rails 6.0.3.5 (February 10, 2021) ##
75
+ ## Rails 6.1.4.5 (February 11, 2022) ##
81
76
 
82
77
  * No changes.
83
78
 
84
79
 
85
- ## Rails 6.0.3.4 (October 07, 2020) ##
80
+ ## Rails 6.1.4.4 (December 15, 2021) ##
86
81
 
87
82
  * No changes.
88
83
 
89
84
 
90
- ## Rails 6.0.3.3 (September 09, 2020) ##
85
+ ## Rails 6.1.4.3 (December 14, 2021) ##
91
86
 
92
87
  * No changes.
93
88
 
94
89
 
95
- ## Rails 6.0.3.2 (June 17, 2020) ##
90
+ ## Rails 6.1.4.2 (December 14, 2021) ##
96
91
 
97
92
  * No changes.
98
93
 
99
94
 
100
- ## Rails 6.0.3.1 (May 18, 2020) ##
95
+ ## Rails 6.1.4.1 (August 19, 2021) ##
101
96
 
102
- * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
97
+ * No changes.
103
98
 
104
- * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
105
99
 
100
+ ## Rails 6.1.4 (June 24, 2021) ##
106
101
 
107
- ## Rails 6.0.3 (May 06, 2020) ##
102
+ * MemCacheStore: convert any underlying value (including `false`) to an `Entry`.
108
103
 
109
- * `Array#to_sentence` no longer returns a frozen string.
104
+ See [#42559](https://github.com/rails/rails/pull/42559).
110
105
 
111
- Before:
106
+ *Alex Ghiculescu*
112
107
 
113
- ['one', 'two'].to_sentence.frozen?
114
- # => true
108
+ * Fix bug in `number_with_precision` when using large `BigDecimal` values.
115
109
 
116
- After:
110
+ Fixes #42302.
117
111
 
118
- ['one', 'two'].to_sentence.frozen?
119
- # => false
120
-
121
- *Nicolas Dular*
112
+ *Federico Aldunate*, *Zachary Scott*
122
113
 
123
- * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
124
- `ActiveSupport.parse_json_times = true`.
114
+ * Check byte size instead of length on `secure_compare`.
125
115
 
126
- *Christian Gregg*
116
+ *Tietew*
127
117
 
118
+ * Fix `Time.at` to not lose `:in` option.
128
119
 
129
- ## Rails 6.0.2.2 (March 19, 2020) ##
120
+ *Ryuta Kamizono*
130
121
 
131
- * No changes.
122
+ * Require a path for `config.cache_store = :file_store`.
132
123
 
124
+ *Alex Ghiculescu*
133
125
 
134
- ## Rails 6.0.2.1 (December 18, 2019) ##
126
+ * Avoid having to store complex object in the default translation file.
135
127
 
136
- * No changes.
128
+ *Rafael Mendonça França*
137
129
 
138
130
 
139
- ## Rails 6.0.2 (December 13, 2019) ##
131
+ ## Rails 6.1.3.2 (May 05, 2021) ##
140
132
 
141
- * Eager load translations during initialization.
133
+ * No changes.
142
134
 
143
- *Diego Plentz*
144
135
 
145
- * Use per-thread CPU time clock on `ActiveSupport::Notifications`.
136
+ ## Rails 6.1.3.1 (March 26, 2021) ##
146
137
 
147
- *George Claghorn*
138
+ * No changes.
148
139
 
149
140
 
150
- ## Rails 6.0.1 (November 5, 2019) ##
141
+ ## Rails 6.1.3 (February 17, 2021) ##
151
142
 
152
- * `ActiveSupport::SafeBuffer` supports `Enumerator` methods.
143
+ * No changes.
153
144
 
154
- *Shugo Maeda*
155
145
 
156
- * The Redis cache store fails gracefully when the server returns a "max number
157
- of clients reached" error.
146
+ ## Rails 6.1.2.1 (February 10, 2021) ##
158
147
 
159
- *Brandon Medenwald*
148
+ * No changes.
160
149
 
161
- * Fixed that mutating a value returned by a memory cache store would
162
- unexpectedly change the cached value.
163
150
 
164
- *Jonathan Hyman*
151
+ ## Rails 6.1.2 (February 09, 2021) ##
165
152
 
166
- * The default inflectors in `zeitwerk` mode support overrides:
153
+ * `ActiveSupport::Cache::MemCacheStore` now accepts an explicit `nil` for its `addresses` argument.
167
154
 
168
155
  ```ruby
169
- # config/initializers/zeitwerk.rb
170
- Rails.autoloaders.each do |autoloader|
171
- autoloader.inflector.inflect(
172
- "html_parser" => "HTMLParser",
173
- "ssl_error" => "SSLError"
174
- )
175
- end
176
- ```
177
-
178
- 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.
156
+ config.cache_store = :mem_cache_store, nil
179
157
 
180
- 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.
181
-
182
- *Xavier Noria*
158
+ # is now equivalent to
183
159
 
184
- * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
185
- and endless range targets.
160
+ config.cache_store = :mem_cache_store
186
161
 
187
- *Allen Hsu*, *Andrew Hodgkinson*
162
+ # and is also equivalent to
188
163
 
189
- * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
190
-
191
- *Iain Beeston*
192
-
193
-
194
- ## Rails 6.0.0 (August 16, 2019) ##
195
-
196
- * Let `require_dependency` in `zeitwerk` mode look the autoload paths up for
197
- better backwards compatibility.
198
-
199
- *Xavier Noria*
164
+ config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
200
165
 
201
- * Let `require_dependency` in `zeitwerk` mode support arguments that respond
202
- to `to_path` for better backwards compatibility.
166
+ # which is the fallback behavior of Dalli
167
+ ```
203
168
 
204
- *Xavier Noria*
169
+ This helps those migrating from `:dalli_store`, where an explicit `nil` was permitted.
205
170
 
206
- * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
171
+ *Michael Overmeyer*
207
172
 
208
- Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
209
- to make log level local to Ruby Fibers in addition to Threads.
210
173
 
211
- Example:
174
+ ## Rails 6.1.1 (January 07, 2021) ##
212
175
 
213
- logger = ActiveSupport::Logger.new(STDOUT)
214
- logger.level = 1
215
- p "Main is debug? #{logger.debug?}"
216
-
217
- Fiber.new {
218
- logger.local_level = 0
219
- p "Thread is debug? #{logger.debug?}"
220
- }.resume
221
-
222
- p "Main is debug? #{logger.debug?}"
176
+ * Change `IPAddr#to_json` to match the behavior of the json gem returning the string representation
177
+ instead of the instance variables of the object.
223
178
 
224
179
  Before:
225
180
 
226
- Main is debug? false
227
- Thread is debug? true
228
- Main is debug? true
181
+ ```ruby
182
+ IPAddr.new("127.0.0.1").to_json
183
+ # => "{\"addr\":2130706433,\"family\":2,\"mask_addr\":4294967295}"
184
+ ```
229
185
 
230
186
  After:
231
187
 
232
- Main is debug? false
233
- Thread is debug? true
234
- Main is debug? false
188
+ ```ruby
189
+ IPAddr.new("127.0.0.1").to_json
190
+ # => "\"127.0.0.1\""
191
+ ```
235
192
 
236
- *Alexander Varnin*
237
193
 
238
- * Do not delegate missing `marshal_dump` and `_dump` methods via the
239
- `delegate_missing_to` extension. This avoids unintentionally adding instance
240
- variables when calling `Marshal.dump(object)`, should the delegation target of
241
- `object` be a method which would otherwise add them. Fixes #36522.
194
+ ## Rails 6.1.0 (December 09, 2020) ##
242
195
 
243
- *Aaron Lipman*
196
+ * Ensure `MemoryStore` disables compression by default. Reverts behavior of
197
+ `MemoryStore` to its prior rails `5.1` behavior.
244
198
 
199
+ *Max Gurewitz*
245
200
 
246
- ## Rails 6.0.0.rc2 (July 22, 2019) ##
201
+ * Calling `iso8601` on negative durations retains the negative sign on individual
202
+ digits instead of prepending it.
247
203
 
248
- * `truncate` would return the original string if it was too short to be truncated
249
- and a frozen string if it were long enough to be truncated. Now truncate will
250
- consistently return an unfrozen string regardless. This behavior is consistent
251
- with `gsub` and `strip`.
204
+ This change is required so we can interoperate with PostgreSQL, which prefers
205
+ negative signs for each component.
206
+
207
+ Compatibility with other iso8601 parsers which support leading negatives as well
208
+ as negatives per component is still retained.
252
209
 
253
210
  Before:
254
211
 
255
- 'foobar'.truncate(5).frozen?
256
- # => true
257
- 'foobar'.truncate(6).frozen?
258
- # => false
212
+ (-1.year - 1.day).iso8601
213
+ # => "-P1Y1D"
259
214
 
260
215
  After:
261
216
 
262
- 'foobar'.truncate(5).frozen?
263
- # => false
264
- 'foobar'.truncate(6).frozen?
265
- # => false
266
-
267
- *Jordan Thomas*
217
+ (-1.year - 1.day).iso8601
218
+ # => "P-1Y-1D"
268
219
 
220
+ *Vipul A M*
269
221
 
270
- ## Rails 6.0.0.rc1 (April 24, 2019) ##
222
+ * Remove deprecated `ActiveSupport::Notifications::Instrumenter#end=`.
271
223
 
272
- * Speed improvements to `Hash.except` and `HashWithIndifferentAccess#except`.
273
-
274
- These methods now unset the `default`/`default_proc` on the returned Hash, compatible with Ruby 3.0’s native implementation.
275
-
276
- *Timo Schilling*
277
-
278
- * Introduce `ActiveSupport::ActionableError`.
279
-
280
- Actionable errors let's you dispatch actions from Rails' error pages. This
281
- can help you save time if you have a clear action for the resolution of
282
- common development errors.
224
+ *Rafael Mendonça França*
283
225
 
284
- The de-facto example are pending migrations. Every time pending migrations
285
- are found, a middleware raises an error. With actionable errors, you can
286
- run the migrations right from the error page. Other examples include Rails
287
- plugins that need to run a rake task to setup themselves. They can now
288
- raise actionable errors to run the setup straight from the error pages.
226
+ * Deprecate `ActiveSupport::Multibyte::Unicode.default_normalization_form`.
289
227
 
290
- Here is how to define an actionable error:
228
+ *Rafael Mendonça França*
291
229
 
292
- ```ruby
293
- class PendingMigrationError < MigrationError #:nodoc:
294
- include ActiveSupport::ActionableError
230
+ * Remove deprecated `ActiveSupport::Multibyte::Unicode.pack_graphemes`,
231
+ `ActiveSupport::Multibyte::Unicode.unpack_graphemes`,
232
+ `ActiveSupport::Multibyte::Unicode.normalize`,
233
+ `ActiveSupport::Multibyte::Unicode.downcase`,
234
+ `ActiveSupport::Multibyte::Unicode.upcase` and `ActiveSupport::Multibyte::Unicode.swapcase`.
295
235
 
296
- action "Run pending migrations" do
297
- ActiveRecord::Tasks::DatabaseTasks.migrate
298
- end
299
- end
300
- ```
236
+ *Rafael Mendonça França*
301
237
 
302
- To make an error actionable, include the `ActiveSupport::ActionableError`
303
- module and invoke the `action` class macro to define the action. An action
304
- needs a name and a procedure to execute. The name is shown as the name of a
305
- button on the error pages. Once clicked, it will invoke the given
306
- procedure.
238
+ * Remove deprecated `ActiveSupport::Multibyte::Chars#consumes?` and `ActiveSupport::Multibyte::Chars#normalize`.
307
239
 
308
- *Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
240
+ *Rafael Mendonça França*
309
241
 
310
- * Preserve `html_safe?` status on `ActiveSupport::SafeBuffer#*`.
242
+ * Remove deprecated file `active_support/core_ext/range/include_range`.
311
243
 
312
- Before:
244
+ *Rafael Mendonça França*
313
245
 
314
- ("<br />".html_safe * 2).html_safe? #=> nil
246
+ * Remove deprecated file `active_support/core_ext/hash/transform_values`.
315
247
 
316
- After:
248
+ *Rafael Mendonça França*
317
249
 
318
- ("<br />".html_safe * 2).html_safe? #=> true
250
+ * Remove deprecated file `active_support/core_ext/hash/compact`.
319
251
 
320
- *Ryo Nakamura*
252
+ *Rafael Mendonça França*
321
253
 
322
- * Calling test methods with `with_info_handler` method to allow minitest-hooks
323
- plugin to work.
254
+ * Remove deprecated file `active_support/core_ext/array/prepend_and_append`.
324
255
 
325
- *Mauri Mustonen*
256
+ *Rafael Mendonça França*
326
257
 
327
- * The Zeitwerk compatibility interface for `ActiveSupport::Dependencies` no
328
- longer implements `autoloaded_constants` or `autoloaded?` (undocumented,
329
- anyway). Experience shows introspection does not have many use cases, and
330
- troubleshooting is done by logging. With this design trade-off we are able
331
- to use even less memory in all environments.
258
+ * Remove deprecated file `active_support/core_ext/numeric/inquiry`.
332
259
 
333
- *Xavier Noria*
260
+ *Rafael Mendonça França*
334
261
 
335
- * Depends on Zeitwerk 2, which stores less metadata if reloading is disabled
336
- and hence uses less memory when `config.cache_classes` is `true`, a standard
337
- setup in production.
262
+ * Remove deprecated file `active_support/core_ext/module/reachable`.
338
263
 
339
- *Xavier Noria*
264
+ *Rafael Mendonça França*
340
265
 
341
- * In `:zeitwerk` mode, eager load directories in engines and applications only
342
- if present in their respective `config.eager_load_paths`.
266
+ * Remove deprecated `Module#parent_name`, `Module#parent` and `Module#parents`.
343
267
 
344
- A common use case for this is adding `lib` to `config.autoload_paths`, but
345
- not to `config.eager_load_paths`. In that configuration, for example, files
346
- in the `lib` directory should not be eager loaded.
268
+ *Rafael Mendonça França*
347
269
 
348
- *Xavier Noria*
270
+ * Remove deprecated `ActiveSupport::LoggerThreadSafeLevel#after_initialize`.
349
271
 
350
- * Fix bug in Range comparisons when comparing to an excluded-end Range
272
+ *Rafael Mendonça França*
351
273
 
352
- Before:
274
+ * Remove deprecated `LoggerSilence` constant.
353
275
 
354
- (1..10).cover?(1...11) # => false
276
+ *Rafael Mendonça França*
355
277
 
356
- After:
278
+ * Remove deprecated fallback to `I18n.default_local` when `config.i18n.fallbacks` is empty.
357
279
 
358
- (1..10).cover?(1...11) # => true
280
+ *Rafael Mendonça França*
359
281
 
360
- With the same change for `Range#include?` and `Range#===`.
282
+ * Remove entries from local cache on `RedisCacheStore#delete_matched`
361
283
 
362
- *Owen Stephens*
284
+ Fixes #38627
363
285
 
364
- * Use weak references in descendants tracker to allow anonymous subclasses to
365
- be garbage collected.
286
+ *ojab*
366
287
 
367
- *Edgars Beigarts*
288
+ * Speed up `ActiveSupport::SecurityUtils.fixed_length_secure_compare` by using
289
+ `OpenSSL.fixed_length_secure_compare`, if available.
368
290
 
369
- * Update `ActiveSupport::Notifications::Instrumenter#instrument` to make
370
- passing a block optional. This will let users use
371
- `ActiveSupport::Notifications` messaging features outside of
372
- instrumentation.
291
+ *Nate Matykiewicz*
373
292
 
374
- *Ali Ibrahim*
293
+ * `ActiveSupport::Cache::MemCacheStore` now checks `ENV["MEMCACHE_SERVERS"]` before falling back to `"localhost:11211"` if configured without any addresses.
375
294
 
376
- * Fix `Time#advance` to work with dates before 1001-03-07
295
+ ```ruby
296
+ config.cache_store = :mem_cache_store
377
297
 
378
- Before:
298
+ # is now equivalent to
379
299
 
380
- Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-05 00:00:00 UTC
300
+ config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
381
301
 
382
- After
302
+ # instead of
383
303
 
384
- Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-06 00:00:00 UTC
304
+ config.cache_store = :mem_cache_store, "localhost:11211" # ignores ENV["MEMCACHE_SERVERS"]
305
+ ```
385
306
 
386
- Note that this doesn't affect `DateTime#advance` as that doesn't use a proleptic calendar.
307
+ *Sam Bostock*
387
308
 
388
- *Andrew White*
309
+ * `ActiveSupport::Subscriber#attach_to` now accepts an `inherit_all:` argument. When set to true,
310
+ it allows a subscriber to receive events for methods defined in the subscriber's ancestor class(es).
389
311
 
390
- * In Zeitwerk mode, engines are now managed by the `main` autoloader. Engines may reference application constants, if the application is reloaded and we do not reload engines, they won't use the reloaded application code.
312
+ ```ruby
313
+ class ActionControllerSubscriber < ActiveSupport::Subscriber
314
+ attach_to :action_controller
391
315
 
392
- *Xavier Noria*
316
+ def start_processing(event)
317
+ info "Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}"
318
+ end
393
319
 
394
- * Add support for supplying `locale` to `transliterate` and `parameterize`.
320
+ def redirect_to(event)
321
+ info { "Redirected to #{event.payload[:location]}" }
322
+ end
323
+ end
395
324
 
396
- I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { "ü" => "ue" } } })
325
+ # We detach ActionControllerSubscriber from the :action_controller namespace so that our CustomActionControllerSubscriber
326
+ # can provide its own instrumentation for certain events in the namespace
327
+ ActionControllerSubscriber.detach_from(:action_controller)
397
328
 
398
- ActiveSupport::Inflector.transliterate("ü", locale: :de) # => "ue"
399
- "Fünf autos".parameterize(locale: :de) # => "fuenf-autos"
400
- ActiveSupport::Inflector.parameterize("Fünf autos", locale: :de) # => "fuenf-autos"
329
+ class CustomActionControllerSubscriber < ActionControllerSubscriber
330
+ attach_to :action_controller, inherit_all: true
401
331
 
402
- *Kaan Ozkan*, *Sharang Dashputre*
332
+ def start_processing(event)
333
+ info "A custom response to start_processing events"
334
+ end
403
335
 
404
- * Allow `Array#excluding` and `Enumerable#excluding` to deal with a passed array gracefully.
336
+ # => CustomActionControllerSubscriber will process events for "start_processing.action_controller" notifications
337
+ # using its own #start_processing implementation, while retaining ActionControllerSubscriber's instrumentation
338
+ # for "redirect_to.action_controller" notifications
339
+ end
340
+ ```
405
341
 
406
- [ 1, 2, 3, 4, 5 ].excluding([4, 5]) # => [ 1, 2, 3 ]
342
+ *Adrianna Chang*
407
343
 
408
- *DHH*
344
+ * Allow the digest class used to generate non-sensitive digests to be configured with `config.active_support.hash_digest_class`.
409
345
 
410
- * Renamed `Array#without` and `Enumerable#without` to `Array#excluding` and `Enumerable#excluding`, to create parity with
411
- `Array#including` and `Enumerable#including`. Retained the old names as aliases.
346
+ `config.active_support.use_sha1_digests` is deprecated in favour of `config.active_support.hash_digest_class = ::Digest::SHA1`.
412
347
 
413
- *DHH*
348
+ *Dirkjan Bussink*
414
349
 
415
- * Added `Array#including` and `Enumerable#including` to conveniently enlarge a collection with more members using a method rather than an operator:
350
+ * Fix bug to make memcached write_entry expire correctly with unless_exist
416
351
 
417
- [ 1, 2, 3 ].including(4, 5) # => [ 1, 2, 3, 4, 5 ]
418
- post.authors.including(Current.person) # => All the authors plus the current person!
352
+ *Jye Lee*
419
353
 
420
- *DHH*
354
+ * Add `ActiveSupport::Duration` conversion methods
421
355
 
356
+ `in_seconds`, `in_minutes`, `in_hours`, `in_days`, `in_weeks`, `in_months`, and `in_years` return the respective duration covered.
422
357
 
423
- ## Rails 6.0.0.beta3 (March 11, 2019) ##
358
+ *Jason York*
424
359
 
425
- * No changes.
360
+ * Fixed issue in `ActiveSupport::Cache::RedisCacheStore` not passing options
361
+ to `read_multi` causing `fetch_multi` to not work properly
426
362
 
363
+ *Rajesh Sharma*
427
364
 
428
- ## Rails 6.0.0.beta2 (February 25, 2019) ##
365
+ * Fixed issue in `ActiveSupport::Cache::MemCacheStore` which caused duplicate compression,
366
+ and caused the provided `compression_threshold` to not be respected.
429
367
 
430
- * New autoloading based on [Zeitwerk](https://github.com/fxn/zeitwerk).
368
+ *Max Gurewitz*
431
369
 
432
- *Xavier Noria*
370
+ * Prevent `RedisCacheStore` and `MemCacheStore` from performing compression
371
+ when reading entries written with `raw: true`.
433
372
 
434
- * Revise `ActiveSupport::Notifications.unsubscribe` to correctly handle Regex or other multiple-pattern subscribers.
373
+ *Max Gurewitz*
435
374
 
436
- *Zach Kemp*
375
+ * `URI.parser` is deprecated and will be removed in Rails 7.0. Use
376
+ `URI::DEFAULT_PARSER` instead.
437
377
 
438
- * Add `before_reset` callback to `CurrentAttributes` and define `after_reset` as an alias of `resets` for symmetry.
378
+ *Jean Boussier*
439
379
 
440
- *Rosa Gutierrez*
380
+ * `require_dependency` has been documented to be _obsolete_ in `:zeitwerk`
381
+ mode. The method is not deprecated as such (yet), but applications are
382
+ encouraged to not use it.
441
383
 
442
- * Remove the `` Kernel#` `` override that suppresses ENOENT and accidentally returns nil on Unix systems.
384
+ In `:zeitwerk` mode, semantics match Ruby's and you do not need to be
385
+ defensive with load order. Just refer to classes and modules normally. If
386
+ the constant name is dynamic, camelize if needed, and constantize.
443
387
 
444
- *Akinori Musha*
388
+ *Xavier Noria*
445
389
 
446
- * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
390
+ * Add 3rd person aliases of `Symbol#start_with?` and `Symbol#end_with?`.
447
391
 
448
- `assoc` can now be called with either a string or a symbol.
392
+ ```ruby
393
+ :foo.starts_with?("f") # => true
394
+ :foo.ends_with?("o") # => true
395
+ ```
449
396
 
450
- *Stefan Schüßler*
397
+ *Ryuta Kamizono*
451
398
 
452
- * Add `Hash#deep_transform_values`, and `Hash#deep_transform_values!`.
399
+ * Add override of unary plus for `ActiveSupport::Duration`.
453
400
 
454
- *Guillermo Iguaran*
401
+ `+ 1.second` is now identical to `+1.second` to prevent errors
402
+ where a seemingly innocent change of formatting leads to a change in the code behavior.
455
403
 
404
+ Before:
405
+ ```ruby
406
+ +1.second.class
407
+ # => ActiveSupport::Duration
408
+ (+ 1.second).class
409
+ # => Integer
410
+ ```
456
411
 
457
- ## Rails 6.0.0.beta1 (January 18, 2019) ##
412
+ After:
413
+ ```ruby
414
+ +1.second.class
415
+ # => ActiveSupport::Duration
416
+ (+ 1.second).class
417
+ # => ActiveSupport::Duration
418
+ ```
458
419
 
459
- * Remove deprecated `Module#reachable?` method.
420
+ Fixes #39079.
460
421
 
461
- *Rafael Mendonça França*
422
+ *Roman Kushnir*
462
423
 
463
- * Remove deprecated `#acronym_regex` method from `Inflections`.
424
+ * Add subsec to `ActiveSupport::TimeWithZone#inspect`.
464
425
 
465
- *Rafael Mendonça França*
426
+ Before:
466
427
 
467
- * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
428
+ Time.at(1498099140).in_time_zone.inspect
429
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
430
+ Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
431
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
432
+ Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
433
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
468
434
 
469
- *Keenan Brock*
435
+ After:
470
436
 
471
- * Preserve key order passed to `ActiveSupport::CacheStore#fetch_multi`.
437
+ Time.at(1498099140).in_time_zone.inspect
438
+ # => "Thu, 22 Jun 2017 02:39:00.000000000 UTC +00:00"
439
+ Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
440
+ # => "Thu, 22 Jun 2017 02:39:00.123456780 UTC +00:00"
441
+ Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
442
+ # => "Thu, 22 Jun 2017 02:39:00.333333333 UTC +00:00"
472
443
 
473
- `fetch_multi(*names)` now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
444
+ *akinomaeni*
474
445
 
475
- *Gannon McGibbon*
446
+ * Calling `ActiveSupport::TaggedLogging#tagged` without a block now returns a tagged logger.
476
447
 
477
- * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
448
+ ```ruby
449
+ logger.tagged("BCX").info("Funky time!") # => [BCX] Funky time!
450
+ ```
478
451
 
479
- *Mark J. Titorenko*, *Vlad Bokov*
452
+ *Eugene Kenny*
480
453
 
481
- * Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
482
- would not act as alias for `#symbolize_keys`.
454
+ * Align `Range#cover?` extension behavior with Ruby behavior for backwards ranges.
483
455
 
484
- *Nick Weiland*
456
+ `(1..10).cover?(5..3)` now returns `false`, as it does in plain Ruby.
485
457
 
486
- * Improve the logic that detects non-autoloaded constants.
458
+ Also update `#include?` and `#===` behavior to match.
487
459
 
488
- *Jan Habermann*, *Xavier Noria*
460
+ *Michael Groeneman*
489
461
 
490
- * Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSupport::Multibyte::Unicode#unpack_graphemes(string)`
491
- in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
462
+ * Update to TZInfo v2.0.0.
492
463
 
493
- *Francesco Rodríguez*
464
+ This changes the output of `ActiveSupport::TimeZone.utc_to_local`, but
465
+ can be controlled with the
466
+ `ActiveSupport.utc_to_local_returns_utc_offset_times` config.
494
467
 
495
- * Deprecate `ActiveSupport::Multibyte::Chars.consumes?` in favor of `String#is_utf8?`.
468
+ New Rails 6.1 apps have it enabled by default, existing apps can upgrade
469
+ via the config in config/initializers/new_framework_defaults_6_1.rb
496
470
 
497
- *Francesco Rodríguez*
471
+ See the `utc_to_local_returns_utc_offset_times` documentation for details.
498
472
 
499
- * Fix duration being rounded to a full second.
500
- ```
501
- time = DateTime.parse("2018-1-1")
502
- time += 0.51.seconds
503
- ```
504
- Will now correctly add 0.51 second and not 1 full second.
473
+ *Phil Ross*, *Jared Beck*
505
474
 
506
- *Edouard Chin*
475
+ * Add Date and Time `#yesterday?` and `#tomorrow?` alongside `#today?`.
507
476
 
508
- * Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSupport::Multibyte::Chars#normalize`
509
- in favor of `String#unicode_normalize`
477
+ Aliased to `#prev_day?` and `#next_day?` to match the existing `#prev/next_day` methods.
510
478
 
511
- *Francesco Rodríguez*
479
+ *Jatin Dhankhar*
512
480
 
513
- * Deprecate `ActiveSupport::Multibyte::Unicode#downcase/upcase/swapcase` in favor of
514
- `String#downcase/upcase/swapcase`.
481
+ * Add `Enumerable#pick` to complement `ActiveRecord::Relation#pick`.
515
482
 
516
- *Francesco Rodríguez*
483
+ *Eugene Kenny*
517
484
 
518
- * Add `ActiveSupport::ParameterFilter`.
485
+ * [Breaking change] `ActiveSupport::Callbacks#halted_callback_hook` now receive a 2nd argument:
519
486
 
520
- *Yoshiyuki Kinjo*
487
+ `ActiveSupport::Callbacks#halted_callback_hook` now receive the name of the callback
488
+ being halted as second argument.
489
+ This change will allow you to differentiate which callbacks halted the chain
490
+ and act accordingly.
521
491
 
522
- * Rename `Module#parent`, `Module#parents`, and `Module#parent_name` to
523
- `module_parent`, `module_parents`, and `module_parent_name`.
492
+ ```ruby
493
+ class Book < ApplicationRecord
494
+ before_save { throw(:abort) }
495
+ before_create { throw(:abort) }
524
496
 
525
- *Gannon McGibbon*
497
+ def halted_callback_hook(filter, callback_name)
498
+ Rails.logger.info("Book couldn't be #{callback_name}d")
499
+ end
526
500
 
527
- * Deprecate the use of `LoggerSilence` in favor of `ActiveSupport::LoggerSilence`
501
+ Book.create # => "Book couldn't be created"
502
+ book.save # => "Book couldn't be saved"
503
+ end
504
+ ```
528
505
 
529
506
  *Edouard Chin*
530
507
 
531
- * Deprecate using negative limits in `String#first` and `String#last`.
508
+ * Support `prepend` with `ActiveSupport::Concern`.
532
509
 
533
- *Gannon McGibbon*, *Eric Turner*
510
+ Allows a module with `extend ActiveSupport::Concern` to be prepended.
534
511
 
535
- * Fix bug where `#without` for `ActiveSupport::HashWithIndifferentAccess` would fail
536
- with symbol arguments
512
+ module Imposter
513
+ extend ActiveSupport::Concern
537
514
 
538
- *Abraham Chan*
539
-
540
- * Treat `#delete_prefix`, `#delete_suffix` and `#unicode_normalize` results as non-`html_safe`.
541
- Ensure safety of arguments for `#insert`, `#[]=` and `#replace` calls on `html_safe` Strings.
542
-
543
- *Janosch Müller*
544
-
545
- * Changed `ActiveSupport::TaggedLogging.new` to return a new logger instance instead
546
- of mutating the one received as parameter.
547
-
548
- *Thierry Joyal*
515
+ # Same as `included`, except only run when prepended.
516
+ prepended do
517
+ end
518
+ end
549
519
 
550
- * Define `unfreeze_time` as an alias of `travel_back` in `ActiveSupport::Testing::TimeHelpers`.
520
+ class Person
521
+ prepend Imposter
522
+ end
551
523
 
552
- The alias is provided for symmetry with `freeze_time`.
524
+ Class methods are prepended to the base class, concerning is also
525
+ updated: `concerning :Imposter, prepend: true do`.
553
526
 
554
- *Ryan Davidson*
527
+ *Jason Karns*, *Elia Schito*
555
528
 
556
- * Add support for tracing constant autoloads. Just throw
529
+ * Deprecate using `Range#include?` method to check the inclusion of a value
530
+ in a date time range. It is recommended to use `Range#cover?` method
531
+ instead of `Range#include?` to check the inclusion of a value
532
+ in a date time range.
557
533
 
558
- ActiveSupport::Dependencies.logger = Rails.logger
559
- ActiveSupport::Dependencies.verbose = true
534
+ *Vishal Telangre*
560
535
 
561
- in an initializer.
536
+ * Support added for a `round_mode` parameter, in all number helpers. (See: `BigDecimal::mode`.)
562
537
 
563
- *Xavier Noria*
564
-
565
- * Maintain `html_safe?` on html_safe strings when sliced.
538
+ ```ruby
539
+ number_to_currency(1234567890.50, precision: 0, round_mode: :half_down) # => "$1,234,567,890"
540
+ number_to_percentage(302.24398923423, precision: 5, round_mode: :down) # => "302.24398%"
541
+ number_to_rounded(389.32314, precision: 0, round_mode: :ceil) # => "390"
542
+ number_to_human_size(483989, precision: 2, round_mode: :up) # => "480 KB"
543
+ number_to_human(489939, precision: 2, round_mode: :floor) # => "480 Thousand"
566
544
 
567
- string = "<div>test</div>".html_safe
568
- string[-1..1].html_safe? # => true
545
+ 485000.to_s(:human, precision: 2, round_mode: :half_even) # => "480 Thousand"
546
+ ```
569
547
 
570
- *Elom Gomez*, *Yumin Wong*
548
+ *Tom Lord*
571
549
 
572
- * Add `Array#extract!`.
550
+ * `Array#to_sentence` no longer returns a frozen string.
573
551
 
574
- The method removes and returns the elements for which the block returns a true value.
575
- If no block is given, an Enumerator is returned instead.
552
+ Before:
576
553
 
577
- numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
578
- odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
579
- numbers # => [0, 2, 4, 6, 8]
554
+ ['one', 'two'].to_sentence.frozen?
555
+ # => true
580
556
 
581
- *bogdanvlviv*
557
+ After:
582
558
 
583
- * Support not to cache `nil` for `ActiveSupport::Cache#fetch`.
559
+ ['one', 'two'].to_sentence.frozen?
560
+ # => false
584
561
 
585
- cache.fetch('bar', skip_nil: true) { nil }
586
- cache.exist?('bar') # => false
562
+ *Nicolas Dular*
587
563
 
588
- *Martin Hong*
564
+ * When an instance of `ActiveSupport::Duration` is converted to an `iso8601` duration string, if `weeks` are mixed with `date` parts, the `week` part will be converted to days.
565
+ This keeps the parser and serializer on the same page.
589
566
 
590
- * Add "event object" support to the notification system.
591
- Before this change, end users were forced to create hand made artisanal
592
- event objects on their own, like this:
567
+ ```ruby
568
+ duration = ActiveSupport::Duration.build(1000000)
569
+ # 1 week, 4 days, 13 hours, 46 minutes, and 40.0 seconds
593
570
 
594
- ActiveSupport::Notifications.subscribe('wait') do |*args|
595
- @event = ActiveSupport::Notifications::Event.new(*args)
596
- end
571
+ duration_iso = duration.iso8601
572
+ # P11DT13H46M40S
597
573
 
598
- ActiveSupport::Notifications.instrument('wait') do
599
- sleep 1
600
- end
574
+ ActiveSupport::Duration.parse(duration_iso)
575
+ # 11 days, 13 hours, 46 minutes, and 40 seconds
601
576
 
602
- @event.duration # => 1000.138
577
+ duration = ActiveSupport::Duration.build(604800)
578
+ # 1 week
603
579
 
604
- After this change, if the block passed to `subscribe` only takes one
605
- parameter, the framework will yield an event object to the block. Now
606
- end users are no longer required to make their own:
580
+ duration_iso = duration.iso8601
581
+ # P1W
607
582
 
608
- ActiveSupport::Notifications.subscribe('wait') do |event|
609
- @event = event
610
- end
583
+ ActiveSupport::Duration.parse(duration_iso)
584
+ # 1 week
585
+ ```
611
586
 
612
- ActiveSupport::Notifications.instrument('wait') do
613
- sleep 1
614
- end
587
+ *Abhishek Sarkar*
615
588
 
616
- p @event.allocations # => 7
617
- p @event.cpu_time # => 0.256
618
- p @event.idle_time # => 1003.2399
589
+ * Add block support to `ActiveSupport::Testing::TimeHelpers#travel_back`.
619
590
 
620
- Now you can enjoy event objects without making them yourself. Neat!
591
+ *Tim Masliuchenko*
621
592
 
622
- *Aaron "t.lo" Patterson*
593
+ * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
594
+ `ActiveSupport.parse_json_times = true`.
623
595
 
624
- * Add cpu_time, idle_time, and allocations to Event.
596
+ *Christian Gregg*
625
597
 
626
- *Eileen M. Uchitelle*, *Aaron Patterson*
598
+ * Support symbolic links for `content_path` in `ActiveSupport::EncryptedFile`.
627
599
 
628
- * RedisCacheStore: support key expiry in increment/decrement.
600
+ *Takumi Shotoku*
629
601
 
630
- Pass `:expires_in` to `#increment` and `#decrement` to set a Redis EXPIRE on the key.
602
+ * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
603
+ and endless range targets.
631
604
 
632
- If the key is already set to expire, RedisCacheStore won't extend its expiry.
605
+ *Allen Hsu*, *Andrew Hodgkinson*
633
606
 
634
- Rails.cache.increment("some_key", 1, expires_in: 2.minutes)
607
+ * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
635
608
 
636
- *Jason Lee*
609
+ *Iain Beeston*
637
610
 
638
- * Allow `Range#===` and `Range#cover?` on Range.
611
+ * Prevent `ActiveSupport::Duration.build(value)` from creating instances of
612
+ `ActiveSupport::Duration` unless `value` is of type `Numeric`.
639
613
 
640
- `Range#cover?` can now accept a range argument like `Range#include?` and
641
- `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
642
- into a new file, with these two methods.
614
+ Addresses the errant set of behaviours described in #37012 where
615
+ `ActiveSupport::Duration` comparisons would fail confusingly
616
+ or return unexpected results when comparing durations built from instances of `String`.
643
617
 
644
- *Requiring active_support/core_ext/range/include_range is now deprecated.*
645
- *Use `require "active_support/core_ext/range/compare_range"` instead.*
618
+ Before:
646
619
 
647
- *utilum*
620
+ small_duration_from_string = ActiveSupport::Duration.build('9')
621
+ large_duration_from_string = ActiveSupport::Duration.build('100000000000000')
622
+ small_duration_from_int = ActiveSupport::Duration.build(9)
648
623
 
649
- * Add `index_with` to Enumerable.
624
+ large_duration_from_string > small_duration_from_string
625
+ # => false
650
626
 
651
- Allows creating a hash from an enumerable with the value from a passed block
652
- or a default argument.
627
+ small_duration_from_string == small_duration_from_int
628
+ # => false
653
629
 
654
- %i( title body ).index_with { |attr| post.public_send(attr) }
655
- # => { title: "hey", body: "what's up?" }
630
+ small_duration_from_int < large_duration_from_string
631
+ # => ArgumentError (comparison of ActiveSupport::Duration::Scalar with ActiveSupport::Duration failed)
656
632
 
657
- %i( title body ).index_with(nil)
658
- # => { title: nil, body: nil }
633
+ large_duration_from_string > small_duration_from_int
634
+ # => ArgumentError (comparison of String with ActiveSupport::Duration failed)
659
635
 
660
- Closely linked with `index_by`, which creates a hash where the keys are extracted from a block.
636
+ After:
661
637
 
662
- *Kasper Timm Hansen*
638
+ small_duration_from_string = ActiveSupport::Duration.build('9')
639
+ # => TypeError (can't build an ActiveSupport::Duration from a String)
663
640
 
664
- * Fix bug where `ActiveSupport::TimeZone.all` would fail when tzinfo data for
665
- any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
641
+ *Alexei Emam*
666
642
 
667
- *Dominik Sander*
643
+ * Add `ActiveSupport::Cache::Store#delete_multi` method to delete multiple keys from the cache store.
668
644
 
669
- * Redis cache store: `delete_matched` no longer blocks the Redis server.
670
- (Switches from evaled Lua to a batched SCAN + DEL loop.)
645
+ *Peter Zhu*
671
646
 
672
- *Gleb Mazovetskiy*
647
+ * Support multiple arguments in `HashWithIndifferentAccess` for `merge` and `update` methods, to
648
+ follow Ruby 2.6 addition.
673
649
 
674
- * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
675
- size when compression is enabled (which is true by default). This patch
676
- does not attempt to repair existing data: please manually flush the cache
677
- to clear out the problematic entries.
650
+ *Wojciech Wnętrzak*
678
651
 
679
- *Godfrey Chan*
652
+ * Allow initializing `thread_mattr_*` attributes via `:default` option.
680
653
 
681
- * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
654
+ class Scraper
655
+ thread_mattr_reader :client, default: Api::Client.new
656
+ end
682
657
 
683
- URI.unescape("\xe3\x83\x90") # => "バ"
684
- URI.unescape("%E3%83%90") # => "バ"
685
- URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
658
+ *Guilherme Mansur*
686
659
 
687
- *Ashe Connor*, *Aaron Patterson*
660
+ * Add `compact_blank` for those times when you want to remove #blank? values from
661
+ an Enumerable (also `compact_blank!` on Hash, Array, ActionController::Parameters).
688
662
 
689
- * Add `before?` and `after?` methods to `Date`, `DateTime`,
690
- `Time`, and `TimeWithZone`.
663
+ *Dana Sherson*
691
664
 
692
- *Nick Holden*
665
+ * Make ActiveSupport::Logger Fiber-safe.
693
666
 
694
- * `ActiveSupport::Inflector#ordinal` and `ActiveSupport::Inflector#ordinalize` now support
695
- translations through I18n.
667
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
668
+ to make log level local to Ruby Fibers in addition to Threads.
696
669
 
697
- # locale/fr.rb
670
+ Example:
698
671
 
699
- {
700
- fr: {
701
- number: {
702
- nth: {
703
- ordinals: lambda do |_key, number:, **_options|
704
- if number.to_i.abs == 1
705
- 'er'
706
- else
707
- 'e'
708
- end
709
- end,
672
+ logger = ActiveSupport::Logger.new(STDOUT)
673
+ logger.level = 1
674
+ puts "Main is debug? #{logger.debug?}"
710
675
 
711
- ordinalized: lambda do |_key, number:, **_options|
712
- "#{number}#{ActiveSupport::Inflector.ordinal(number)}"
713
- end
714
- }
715
- }
716
- }
717
- }
676
+ Fiber.new {
677
+ logger.local_level = 0
678
+ puts "Thread is debug? #{logger.debug?}"
679
+ }.resume
718
680
 
681
+ puts "Main is debug? #{logger.debug?}"
719
682
 
720
- *Christian Blais*
683
+ Before:
721
684
 
722
- * Add `:private` option to ActiveSupport's `Module#delegate`
723
- in order to delegate methods as private:
685
+ Main is debug? false
686
+ Thread is debug? true
687
+ Main is debug? true
724
688
 
725
- class User < ActiveRecord::Base
726
- has_one :profile
727
- delegate :date_of_birth, to: :profile, private: true
689
+ After:
728
690
 
729
- def age
730
- Date.today.year - date_of_birth.year
731
- end
732
- end
691
+ Main is debug? false
692
+ Thread is debug? true
693
+ Main is debug? false
733
694
 
734
- # User.new.age # => 29
735
- # User.new.date_of_birth
736
- # => NoMethodError: private method `date_of_birth' called for #<User:0x00000008221340>
695
+ Fixes #36752.
737
696
 
738
- *Tomas Valent*
697
+ *Alexander Varnin*
739
698
 
740
- * `String#truncate_bytes` to truncate a string to a maximum bytesize without
741
- breaking multibyte characters or grapheme clusters like 👩‍👩‍👦‍👦.
699
+ * Allow the `on_rotation` proc used when decrypting/verifying a message to be
700
+ passed at the constructor level.
742
701
 
743
- *Jeremy Daer*
702
+ Before:
744
703
 
745
- * `String#strip_heredoc` preserves frozenness.
704
+ crypt = ActiveSupport::MessageEncryptor.new('long_secret')
705
+ crypt.decrypt_and_verify(encrypted_message, on_rotation: proc { ... })
706
+ crypt.decrypt_and_verify(another_encrypted_message, on_rotation: proc { ... })
746
707
 
747
- "foo".freeze.strip_heredoc.frozen? # => true
708
+ After:
748
709
 
749
- Fixes that frozen string literals would inadvertently become unfrozen:
710
+ crypt = ActiveSupport::MessageEncryptor.new('long_secret', on_rotation: proc { ... })
711
+ crypt.decrypt_and_verify(encrypted_message)
712
+ crypt.decrypt_and_verify(another_encrypted_message)
750
713
 
751
- # frozen_string_literal: true
714
+ *Edouard Chin*
752
715
 
753
- foo = <<-MSG.strip_heredoc
754
- la la la
755
- MSG
716
+ * `delegate_missing_to` would raise a `DelegationError` if the object
717
+ delegated to was `nil`. Now the `allow_nil` option has been added to enable
718
+ the user to specify they want `nil` returned in this case.
756
719
 
757
- foo.frozen? # => false !??
720
+ *Matthew Tanous*
758
721
 
759
- *Jeremy Daer*
722
+ * `truncate` would return the original string if it was too short to be truncated
723
+ and a frozen string if it were long enough to be truncated. Now truncate will
724
+ consistently return an unfrozen string regardless. This behavior is consistent
725
+ with `gsub` and `strip`.
760
726
 
761
- * Rails 6 requires Ruby 2.5.0 or newer.
727
+ Before:
762
728
 
763
- *Jeremy Daer*, *Kasper Timm Hansen*
729
+ 'foobar'.truncate(5).frozen?
730
+ # => true
731
+ 'foobar'.truncate(6).frozen?
732
+ # => false
764
733
 
765
- * Adds parallel testing to Rails.
734
+ After:
766
735
 
767
- Parallelize your test suite with forked processes or threads.
736
+ 'foobar'.truncate(5).frozen?
737
+ # => false
738
+ 'foobar'.truncate(6).frozen?
739
+ # => false
768
740
 
769
- *Eileen M. Uchitelle*, *Aaron Patterson*
741
+ *Jordan Thomas*
770
742
 
771
743
 
772
- Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activesupport/CHANGELOG.md) for previous changes.
744
+ Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activesupport/CHANGELOG.md) for previous changes.