activesupport 5.2.5 → 6.0.4.6

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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +477 -398
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -3
  5. data/lib/active_support/actionable_error.rb +48 -0
  6. data/lib/active_support/backtrace_cleaner.rb +27 -1
  7. data/lib/active_support/cache/file_store.rb +32 -32
  8. data/lib/active_support/cache/mem_cache_store.rb +12 -7
  9. data/lib/active_support/cache/memory_store.rb +15 -9
  10. data/lib/active_support/cache/null_store.rb +8 -3
  11. data/lib/active_support/cache/redis_cache_store.rb +47 -20
  12. data/lib/active_support/cache/strategy/local_cache.rb +22 -22
  13. data/lib/active_support/cache.rb +71 -48
  14. data/lib/active_support/callbacks.rb +16 -8
  15. data/lib/active_support/concern.rb +24 -1
  16. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
  17. data/lib/active_support/concurrency/share_lock.rb +0 -1
  18. data/lib/active_support/configurable.rb +7 -11
  19. data/lib/active_support/core_ext/array/access.rb +18 -6
  20. data/lib/active_support/core_ext/array/conversions.rb +5 -5
  21. data/lib/active_support/core_ext/array/extract.rb +21 -0
  22. data/lib/active_support/core_ext/array/prepend_and_append.rb +2 -6
  23. data/lib/active_support/core_ext/array.rb +1 -1
  24. data/lib/active_support/core_ext/class/attribute.rb +11 -16
  25. data/lib/active_support/core_ext/class/subclasses.rb +1 -1
  26. data/lib/active_support/core_ext/date/calculations.rb +6 -5
  27. data/lib/active_support/core_ext/date_and_time/calculations.rb +24 -47
  28. data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
  29. data/lib/active_support/core_ext/date_time/calculations.rb +1 -1
  30. data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
  31. data/lib/active_support/core_ext/enumerable.rb +97 -73
  32. data/lib/active_support/core_ext/hash/compact.rb +2 -26
  33. data/lib/active_support/core_ext/hash/conversions.rb +1 -1
  34. data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
  35. data/lib/active_support/core_ext/hash/except.rb +2 -2
  36. data/lib/active_support/core_ext/hash/keys.rb +0 -29
  37. data/lib/active_support/core_ext/hash/slice.rb +3 -25
  38. data/lib/active_support/core_ext/hash/transform_values.rb +2 -29
  39. data/lib/active_support/core_ext/hash.rb +1 -2
  40. data/lib/active_support/core_ext/integer/multiple.rb +1 -1
  41. data/lib/active_support/core_ext/kernel.rb +0 -1
  42. data/lib/active_support/core_ext/load_error.rb +1 -1
  43. data/lib/active_support/core_ext/module/attribute_accessors.rb +7 -10
  44. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +13 -19
  45. data/lib/active_support/core_ext/module/delegation.rb +41 -8
  46. data/lib/active_support/core_ext/module/introspection.rb +38 -13
  47. data/lib/active_support/core_ext/module/reachable.rb +1 -6
  48. data/lib/active_support/core_ext/module/redefine_method.rb +8 -17
  49. data/lib/active_support/core_ext/module.rb +0 -1
  50. data/lib/active_support/core_ext/numeric/conversions.rb +124 -128
  51. data/lib/active_support/core_ext/numeric/inquiry.rb +2 -25
  52. data/lib/active_support/core_ext/numeric.rb +0 -1
  53. data/lib/active_support/core_ext/object/blank.rb +1 -2
  54. data/lib/active_support/core_ext/object/duplicable.rb +7 -114
  55. data/lib/active_support/core_ext/object/json.rb +2 -1
  56. data/lib/active_support/core_ext/object/try.rb +17 -7
  57. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  58. data/lib/active_support/core_ext/range/compare_range.rb +28 -13
  59. data/lib/active_support/core_ext/range/conversions.rb +31 -29
  60. data/lib/active_support/core_ext/range/each.rb +0 -1
  61. data/lib/active_support/core_ext/range/include_range.rb +6 -0
  62. data/lib/active_support/core_ext/range/include_time_with_zone.rb +2 -2
  63. data/lib/active_support/core_ext/regexp.rb +0 -4
  64. data/lib/active_support/core_ext/securerandom.rb +23 -3
  65. data/lib/active_support/core_ext/string/access.rb +8 -0
  66. data/lib/active_support/core_ext/string/filters.rb +42 -1
  67. data/lib/active_support/core_ext/string/inflections.rb +7 -2
  68. data/lib/active_support/core_ext/string/multibyte.rb +4 -3
  69. data/lib/active_support/core_ext/string/output_safety.rb +68 -10
  70. data/lib/active_support/core_ext/string/strip.rb +3 -1
  71. data/lib/active_support/core_ext/time/calculations.rb +34 -3
  72. data/lib/active_support/core_ext/uri.rb +1 -0
  73. data/lib/active_support/current_attributes.rb +8 -0
  74. data/lib/active_support/dependencies/zeitwerk_integration.rb +117 -0
  75. data/lib/active_support/dependencies.rb +74 -18
  76. data/lib/active_support/deprecation/behaviors.rb +1 -1
  77. data/lib/active_support/deprecation/method_wrappers.rb +17 -23
  78. data/lib/active_support/deprecation/proxy_wrappers.rb +28 -5
  79. data/lib/active_support/deprecation.rb +1 -1
  80. data/lib/active_support/descendants_tracker.rb +55 -9
  81. data/lib/active_support/duration/iso8601_parser.rb +2 -4
  82. data/lib/active_support/duration/iso8601_serializer.rb +3 -5
  83. data/lib/active_support/duration.rb +7 -8
  84. data/lib/active_support/encrypted_configuration.rb +0 -4
  85. data/lib/active_support/encrypted_file.rb +3 -2
  86. data/lib/active_support/evented_file_update_checker.rb +39 -10
  87. data/lib/active_support/execution_wrapper.rb +17 -13
  88. data/lib/active_support/file_update_checker.rb +0 -1
  89. data/lib/active_support/gem_version.rb +4 -4
  90. data/lib/active_support/hash_with_indifferent_access.rb +22 -18
  91. data/lib/active_support/i18n.rb +1 -0
  92. data/lib/active_support/i18n_railtie.rb +13 -1
  93. data/lib/active_support/inflector/inflections.rb +1 -5
  94. data/lib/active_support/inflector/methods.rb +16 -29
  95. data/lib/active_support/inflector/transliterate.rb +47 -18
  96. data/lib/active_support/json/decoding.rb +23 -24
  97. data/lib/active_support/json/encoding.rb +6 -2
  98. data/lib/active_support/key_generator.rb +0 -32
  99. data/lib/active_support/lazy_load_hooks.rb +5 -2
  100. data/lib/active_support/locale/en.rb +33 -0
  101. data/lib/active_support/log_subscriber.rb +31 -9
  102. data/lib/active_support/logger.rb +1 -16
  103. data/lib/active_support/logger_silence.rb +28 -12
  104. data/lib/active_support/logger_thread_safe_level.rb +26 -4
  105. data/lib/active_support/message_encryptor.rb +4 -6
  106. data/lib/active_support/message_verifier.rb +5 -5
  107. data/lib/active_support/messages/metadata.rb +11 -2
  108. data/lib/active_support/messages/rotator.rb +4 -4
  109. data/lib/active_support/multibyte/chars.rb +29 -49
  110. data/lib/active_support/multibyte/unicode.rb +44 -282
  111. data/lib/active_support/notifications/fanout.rb +98 -13
  112. data/lib/active_support/notifications/instrumenter.rb +80 -9
  113. data/lib/active_support/notifications.rb +41 -4
  114. data/lib/active_support/number_helper/number_converter.rb +4 -5
  115. data/lib/active_support/number_helper/number_to_currency_converter.rb +4 -9
  116. data/lib/active_support/number_helper/number_to_delimited_converter.rb +3 -2
  117. data/lib/active_support/number_helper/number_to_human_converter.rb +3 -2
  118. data/lib/active_support/number_helper/number_to_human_size_converter.rb +3 -2
  119. data/lib/active_support/number_helper/number_to_percentage_converter.rb +3 -1
  120. data/lib/active_support/number_helper/number_to_phone_converter.rb +2 -1
  121. data/lib/active_support/number_helper/number_to_rounded_converter.rb +5 -4
  122. data/lib/active_support/number_helper/rounding_helper.rb +1 -1
  123. data/lib/active_support/number_helper.rb +11 -0
  124. data/lib/active_support/option_merger.rb +21 -3
  125. data/lib/active_support/ordered_hash.rb +1 -1
  126. data/lib/active_support/ordered_options.rb +5 -1
  127. data/lib/active_support/parameter_filter.rb +128 -0
  128. data/lib/active_support/rails.rb +0 -6
  129. data/lib/active_support/reloader.rb +5 -6
  130. data/lib/active_support/security_utils.rb +1 -1
  131. data/lib/active_support/string_inquirer.rb +0 -1
  132. data/lib/active_support/subscriber.rb +65 -26
  133. data/lib/active_support/tagged_logging.rb +13 -4
  134. data/lib/active_support/test_case.rb +91 -0
  135. data/lib/active_support/testing/assertions.rb +15 -1
  136. data/lib/active_support/testing/deprecation.rb +0 -1
  137. data/lib/active_support/testing/file_fixtures.rb +2 -0
  138. data/lib/active_support/testing/isolation.rb +2 -2
  139. data/lib/active_support/testing/method_call_assertions.rb +28 -1
  140. data/lib/active_support/testing/parallelization.rb +134 -0
  141. data/lib/active_support/testing/stream.rb +1 -2
  142. data/lib/active_support/testing/time_helpers.rb +7 -9
  143. data/lib/active_support/time_with_zone.rb +15 -5
  144. data/lib/active_support/values/time_zone.rb +12 -7
  145. data/lib/active_support/xml_mini/jdom.rb +2 -3
  146. data/lib/active_support/xml_mini/libxml.rb +2 -2
  147. data/lib/active_support/xml_mini/libxmlsax.rb +4 -4
  148. data/lib/active_support/xml_mini/nokogiri.rb +2 -2
  149. data/lib/active_support/xml_mini/nokogirisax.rb +3 -3
  150. data/lib/active_support/xml_mini/rexml.rb +2 -2
  151. data/lib/active_support/xml_mini.rb +2 -10
  152. data/lib/active_support.rb +2 -1
  153. metadata +40 -12
  154. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -13
  155. data/lib/active_support/values/unicode_tables.dat +0 -0
