activesupport 6.0.4 → 6.1.4

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