activesupport 5.2.4.2 → 6.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

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