data/CHANGELOG.md CHANGED
@@ -1,35 +1,182 @@
1
- ## Rails 5.2.5 (March 26, 2021) ##
1
+ ## Rails 6.0.4.6 (February 11, 2022) ##
2
+
3
+ * Fix Reloader method signature to work with the new Executor signature
4
+
5
+
6
+ ## Rails 6.0.4.5 (February 11, 2022) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 6.0.4.4 (December 15, 2021) ##
2
12
 
3
13
  * No changes.
4
14
 
5
15
 
6
- ## Rails 5.2.4.5 (February 10, 2021) ##
16
+ ## Rails 6.0.4.3 (December 14, 2021) ##
7
17
 
8
18
  * No changes.
9
19
 
10
20
 
11
- ## Rails 5.2.4.4 (September 09, 2020) ##
21
+ ## Rails 6.0.4.2 (December 14, 2021) ##
12
22
 
13
23
  * No changes.
14
24
 
15
25
 
16
- ## Rails 5.2.4.3 (May 18, 2020) ##
26
+ ## Rails 6.0.4.1 (August 19, 2021) ##
27
+
28
+ * No changes.
29
+
30
+
31
+ ## Rails 6.0.4 (June 15, 2021) ##
32
+
33
+ * Fixed issue in `ActiveSupport::Cache::RedisCacheStore` not passing options
34
+ to `read_multi` causing `fetch_multi` to not work properly.
35
+
36
+ *Rajesh Sharma*
37
+
38
+ * `with_options` copies its options hash again to avoid leaking mutations.
39
+
40
+ Fixes #39343.
41
+
42
+ *Eugene Kenny*
43
+
44
+
45
+ ## Rails 6.0.3.7 (May 05, 2021) ##
46
+
47
+ * No changes.
48
+
49
+
50
+ ## Rails 6.0.3.6 (March 26, 2021) ##
51
+
52
+ * No changes.
53
+
54
+
55
+ ## Rails 6.0.3.5 (February 10, 2021) ##
56
+
57
+ * No changes.
58
+
59
+
60
+ ## Rails 6.0.3.4 (October 07, 2020) ##
61
+
62
+ * No changes.
63
+
64
+
65
+ ## Rails 6.0.3.3 (September 09, 2020) ##
66
+
67
+ * No changes.
68
+
69
+
70
+ ## Rails 6.0.3.2 (June 17, 2020) ##
71
+
72
+ * No changes.
73
+
74
+
75
+ ## Rails 6.0.3.1 (May 18, 2020) ##
17
76
 
18
77
  * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
19
78
 
20
79
  * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
21
80
 
22
- ## Rails 5.2.4.2 (March 19, 2020) ##
81
+
82
+ ## Rails 6.0.3 (May 06, 2020) ##
83
+
84
+ * `Array#to_sentence` no longer returns a frozen string.
85
+
86
+ Before:
87
+
88
+ ['one', 'two'].to_sentence.frozen?
89
+ # => true
90
+
91
+ After:
92
+
93
+ ['one', 'two'].to_sentence.frozen?
94
+ # => false
95
+
96
+ *Nicolas Dular*
97
+
98
+ * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
99
+ `ActiveSupport.parse_json_times = true`.
100
+
101
+ *Christian Gregg*
102
+
103
+
104
+ ## Rails 6.0.2.2 (March 19, 2020) ##
23
105
 
24
106
  * No changes.
25
107
 
26
108
 
27
- ## Rails 5.2.4.1 (December 18, 2019) ##
109
+ ## Rails 6.0.2.1 (December 18, 2019) ##
28
110
 
