activesupport 5.2.6.3 → 6.0.4.7

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