activesupport 5.2.6 → 6.0.0

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