29
111
  * No changes.
30
112
 
31
113
 
32
- ## Rails 5.2.4 (November 27, 2019) ##
114
+ ## Rails 6.0.2 (December 13, 2019) ##
115
+
116
+ * Eager load translations during initialization.
117
+
118
+ *Diego Plentz*
119
+
120
+ * Use per-thread CPU time clock on `ActiveSupport::Notifications`.
121
+
122
+ *George Claghorn*
123
+
124
+
125
+ ## Rails 6.0.1 (November 5, 2019) ##
126
+
127
+ * `ActiveSupport::SafeBuffer` supports `Enumerator` methods.
128
+
129
+ *Shugo Maeda*
130
+
131
+ * The Redis cache store fails gracefully when the server returns a "max number
132
+ of clients reached" error.
133
+
134
+ *Brandon Medenwald*
135
+
136
+ * Fixed that mutating a value returned by a memory cache store would
137
+ unexpectedly change the cached value.
138
+
139
+ *Jonathan Hyman*
140
+
141
+ * The default inflectors in `zeitwerk` mode support overrides:
142
+
143
+ ```ruby
144
+ # config/initializers/zeitwerk.rb
145
+ Rails.autoloaders.each do |autoloader|
146
+ autoloader.inflector.inflect(
147
+ "html_parser" => "HTMLParser",
148
+ "ssl_error" => "SSLError"
149
+ )
150
+ end
151
+ ```
152
+
153
+ 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.
154
+
155
+ 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.
156
+
157
+ *Xavier Noria*
158
+
159
+ * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
160
+ and endless range targets.
161
+
162
+ *Allen Hsu*, *Andrew Hodgkinson*
163
+
164
+ * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
165
+
166
+ *Iain Beeston*
167
+
168
+
169
+ ## Rails 6.0.0 (August 16, 2019) ##
170
+
171
+ * Let `require_dependency` in `zeitwerk` mode look the autoload paths up for
172
+ better backwards compatibility.
173
+
174
+ *Xavier Noria*
175
+
176
+ * Let `require_dependency` in `zeitwerk` mode support arguments that respond
177
+ to `to_path` for better backwards compatibility.
178
+
179
+ *Xavier Noria*
33
180
 
34
181
  * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
35
182
 
@@ -63,606 +210,538 @@
63
210
 
64
211
  *Alexander Varnin*
65
212
 
213
+ * Do not delegate missing `marshal_dump` and `_dump` methods via the
214
+ `delegate_missing_to` extension. This avoids unintentionally adding instance
215
+ variables when calling `Marshal.dump(object)`, should the delegation target of
216
+ `object` be a method which would otherwise add them. Fixes #36522.
66
217
 
67
- ## Rails 5.2.3 (March 27, 2019) ##
68
-
69
- * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
70
-
71
- `assoc` can now be called with either a string or a symbol.
218
+ *Aaron Lipman*
72
219
 
73
- *Stefan Schüßler*
74
220
 
75
- * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
221
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
76
222
 
77
- *Keenan Brock*
223
+ * `truncate` would return the original string if it was too short to be truncated
224
+ and a frozen string if it were long enough to be truncated. Now truncate will
225
+ consistently return an unfrozen string regardless. This behavior is consistent
226
+ with `gsub` and `strip`.
78
227
 
79
- * Allow Range#=== and Range#cover? on Range
228
+ Before:
80
229
 
81
- `Range#cover?` can now accept a range argument like `Range#include?` and
82
- `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
83
- into a new file, with these two methods.
230
+ 'foobar'.truncate(5).frozen?
231
+ # => true
232
+ 'foobar'.truncate(6).frozen?
233
+ # => false
84
234
 
85
- *utilum*
235
+ After:
86
236
 
87
- * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
237
+ 'foobar'.truncate(5).frozen?
238
+ # => false
239
+ 'foobar'.truncate(6).frozen?
240
+ # => false
88
241
 
89
- *Mark J. Titorenko*, *Vlad Bokov*
242
+ *Jordan Thomas*
90
243
 
91
244
 
92
- ## Rails 5.2.2.1 (March 11, 2019) ##
245
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
93
246
 
94
- * No changes.
247
+ * Speed improvements to `Hash.except` and `HashWithIndifferentAccess#except`.
95
248
 
249
+ These methods now unset the `default`/`default_proc` on the returned Hash, compatible with Ruby 3.0’s native implementation.
96
250
 
97
- ## Rails 5.2.2 (December 04, 2018) ##
251
+ *Timo Schilling*
98
252
 
99
- * Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
100
- would not act as alias for `#symbolize_keys`.
253
+ * Introduce `ActiveSupport::ActionableError`.
101
254
 
102
- *Nick Weiland*
255
+ Actionable errors let's you dispatch actions from Rails' error pages. This
256
+ can help you save time if you have a clear action for the resolution of
257
+ common development errors.
103
258
 
104
- * Improve the logic that detects non-autoloaded constants.
259
+ The de-facto example are pending migrations. Every time pending migrations
260
+ are found, a middleware raises an error. With actionable errors, you can
261
+ run the migrations right from the error page. Other examples include Rails
262
+ plugins that need to run a rake task to setup themselves. They can now
263
+ raise actionable errors to run the setup straight from the error pages.
105
264
 
106
- *Jan Habermann*, *Xavier Noria*
265
+ Here is how to define an actionable error:
107
266
 
108
- * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
267
+ ```ruby
268
+ class PendingMigrationError < MigrationError #:nodoc:
269
+ include ActiveSupport::ActionableError
109
270
 
110
- URI.unescape("\xe3\x83\x90") # => "バ"
111
- URI.unescape("%E3%83%90") # => "バ"
112
- URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
271
+ action "Run pending migrations" do
272
+ ActiveRecord::Tasks::DatabaseTasks.migrate
273
+ end
274
+ end
275
+ ```
113
276
 
114
- *Ashe Connor*, *Aaron Patterson*
277
+ To make an error actionable, include the `ActiveSupport::ActionableError`
278
+ module and invoke the `action` class macro to define the action. An action
279
+ needs a name and a procedure to execute. The name is shown as the name of a
280
+ button on the error pages. Once clicked, it will invoke the given
281
+ procedure.
115
282
 
283
+ *Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
116
284
 
117
- ## Rails 5.2.1.1 (November 27, 2018) ##
285
+ * Preserve `html_safe?` status on `ActiveSupport::SafeBuffer#*`.
118
286
 
119
- * No changes.
287
+ Before:
120
288
 
289
+ ("<br />".html_safe * 2).html_safe? #=> nil
121
290
 
122
- ## Rails 5.2.1 (August 07, 2018) ##
291
+ After:
123
292
 
124
- * Redis cache store: `delete_matched` no longer blocks the Redis server.
125
- (Switches from evaled Lua to a batched SCAN + DEL loop.)
293
+ ("<br />".html_safe * 2).html_safe? #=> true
126
294
 
127
- *Gleb Mazovetskiy*
295
+ *Ryo Nakamura*
128
296
 
129
- * Fix bug where `ActiveSupport::Timezone.all` would fail when tzinfo data for
130
- any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
297
+ * Calling test methods with `with_info_handler` method to allow minitest-hooks
298
+ plugin to work.
131
299
 
132
- *Dominik Sander*
300
+ *Mauri Mustonen*
133
301
 
134
- * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
135
- size when compression is enabled (which is true by default). This patch
136
- does not attempt to repair existing data: please manually flush the cache
137
- to clear out the problematic entries.
302
+ * The Zeitwerk compatibility interface for `ActiveSupport::Dependencies` no
303
+ longer implements `autoloaded_constants` or `autoloaded?` (undocumented,
304
+ anyway). Experience shows introspection does not have many use cases, and
305
+ troubleshooting is done by logging. With this design trade-off we are able
306
+ to use even less memory in all environments.
138
307
 
139
- *Godfrey Chan*
308
+ *Xavier Noria*
140
309
 
141
- * Fix `ActiveSupport::Cache#read_multi` bug with local cache enabled that was
142
- returning instances of `ActiveSupport::Cache::Entry` instead of the raw values.
310
+ * Depends on Zeitwerk 2, which stores less metadata if reloading is disabled
311
+ and hence uses less memory when `config.cache_classes` is `true`, a standard
312
+ setup in production.
143
313
 
144
- *Jason Lee*
314
+ *Xavier Noria*
145
315
 
316
+ * In `:zeitwerk` mode, eager load directories in engines and applications only
317
+ if present in their respective `config.eager_load_paths`.
146
318
 
147
- ## Rails 5.2.0 (April 09, 2018) ##
319
+ A common use case for this is adding `lib` to `config.autoload_paths`, but
320
+ not to `config.eager_load_paths`. In that configuration, for example, files
321
+ in the `lib` directory should not be eager loaded.
148
322
 
149
- * Caching: MemCache and Redis `read_multi` and `fetch_multi` speedup.
150
- Read from the local in-memory cache before consulting the backend.
323
+ *Xavier Noria*
151
324
 
152
- *Gabriel Sobrinho*
325
+ * Fix bug in Range comparisons when comparing to an excluded-end Range
153
326
 
154
- * Return all mappings for a timezone identifier in `country_zones`.
327
+ Before:
155
328
 
156
- Some timezones like `Europe/London` have multiple mappings in
157
- `ActiveSupport::TimeZone::MAPPING` so return all of them instead
158
- of the first one found by using `Hash#value`. e.g:
329
+ (1..10).cover?(1...11) # => false
159
330
 
160
- # Before
161
- ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"]
331
+ After:
162
332
 
163
- # After
164
- ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"]
333
+ (1..10).cover?(1...11) # => true
165
334
 
166
- Fixes #31668.
335
+ With the same change for `Range#include?` and `Range#===`.
167
336
 
168
- *Andrew White*
337
+ *Owen Stephens*
169
338
 
170
- * Add support for connection pooling on RedisCacheStore.
339
+ * Use weak references in descendants tracker to allow anonymous subclasses to
340
+ be garbage collected.
171
341
 
172
- *fatkodima*
342
+ *Edgars Beigarts*
173
343
 
174
- * Support hash as first argument in `assert_difference`. This allows to specify multiple
175
- numeric differences in the same assertion.
344
+ * Update `ActiveSupport::Notifications::Instrumenter#instrument` to make
345
+ passing a block optional. This will let users use
346
+ `ActiveSupport::Notifications` messaging features outside of
347
+ instrumentation.
176
348
 
177
- assert_difference ->{ Article.count } => 1, ->{ Post.count } => 2
349
+ *Ali Ibrahim*
178
350
 
179
- *Julien Meichelbeck*
351
+ * Fix `Time#advance` to work with dates before 1001-03-07
180
352
 
181
- * Add missing instrumentation for `read_multi` in `ActiveSupport::Cache::Store`.
353
+ Before:
182
354
 
183
- *Ignatius Reza Lesmana*
355
+ Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-05 00:00:00 UTC
184
356
 
185
- * `assert_changes` will always assert that the expression changes,
186
- regardless of `from:` and `to:` argument combinations.
357
+ After
187
358
 
188
- *Daniel Ma*
359
+ Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-06 00:00:00 UTC
189
360
 
190
- * Use SHA-1 to generate non-sensitive digests, such as the ETag header.
361
+ Note that this doesn't affect `DateTime#advance` as that doesn't use a proleptic calendar.
191
362
 
192
- Enabled by default for new apps; upgrading apps can opt in by setting
193
- `config.active_support.use_sha1_digests = true`.
363
+ *Andrew White*
194
364
 
195
- *Dmitri Dolguikh*, *Eugene Kenny*
365
+ * 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.
196
366
 
197
- * Changed default behaviour of `ActiveSupport::SecurityUtils.secure_compare`,
198
- to make it not leak length information even for variable length string.
367
+ *Xavier Noria*
199
368
 
200
- Renamed old `ActiveSupport::SecurityUtils.secure_compare` to `fixed_length_secure_compare`,
201
- and started raising `ArgumentError` in case of length mismatch of passed strings.
369
+ * Add support for supplying `locale` to `transliterate` and `parameterize`.
202
370
 
203
- *Vipul A M*
371
+ I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { "ü" => "ue" } } })
204
372
 
205
- * Make `ActiveSupport::TimeZone.all` return only time zones that are in
206
- `ActiveSupport::TimeZone::MAPPING`.
373
+ ActiveSupport::Inflector.transliterate("ü", locale: :de) # => "ue"
374
+ "Fünf autos".parameterize(locale: :de) # => "fuenf-autos"
375
+ ActiveSupport::Inflector.parameterize("Fünf autos", locale: :de) # => "fuenf-autos"
207
376
 
208
- Fixes #7245.
377
+ *Kaan Ozkan*, *Sharang Dashputre*
209
378
 
210
- *Chris LaRose*
379
+ * Allow `Array#excluding` and `Enumerable#excluding` to deal with a passed array gracefully.
211
380
 
212
- * MemCacheStore: Support expiring counters.
381
+ [ 1, 2, 3, 4, 5 ].excluding([4, 5]) # => [ 1, 2, 3 ]
213
382
 
214
- Pass `expires_in: [seconds]` to `#increment` and `#decrement` options
215
- to set the Memcached TTL (time-to-live) if the counter doesn't exist.
216
- If the counter exists, Memcached doesn't extend its expiry when it's
217
- incremented or decremented.
383
+ *DHH*
218
384
 
219
- ```
220
- Rails.cache.increment("my_counter", 1, expires_in: 2.minutes)
221
- ```
385
+ * Renamed `Array#without` and `Enumerable#without` to `Array#excluding` and `Enumerable#excluding`, to create parity with
386
+ `Array#including` and `Enumerable#including`. Retained the old names as aliases.
222
387
 
223
- *Takumasa Ochi*
388
+ *DHH*
224
389
 
225
- * Handle `TZInfo::AmbiguousTime` errors.
390
+ * Added `Array#including` and `Enumerable#including` to conveniently enlarge a collection with more members using a method rather than an operator:
226
391
 
227
- Make `ActiveSupport::TimeWithZone` match Ruby's handling of ambiguous
228
- times by choosing the later period, e.g.
392
+ [ 1, 2, 3 ].including(4, 5) # => [ 1, 2, 3, 4, 5 ]
393
+ post.authors.including(Current.person) # => All the authors plus the current person!
229
394
 
230
- Ruby:
231
- ```
232
- ENV["TZ"] = "Europe/Moscow"
233
- Time.local(2014, 10, 26, 1, 0, 0) # => 2014-10-26 01:00:00 +0300
234
- ```
395
+ *DHH*
235
396
 
236
- Before:
237
- ```
238
- >> "2014-10-26 01:00:00".in_time_zone("Moscow")
239
- TZInfo::AmbiguousTime: 26/10/2014 01:00 is an ambiguous local time.
240
- ```
241
397
 
242
- After:
243
- ```
244
- >> "2014-10-26 01:00:00".in_time_zone("Moscow")
245
- => Sun, 26 Oct 2014 01:00:00 MSK +03:00
246
- ```
398
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
247
399
 
248
- Fixes #17395.
400
+ * No changes.
249
401
 
250
- *Andrew White*
251
402
 
252
- * Redis cache store.
403
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
253
404
 
254
- ```
255
- # Defaults to `redis://localhost:6379/0`. Only use for dev/test.
256
- config.cache_store = :redis_cache_store
257
-
258
- # Supports all common cache store options (:namespace, :compress,
259
- # :compress_threshold, :expires_in, :race_condition_ttl) and all
260
- # Redis options.
261
- cache_password = Rails.application.secrets.redis_cache_password
262
- config.cache_store = :redis_cache_store, driver: :hiredis,
263
- namespace: 'myapp-cache', compress: true, timeout: 1,
264
- url: "redis://:#{cache_password}@myapp-cache-1:6379/0"
265
-
266
- # Supports Redis::Distributed with multiple hosts
267
- config.cache_store = :redis_cache_store, driver: :hiredis
268
- namespace: 'myapp-cache', compress: true,
269
- url: %w[
270
- redis://myapp-cache-1:6379/0
271
- redis://myapp-cache-1:6380/0
272
- redis://myapp-cache-2:6379/0
273
- redis://myapp-cache-2:6380/0
274
- redis://myapp-cache-3:6379/0
275
- redis://myapp-cache-3:6380/0
276
- ]
277
-
278
- # Or pass a builder block
279
- config.cache_store = :redis_cache_store,
280
- namespace: 'myapp-cache', compress: true,
281
- redis: -> { Redis.new … }
282
- ```
405
+ * New autoloading based on [Zeitwerk](https://github.com/fxn/zeitwerk).
283
406
 
284
- Deployment note: Take care to use a *dedicated Redis cache* rather
285
- than pointing this at your existing Redis server. It won't cope well
286
- with mixed usage patterns and it won't expire cache entries by default.
407
+ *Xavier Noria*
287
408
 
288
- Redis cache server setup guide: https://redis.io/topics/lru-cache
409
+ * Revise `ActiveSupport::Notifications.unsubscribe` to correctly handle Regex or other multiple-pattern subscribers.
289
410
 
290
- *Jeremy Daer*
411
+ *Zach Kemp*
291
412
 
292
- * Cache: Enable compression by default for values > 1kB.
413
+ * Add `before_reset` callback to `CurrentAttributes` and define `after_reset` as an alias of `resets` for symmetry.
293
414
 
294
- Compression has long been available, but opt-in and at a 16kB threshold.
295
- It wasn't enabled by default due to CPU cost. Today it's cheap and typical
296
- cache data is eminently compressible, such as HTML or JSON fragments.
297
- Compression dramatically reduces Memcached/Redis mem usage, which means
298
- the same cache servers can store more data, which means higher hit rates.
415
+ *Rosa Gutierrez*
299
416
 
300
- To disable compression, pass `compress: false` to the initializer.
417
+ * Remove the `` Kernel#` `` override that suppresses ENOENT and accidentally returns nil on Unix systems.
301
418
 
302
- *Jeremy Daer*
419
+ *Akinori Musha*
303
420
 
304
- * Allow `Range#include?` on TWZ ranges.
421
+ * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
305
422
 
306
- In #11474 we prevented TWZ ranges being iterated over which matched
307
- Ruby's handling of Time ranges and as a consequence `include?`
308
- stopped working with both Time ranges and TWZ ranges. However in
309
- ruby/ruby@b061634 support was added for `include?` to use `cover?`
310
- for 'linear' objects. Since we have no way of making Ruby consider
311
- TWZ instances as 'linear' we have to override `Range#include?`.
423
+ `assoc` can now be called with either a string or a symbol.
312
424
 
313
- Fixes #30799.
425
+ *Stefan Schüßler*
314
426
 
315
- *Andrew White*
427
+ * Add `Hash#deep_transform_values`, and `Hash#deep_transform_values!`.
316
428
 
317
- * Fix acronym support in `humanize`.
429
+ *Guillermo Iguaran*
318
430
 
319
- Acronym inflections are stored with lowercase keys in the hash but
320
- the match wasn't being lowercased before being looked up in the hash.
321
- This shouldn't have any performance impact because before it would
322
- fail to find the acronym and perform the `downcase` operation anyway.
323
431
 
324
- Fixes #31052.
432
+ ## Rails 6.0.0.beta1 (January 18, 2019) ##
325
433
 
326
- *Andrew White*
434
+ * Remove deprecated `Module#reachable?` method.
327
435
 
328
- * Add same method signature for `Time#prev_year` and `Time#next_year`
329
- in accordance with `Date#prev_year`, `Date#next_year`.
436
+ *Rafael Mendonça França*
330
437
 
331
- Allows pass argument for `Time#prev_year` and `Time#next_year`.
438
+ * Remove deprecated `#acronym_regex` method from `Inflections`.
332
439
 
333
- Before:
334
- ```
335
- Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
336
- Time.new(2017, 9, 16, 17, 0).prev_year(1)
337
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
440
+ *Rafael Mendonça França*
338
441
 
339
- Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
340
- Time.new(2017, 9, 16, 17, 0).next_year(1)
341
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
342
- ```
442
+ * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
343
443
 
344
- After:
345
- ```
346
- Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
347
- Time.new(2017, 9, 16, 17, 0).prev_year(1) # => 2016-09-16 17:00:00 +0300
444
+ *Keenan Brock*
348
445
 
349
- Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
350
- Time.new(2017, 9, 16, 17, 0).next_year(1) # => 2018-09-16 17:00:00 +0300
351
- ```
446
+ * Preserve key order passed to `ActiveSupport::CacheStore#fetch_multi`.
352
447
 
353
- *bogdanvlviv*
448
+ `fetch_multi(*names)` now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
354
449
 
355
- * Add same method signature for `Time#prev_month` and `Time#next_month`
356
- in accordance with `Date#prev_month`, `Date#next_month`.
450
+ *Gannon McGibbon*
357
451
 
358
- Allows pass argument for `Time#prev_month` and `Time#next_month`.
452
+ * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
359
453
 
360
- Before:
361
- ```
362
- Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
363
- Time.new(2017, 9, 16, 17, 0).prev_month(1)
364
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
454
+ *Mark J. Titorenko*, *Vlad Bokov*
365
455
 
366
- Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
367
- Time.new(2017, 9, 16, 17, 0).next_month(1)
368
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
369
- ```
456
+ * Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
457
+ would not act as alias for `#symbolize_keys`.
370
458
 
371
- After:
372
- ```
373
- Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
374
- Time.new(2017, 9, 16, 17, 0).prev_month(1) # => 2017-08-16 17:00:00 +0300
459
+ *Nick Weiland*
375
460
 
376
- Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
377
- Time.new(2017, 9, 16, 17, 0).next_month(1) # => 2017-10-16 17:00:00 +0300
378
- ```
461
+ * Improve the logic that detects non-autoloaded constants.
379
462
 
380
- *bogdanvlviv*
463
+ *Jan Habermann*, *Xavier Noria*
381
464
 
382
- * Add same method signature for `Time#prev_day` and `Time#next_day`
383
- in accordance with `Date#prev_day`, `Date#next_day`.
465
+ * Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSupport::Multibyte::Unicode#unpack_graphemes(string)`
466
+ in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
384
467
 
385
- Allows pass argument for `Time#prev_day` and `Time#next_day`.
468
+ *Francesco Rodríguez*
386
469
 
387
- Before:
388
- ```
389
- Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
390
- Time.new(2017, 9, 16, 17, 0).prev_day(1)
391
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
470
+ * Deprecate `ActiveSupport::Multibyte::Chars.consumes?` in favor of `String#is_utf8?`.
392
471
 
393
- Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
394
- Time.new(2017, 9, 16, 17, 0).next_day(1)
395
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
396
- ```
472
+ *Francesco Rodríguez*
397
473
 
398
- After:
474
+ * Fix duration being rounded to a full second.
399
475
  ```
400
- Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
401
- Time.new(2017, 9, 16, 17, 0).prev_day(1) # => 2017-09-15 17:00:00 +0300
402
-
403
- Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
404
- Time.new(2017, 9, 16, 17, 0).next_day(1) # => 2017-09-17 17:00:00 +0300
476
+ time = DateTime.parse("2018-1-1")
477
+ time += 0.51.seconds
405
478
  ```
479
+ Will now correctly add 0.51 second and not 1 full second.
406
480
 
407
- *bogdanvlviv*
408
-
409
- * `IO#to_json` now returns the `to_s` representation, rather than
410
- attempting to convert to an array. This fixes a bug where `IO#to_json`
411
- would raise an `IOError` when called on an unreadable object.
412
-
413
- Fixes #26132.
414
-
415
- *Paul Kuruvilla*
416
-
417
- * Remove deprecated `halt_callback_chains_on_return_false` option.
418
-
419
- *Rafael Mendonça França*
420
-
421
- * Remove deprecated `:if` and `:unless` string filter for callbacks.
481
+ *Edouard Chin*
422
482
 
423
- *Rafael Mendonça França*
483
+ * Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSupport::Multibyte::Chars#normalize`
484
+ in favor of `String#unicode_normalize`
424
485
 
425
- * `Hash#slice` now falls back to Ruby 2.5+'s built-in definition if defined.
486
+ *Francesco Rodríguez*
426
487
 
427
- *Akira Matsuda*
488
+ * Deprecate `ActiveSupport::Multibyte::Unicode#downcase/upcase/swapcase` in favor of
489
+ `String#downcase/upcase/swapcase`.
428
490
 
429
- * Deprecate `secrets.secret_token`.
491
+ *Francesco Rodríguez*
430
492
 
431
- The architecture for secrets had a big upgrade between Rails 3 and Rails 4,
432
- when the default changed from using `secret_token` to `secret_key_base`.
493
+ * Add `ActiveSupport::ParameterFilter`.
433
494
 
434
- `secret_token` has been soft deprecated in documentation for four years
435
- but is still in place to support apps created before Rails 4.
436
- Deprecation warnings have been added to help developers upgrade their
437
- applications to `secret_key_base`.
495
+ *Yoshiyuki Kinjo*
438
496
 
439
- *claudiob*, *Kasper Timm Hansen*
497
+ * Rename `Module#parent`, `Module#parents`, and `Module#parent_name` to
498
+ `module_parent`, `module_parents`, and `module_parent_name`.
440
499
 
441
- * Return an instance of `HashWithIndifferentAccess` from `HashWithIndifferentAccess#transform_keys`.
500
+ *Gannon McGibbon*
442
501
 
443
- *Yuji Yaginuma*
502
+ * Deprecate the use of `LoggerSilence` in favor of `ActiveSupport::LoggerSilence`
444
503
 
445
- * Add key rotation support to `MessageEncryptor` and `MessageVerifier`.
504
+ *Edouard Chin*
446
505
 
447
- This change introduces a `rotate` method to both the `MessageEncryptor` and
448
- `MessageVerifier` classes. This method accepts the same arguments and
449
- options as the given classes' constructor. The `encrypt_and_verify` method
450
- for `MessageEncryptor` and the `verified` method for `MessageVerifier` also
451
- accept an optional keyword argument `:on_rotation` block which is called
452
- when a rotated instance is used to decrypt or verify the message.
506
+ * Deprecate using negative limits in `String#first` and `String#last`.
453
507
 
454
- *Michael J Coyne*
508
+ *Gannon McGibbon*, *Eric Turner*
455
509
 
456
- * Deprecate `Module#reachable?` method.
510
+ * Fix bug where `#without` for `ActiveSupport::HashWithIndifferentAccess` would fail
511
+ with symbol arguments
457
512
 
458
- *bogdanvlviv*
513
+ *Abraham Chan*
459
514
 
460
- * Add `config/credentials.yml.enc` to store production app secrets.
515
+ * Treat `#delete_prefix`, `#delete_suffix` and `#unicode_normalize` results as non-`html_safe`.
516
+ Ensure safety of arguments for `#insert`, `#[]=` and `#replace` calls on `html_safe` Strings.
461
517
 
462
- Allows saving any authentication credentials for third party services
463
- directly in repo encrypted with `config/master.key` or `ENV["RAILS_MASTER_KEY"]`.
518
+ *Janosch Müller*
464
519
 
465
- This will eventually replace `Rails.application.secrets` and the encrypted
466
- secrets introduced in Rails 5.1.
520
+ * Changed `ActiveSupport::TaggedLogging.new` to return a new logger instance instead
521
+ of mutating the one received as parameter.
467
522
 
468
- *DHH*, *Kasper Timm Hansen*
523
+ *Thierry Joyal*
469
524
 
470
- * Add `ActiveSupport::EncryptedFile` and `ActiveSupport::EncryptedConfiguration`.
525
+ * Define `unfreeze_time` as an alias of `travel_back` in `ActiveSupport::Testing::TimeHelpers`.
471
526
 
472
- Allows for stashing encrypted files or configuration directly in repo by
473
- encrypting it with a key.
527
+ The alias is provided for symmetry with `freeze_time`.
474
528
 
475
- Backs the new credentials setup above, but can also be used independently.
529
+ *Ryan Davidson*
476
530
 
477
- *DHH*, *Kasper Timm Hansen*
531
+ * Add support for tracing constant autoloads. Just throw
478
532
 
479
- * `Module#delegate_missing_to` now raises `DelegationError` if target is nil,
480
- similar to `Module#delegate`.
533
+ ActiveSupport::Dependencies.logger = Rails.logger
534
+ ActiveSupport::Dependencies.verbose = true
481
535
 
482
- *Anton Khamets*
536
+ in an initializer.
483
537
 
484
- * Update `String#camelize` to provide feedback when wrong option is passed.
538
+ *Xavier Noria*
485
539
 
486
- `String#camelize` was returning nil without any feedback when an
487
- invalid option was passed as a parameter.
540
+ * Maintain `html_safe?` on html_safe strings when sliced.
488
541
 
489
- Previously:
542
+ string = "<div>test</div>".html_safe
543
+ string[-1..1].html_safe? # => true
490
544
 
491
- 'one_two'.camelize(true)
492
- # => nil
545
+ *Elom Gomez*, *Yumin Wong*
493
546
 
494
- Now:
547
+ * Add `Array#extract!`.
495
548
 
496
- 'one_two'.camelize(true)
497
- # => ArgumentError: Invalid option, use either :upper or :lower.
549
+ The method removes and returns the elements for which the block returns a true value.
550
+ If no block is given, an Enumerator is returned instead.
498
551
 
499
- *Ricardo Díaz*
552
+ numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
553
+ odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
554
+ numbers # => [0, 2, 4, 6, 8]
500
555
 
501
- * Fix modulo operations involving durations.
556
+ *bogdanvlviv*
502
557
 
503
- Rails 5.1 introduced `ActiveSupport::Duration::Scalar` as a wrapper
504
- around numeric values as a way of ensuring a duration was the outcome of
505
- an expression. However, the implementation was missing support for modulo
506
- operations. This support has now been added and should result in a duration
507
- being returned from expressions involving modulo operations.
558
+ * Support not to cache `nil` for `ActiveSupport::Cache#fetch`.
508
559
 
509
- Prior to Rails 5.1:
560
+ cache.fetch('bar', skip_nil: true) { nil }
561
+ cache.exist?('bar') # => false
510
562
 
511
- 5.minutes % 2.minutes
512
- # => 60
563
+ *Martin Hong*
513
564
 
514
- Now:
565
+ * Add "event object" support to the notification system.
566
+ Before this change, end users were forced to create hand made artisanal
567
+ event objects on their own, like this:
515
568
 
516
- 5.minutes % 2.minutes
517
- # => 1 minute
569
+ ActiveSupport::Notifications.subscribe('wait') do |*args|
570
+ @event = ActiveSupport::Notifications::Event.new(*args)
571
+ end
518
572
 
519
- Fixes #29603 and #29743.
573
+ ActiveSupport::Notifications.instrument('wait') do
574
+ sleep 1
575
+ end
520
576
 
521
- *Sayan Chakraborty*, *Andrew White*
577
+ @event.duration # => 1000.138
522
578
 
523
- * Fix division where a duration is the denominator.
579
+ After this change, if the block passed to `subscribe` only takes one
580
+ parameter, the framework will yield an event object to the block. Now
581
+ end users are no longer required to make their own:
524
582
 
525
- PR #29163 introduced a change in behavior when a duration was the denominator
526
- in a calculation - this was incorrect as dividing by a duration should always
527
- return a `Numeric`. The behavior of previous versions of Rails has been restored.
583
+ ActiveSupport::Notifications.subscribe('wait') do |event|
584
+ @event = event
585
+ end
528
586
 
529
- Fixes #29592.
587
+ ActiveSupport::Notifications.instrument('wait') do
588
+ sleep 1
589
+ end
530
590
 
531
- *Andrew White*
591
+ p @event.allocations # => 7
592
+ p @event.cpu_time # => 0.256
593
+ p @event.idle_time # => 1003.2399
532
594
 
533
- * Add purpose and expiry support to `ActiveSupport::MessageVerifier` and
534
- `ActiveSupport::MessageEncryptor`.
595
+ Now you can enjoy event objects without making them yourself. Neat!
535
596
 
536
- For instance, to ensure a message is only usable for one intended purpose:
597
+ *Aaron "t.lo" Patterson*
537
598
 
538
- token = @verifier.generate("x", purpose: :shipping)
599
+ * Add cpu_time, idle_time, and allocations to Event.
539
600
 
540
- @verifier.verified(token, purpose: :shipping) # => "x"
541
- @verifier.verified(token) # => nil
601
+ *Eileen M. Uchitelle*, *Aaron Patterson*
542
602
 
543
- Or make it expire after a set time:
603
+ * RedisCacheStore: support key expiry in increment/decrement.
544
604
 
545
- @verifier.generate("x", expires_in: 1.month)
546
- @verifier.generate("y", expires_at: Time.now.end_of_year)
605
+ Pass `:expires_in` to `#increment` and `#decrement` to set a Redis EXPIRE on the key.
547
606
 
548
- Showcased with `ActiveSupport::MessageVerifier`, but works the same for
549
- `ActiveSupport::MessageEncryptor`'s `encrypt_and_sign` and `decrypt_and_verify`.
607
+ If the key is already set to expire, RedisCacheStore won't extend its expiry.
550
608
 
551
- Pull requests: #29599, #29854
609
+ Rails.cache.increment("some_key", 1, expires_in: 2.minutes)
552
610
 
553
- *Assain Jaleel*
554
-
555
- * Make the order of `Hash#reverse_merge!` consistent with `HashWithIndifferentAccess`.
611
+ *Jason Lee*
556
612
 
557
- *Erol Fornoles*
613
+ * Allow `Range#===` and `Range#cover?` on Range.
558
614
 
559
- * Add `freeze_time` helper which freezes time to `Time.now` in tests.
615
+ `Range#cover?` can now accept a range argument like `Range#include?` and
616
+ `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
617
+ into a new file, with these two methods.
560
618
 
561
- *Prathamesh Sonpatki*
619
+ *Requiring active_support/core_ext/range/include_range is now deprecated.*
620
+ *Use `require "active_support/core_ext/range/compare_range"` instead.*
562
621
 
563
- * Default `ActiveSupport::MessageEncryptor` to use AES 256 GCM encryption.
622
+ *utilum*
564
623
 
565
- On for new Rails 5.2 apps. Upgrading apps can find the config as a new
566
- framework default.
624
+ * Add `index_with` to Enumerable.
567
625
 
568
- *Assain Jaleel*
626
+ Allows creating a hash from an enumerable with the value from a passed block
627
+ or a default argument.
569
628
 
570
- * Cache: `write_multi`.
629
+ %i( title body ).index_with { |attr| post.public_send(attr) }
630
+ # => { title: "hey", body: "what's up?" }
571
631
 
572
- Rails.cache.write_multi foo: 'bar', baz: 'qux'
632
+ %i( title body ).index_with(nil)
633
+ # => { title: nil, body: nil }
573
634
 
574
- Plus faster fetch_multi with stores that implement `write_multi_entries`.
575
- Keys that aren't found may be written to the cache store in one shot
576
- instead of separate writes.
635
+ Closely linked with `index_by`, which creates a hash where the keys are extracted from a block.
577
636
 
578
- The default implementation simply calls `write_entry` for each entry.
579
- Stores may override if they're capable of one-shot bulk writes, like
580
- Redis `MSET`.
637
+ *Kasper Timm Hansen*
581
638
 
582
- *Jeremy Daer*
639
+ * Fix bug where `ActiveSupport::TimeZone.all` would fail when tzinfo data for
640
+ any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
583
641
 
584
- * Add default option to module and class attribute accessors.
642
+ *Dominik Sander*
585
643
 
586
- mattr_accessor :settings, default: {}
644
+ * Redis cache store: `delete_matched` no longer blocks the Redis server.
645
+ (Switches from evaled Lua to a batched SCAN + DEL loop.)
587
646
 
588
- Works for `mattr_reader`, `mattr_writer`, `cattr_accessor`, `cattr_reader`,
589
- and `cattr_writer` as well.
647
+ *Gleb Mazovetskiy*
590
648
 
591
- *Genadi Samokovarov*
649
+ * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
650
+ size when compression is enabled (which is true by default). This patch
651
+ does not attempt to repair existing data: please manually flush the cache
652
+ to clear out the problematic entries.
592
653
 
593
- * Add `Date#prev_occurring` and `Date#next_occurring` to return specified next/previous occurring day of week.
654
+ *Godfrey Chan*
594
655
 
595
- *Shota Iguchi*
656
+ * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
596
657
 
597
- * Add default option to `class_attribute`.
658
+ URI.unescape("\xe3\x83\x90") # => "バ"
659
+ URI.unescape("%E3%83%90") # => "バ"
660
+ URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
598
661
 
599
- Before:
662
+ *Ashe Connor*, *Aaron Patterson*
600
663
 
601
- class_attribute :settings
602
- self.settings = {}
664
+ * Add `before?` and `after?` methods to `Date`, `DateTime`,
665
+ `Time`, and `TimeWithZone`.
603
666
 
604
- Now:
667
+ *Nick Holden*
605
668
 
606
- class_attribute :settings, default: {}
669
+ * `ActiveSupport::Inflector#ordinal` and `ActiveSupport::Inflector#ordinalize` now support
670
+ translations through I18n.
607
671
 
608
- *DHH*
672
+ # locale/fr.rb
609
673
 
610
- * `#singularize` and `#pluralize` now respect uncountables for the specified locale.
674
+ {
675
+ fr: {
676
+ number: {
677
+ nth: {
678
+ ordinals: lambda do |_key, number:, **_options|
679
+ if number.to_i.abs == 1
680
+ 'er'
681
+ else
682
+ 'e'
683
+ end
684
+ end,
611
685
 
612
- *Eilis Hamilton*
686
+ ordinalized: lambda do |_key, number:, **_options|
687
+ "#{number}#{ActiveSupport::Inflector.ordinal(number)}"
688
+ end
689
+ }
690
+ }
691
+ }
692
+ }
613
693
 
614
- * Add `ActiveSupport::CurrentAttributes` to provide a thread-isolated attributes singleton.
615
- Primary use case is keeping all the per-request attributes easily available to the whole system.
616
694
 
617
- *DHH*
695
+ *Christian Blais*
618
696
 
619
- * Fix implicit coercion calculations with scalars and durations.
697
+ * Add `:private` option to ActiveSupport's `Module#delegate`
698
+ in order to delegate methods as private:
620
699
 
621
- Previously, calculations where the scalar is first would be converted to a duration
622
- of seconds, but this causes issues with dates being converted to times, e.g:
700
+ class User < ActiveRecord::Base
701
+ has_one :profile
702
+ delegate :date_of_birth, to: :profile, private: true
623
703
 
624
- Time.zone = "Beijing" # => Asia/Shanghai
625
- date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
626
- 2 * 1.day # => 172800 seconds
627
- date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00
704
+ def age
705
+ Date.today.year - date_of_birth.year
706
+ end
707
+ end
628
708
 
629
- Now, the `ActiveSupport::Duration::Scalar` calculation methods will try to maintain
630
- the part structure of the duration where possible, e.g:
709
+ # User.new.age # => 29
710
+ # User.new.date_of_birth
711
+ # => NoMethodError: private method `date_of_birth' called for #<User:0x00000008221340>
631
712
 
632
- Time.zone = "Beijing" # => Asia/Shanghai
633
- date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
634
- 2 * 1.day # => 2 days
635
- date + 2 * 1.day # => Mon, 22 May 2017
713
+ *Tomas Valent*
636
714
 
637
- Fixes #29160, #28970.
715
+ * `String#truncate_bytes` to truncate a string to a maximum bytesize without
716
+ breaking multibyte characters or grapheme clusters like 👩‍👩‍👦‍👦.
638
717
 
639
- *Andrew White*
718
+ *Jeremy Daer*
640
719
 
641
- * Add support for versioned cache entries. This enables the cache stores to recycle cache keys, greatly saving
642
- on storage in cases with frequent churn. Works together with the separation of `#cache_key` and `#cache_version`
643
- in Active Record and its use in Action Pack's fragment caching.
720
+ * `String#strip_heredoc` preserves frozenness.
644
721
 
645
- *DHH*
722
+ "foo".freeze.strip_heredoc.frozen? # => true
646
723
 
647
- * Pass gem name and deprecation horizon to deprecation notifications.
724
+ Fixes that frozen string literals would inadvertently become unfrozen:
648
725
 
649
- *Willem van Bergen*
726
+ # frozen_string_literal: true
650
727
 
651
- * Add support for `:offset` and `:zone` to `ActiveSupport::TimeWithZone#change`.
728
+ foo = <<-MSG.strip_heredoc
729
+ la la la
730
+ MSG
652
731
 
653
- *Andrew White*
732
+ foo.frozen? # => false !??
654
733
 
655
- * Add support for `:offset` to `Time#change`.
734
+ *Jeremy Daer*
656
735
 
657
- Fixes #28723.
736
+ * Rails 6 requires Ruby 2.5.0 or newer.
658
737
 
659
- *Andrew White*
738
+ *Jeremy Daer*, *Kasper Timm Hansen*
660
739
 
661
- * Add `fetch_values` for `HashWithIndifferentAccess`.
740
+ * Adds parallel testing to Rails.
662
741
 
663
- The method was originally added to `Hash` in Ruby 2.3.0.
742
+ Parallelize your test suite with forked processes or threads.
664
743
 
665
- *Josh Pencheon*
744
+ *Eileen M. Uchitelle*, *Aaron Patterson*
666
745
 
667
746
 
668
- Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activesupport/CHANGELOG.md) for previous changes.
747
+ Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activesupport/CHANGELOG.md) for previous changes.