activesupport 5.2.7.1 → 6.1.4.6

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

Potentially problematic release.


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

Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +399 -434
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -3
  5. data/lib/active_support/actionable_error.rb +48 -0
  6. data/lib/active_support/array_inquirer.rb +4 -2
  7. data/lib/active_support/backtrace_cleaner.rb +29 -3
  8. data/lib/active_support/benchmarkable.rb +1 -1
  9. data/lib/active_support/cache/file_store.rb +34 -34
  10. data/lib/active_support/cache/mem_cache_store.rb +39 -24
  11. data/lib/active_support/cache/memory_store.rb +59 -33
  12. data/lib/active_support/cache/null_store.rb +8 -3
  13. data/lib/active_support/cache/redis_cache_store.rb +72 -45
  14. data/lib/active_support/cache/strategy/local_cache.rb +41 -26
  15. data/lib/active_support/cache.rb +148 -78
  16. data/lib/active_support/callbacks.rb +81 -64
  17. data/lib/active_support/concern.rb +70 -3
  18. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
  19. data/lib/active_support/concurrency/share_lock.rb +0 -1
  20. data/lib/active_support/configurable.rb +10 -14
  21. data/lib/active_support/configuration_file.rb +51 -0
  22. data/lib/active_support/core_ext/array/access.rb +18 -6
  23. data/lib/active_support/core_ext/array/conversions.rb +5 -5
  24. data/lib/active_support/core_ext/array/extract.rb +21 -0
  25. data/lib/active_support/core_ext/array.rb +1 -1
  26. data/lib/active_support/core_ext/benchmark.rb +2 -2
  27. data/lib/active_support/core_ext/class/attribute.rb +32 -47
  28. data/lib/active_support/core_ext/class/subclasses.rb +17 -38
  29. data/lib/active_support/core_ext/date/calculations.rb +6 -5
  30. data/lib/active_support/core_ext/date/conversions.rb +2 -1
  31. data/lib/active_support/core_ext/date_and_time/calculations.rb +37 -47
  32. data/lib/active_support/core_ext/date_and_time/compatibility.rb +15 -0
  33. data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
  34. data/lib/active_support/core_ext/date_time/calculations.rb +1 -1
  35. data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
  36. data/lib/active_support/core_ext/enumerable.rb +171 -75
  37. data/lib/active_support/core_ext/hash/conversions.rb +3 -3
  38. data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
  39. data/lib/active_support/core_ext/hash/except.rb +2 -2
  40. data/lib/active_support/core_ext/hash/keys.rb +1 -30
  41. data/lib/active_support/core_ext/hash/slice.rb +6 -27
  42. data/lib/active_support/core_ext/hash.rb +1 -2
  43. data/lib/active_support/core_ext/integer/multiple.rb +1 -1
  44. data/lib/active_support/core_ext/kernel.rb +0 -1
  45. data/lib/active_support/core_ext/load_error.rb +1 -1
  46. data/lib/active_support/core_ext/marshal.rb +2 -0
  47. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  48. data/lib/active_support/core_ext/module/attribute_accessors.rb +30 -39
  49. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +17 -19
  50. data/lib/active_support/core_ext/module/concerning.rb +8 -2
  51. data/lib/active_support/core_ext/module/delegation.rb +76 -33
  52. data/lib/active_support/core_ext/module/introspection.rb +16 -15
  53. data/lib/active_support/core_ext/module/redefine_method.rb +8 -17
  54. data/lib/active_support/core_ext/module.rb +0 -1
  55. data/lib/active_support/core_ext/name_error.rb +29 -2
  56. data/lib/active_support/core_ext/numeric/conversions.rb +129 -129
  57. data/lib/active_support/core_ext/numeric.rb +0 -1
  58. data/lib/active_support/core_ext/object/blank.rb +1 -2
  59. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  60. data/lib/active_support/core_ext/object/duplicable.rb +7 -114
  61. data/lib/active_support/core_ext/object/json.rb +14 -2
  62. data/lib/active_support/core_ext/object/try.rb +17 -7
  63. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  64. data/lib/active_support/core_ext/range/compare_range.rb +34 -13
  65. data/lib/active_support/core_ext/range/conversions.rb +31 -29
  66. data/lib/active_support/core_ext/range/each.rb +0 -1
  67. data/lib/active_support/core_ext/range/include_time_with_zone.rb +8 -3
  68. data/lib/active_support/core_ext/regexp.rb +8 -5
  69. data/lib/active_support/core_ext/securerandom.rb +23 -3
  70. data/lib/active_support/core_ext/string/access.rb +5 -16
  71. data/lib/active_support/core_ext/string/conversions.rb +1 -0
  72. data/lib/active_support/core_ext/string/filters.rb +42 -1
  73. data/lib/active_support/core_ext/string/inflections.rb +45 -6
  74. data/lib/active_support/core_ext/string/inquiry.rb +1 -0
  75. data/lib/active_support/core_ext/string/multibyte.rb +6 -5
  76. data/lib/active_support/core_ext/string/output_safety.rb +70 -41
  77. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -2
  78. data/lib/active_support/core_ext/string/strip.rb +3 -1
  79. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +14 -0
  80. data/lib/active_support/core_ext/symbol.rb +3 -0
  81. data/lib/active_support/core_ext/time/calculations.rb +51 -3
  82. data/lib/active_support/core_ext/time/conversions.rb +2 -0
  83. data/lib/active_support/core_ext/uri.rb +6 -1
  84. data/lib/active_support/core_ext.rb +1 -1
  85. data/lib/active_support/current_attributes/test_helper.rb +13 -0
  86. data/lib/active_support/current_attributes.rb +16 -2
  87. data/lib/active_support/dependencies/zeitwerk_integration.rb +117 -0
  88. data/lib/active_support/dependencies.rb +109 -34
  89. data/lib/active_support/deprecation/behaviors.rb +16 -3
  90. data/lib/active_support/deprecation/disallowed.rb +56 -0
  91. data/lib/active_support/deprecation/instance_delegator.rb +0 -1
  92. data/lib/active_support/deprecation/method_wrappers.rb +18 -23
  93. data/lib/active_support/deprecation/proxy_wrappers.rb +29 -6
  94. data/lib/active_support/deprecation/reporting.rb +50 -7
  95. data/lib/active_support/deprecation.rb +6 -1
  96. data/lib/active_support/descendants_tracker.rb +59 -9
  97. data/lib/active_support/duration/iso8601_parser.rb +2 -4
  98. data/lib/active_support/duration/iso8601_serializer.rb +18 -14
  99. data/lib/active_support/duration.rb +78 -30
  100. data/lib/active_support/encrypted_configuration.rb +0 -4
  101. data/lib/active_support/encrypted_file.rb +22 -4
  102. data/lib/active_support/environment_inquirer.rb +20 -0
  103. data/lib/active_support/evented_file_update_checker.rb +82 -117
  104. data/lib/active_support/execution_wrapper.rb +2 -1
  105. data/lib/active_support/file_update_checker.rb +0 -1
  106. data/lib/active_support/fork_tracker.rb +64 -0
  107. data/lib/active_support/gem_version.rb +4 -4
  108. data/lib/active_support/hash_with_indifferent_access.rb +70 -42
  109. data/lib/active_support/i18n.rb +1 -0
  110. data/lib/active_support/i18n_railtie.rb +15 -8
  111. data/lib/active_support/inflector/inflections.rb +2 -7
  112. data/lib/active_support/inflector/methods.rb +49 -58
  113. data/lib/active_support/inflector/transliterate.rb +47 -18
  114. data/lib/active_support/json/decoding.rb +25 -26
  115. data/lib/active_support/json/encoding.rb +11 -3
  116. data/lib/active_support/key_generator.rb +1 -33
  117. data/lib/active_support/lazy_load_hooks.rb +5 -2
  118. data/lib/active_support/locale/en.rb +33 -0
  119. data/lib/active_support/locale/en.yml +7 -3
  120. data/lib/active_support/log_subscriber.rb +39 -9
  121. data/lib/active_support/logger.rb +2 -17
  122. data/lib/active_support/logger_silence.rb +11 -19
  123. data/lib/active_support/logger_thread_safe_level.rb +50 -6
  124. data/lib/active_support/message_encryptor.rb +8 -13
  125. data/lib/active_support/message_verifier.rb +10 -10
  126. data/lib/active_support/messages/metadata.rb +11 -2
  127. data/lib/active_support/messages/rotation_configuration.rb +2 -1
  128. data/lib/active_support/messages/rotator.rb +10 -9
  129. data/lib/active_support/multibyte/chars.rb +10 -68
  130. data/lib/active_support/multibyte/unicode.rb +15 -327
  131. data/lib/active_support/notifications/fanout.rb +116 -16
  132. data/lib/active_support/notifications/instrumenter.rb +71 -9
  133. data/lib/active_support/notifications.rb +72 -8
  134. data/lib/active_support/number_helper/number_converter.rb +5 -6
  135. data/lib/active_support/number_helper/number_to_currency_converter.rb +4 -9
  136. data/lib/active_support/number_helper/number_to_delimited_converter.rb +3 -2
  137. data/lib/active_support/number_helper/number_to_human_converter.rb +4 -3
  138. data/lib/active_support/number_helper/number_to_human_size_converter.rb +4 -3
  139. data/lib/active_support/number_helper/number_to_percentage_converter.rb +3 -1
  140. data/lib/active_support/number_helper/number_to_phone_converter.rb +2 -1
  141. data/lib/active_support/number_helper/number_to_rounded_converter.rb +12 -7
  142. data/lib/active_support/number_helper/rounding_helper.rb +12 -28
  143. data/lib/active_support/number_helper.rb +38 -12
  144. data/lib/active_support/option_merger.rb +22 -3
  145. data/lib/active_support/ordered_hash.rb +1 -1
  146. data/lib/active_support/ordered_options.rb +13 -3
  147. data/lib/active_support/parameter_filter.rb +133 -0
  148. data/lib/active_support/per_thread_registry.rb +1 -1
  149. data/lib/active_support/rails.rb +1 -10
  150. data/lib/active_support/railtie.rb +23 -1
  151. data/lib/active_support/reloader.rb +4 -5
  152. data/lib/active_support/rescuable.rb +4 -4
  153. data/lib/active_support/secure_compare_rotator.rb +51 -0
  154. data/lib/active_support/security_utils.rb +19 -12
  155. data/lib/active_support/string_inquirer.rb +4 -3
  156. data/lib/active_support/subscriber.rb +72 -28
  157. data/lib/active_support/tagged_logging.rb +42 -8
  158. data/lib/active_support/test_case.rb +91 -0
  159. data/lib/active_support/testing/assertions.rb +30 -9
  160. data/lib/active_support/testing/deprecation.rb +0 -1
  161. data/lib/active_support/testing/file_fixtures.rb +2 -0
  162. data/lib/active_support/testing/isolation.rb +2 -2
  163. data/lib/active_support/testing/method_call_assertions.rb +28 -1
  164. data/lib/active_support/testing/parallelization/server.rb +78 -0
  165. data/lib/active_support/testing/parallelization/worker.rb +100 -0
  166. data/lib/active_support/testing/parallelization.rb +51 -0
  167. data/lib/active_support/testing/stream.rb +1 -2
  168. data/lib/active_support/testing/time_helpers.rb +47 -12
  169. data/lib/active_support/time_with_zone.rb +81 -47
  170. data/lib/active_support/values/time_zone.rb +32 -17
  171. data/lib/active_support/xml_mini/jdom.rb +2 -3
  172. data/lib/active_support/xml_mini/libxml.rb +2 -2
  173. data/lib/active_support/xml_mini/libxmlsax.rb +4 -4
  174. data/lib/active_support/xml_mini/nokogiri.rb +2 -2
  175. data/lib/active_support/xml_mini/nokogirisax.rb +3 -3
  176. data/lib/active_support/xml_mini/rexml.rb +10 -3
  177. data/lib/active_support/xml_mini.rb +2 -10
  178. data/lib/active_support.rb +14 -1
  179. metadata +55 -29
  180. data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -9
  181. data/lib/active_support/core_ext/hash/compact.rb +0 -29
  182. data/lib/active_support/core_ext/hash/transform_values.rb +0 -32
  183. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -13
  184. data/lib/active_support/core_ext/module/reachable.rb +0 -11
  185. data/lib/active_support/core_ext/numeric/inquiry.rb +0 -28
  186. data/lib/active_support/core_ext/range/include_range.rb +0 -3
  187. data/lib/active_support/values/unicode_tables.dat +0 -0
data/CHANGELOG.md CHANGED
@@ -1,710 +1,675 @@
1
- ## Rails 5.2.7.1 (April 26, 2022) ##
1
+ ## Rails 6.1.4.6 (February 11, 2022) ##
2
2
 
3
- * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
4
-
5
- Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
6
- in names of tags and names of attributes, following the specification of XML.
7
-
8
- *Álvaro Martín Fraguas*
9
-
10
-
11
- ## Rails 5.2.7 (March 10, 2022) ##
12
-
13
- * Restore support to Ruby 2.2.
14
-
15
- *ojab*
3
+ * Fix Reloader method signature to work with the new Executor signature
16
4
 
17
5
 
18
- ## Rails 5.2.6.3 (March 08, 2022) ##
6
+ ## Rails 6.1.4.5 (February 11, 2022) ##
19
7
 
20
8
  * No changes.
21
9
 
22
10
 
23
- ## Rails 5.2.6.2 (February 11, 2022) ##
24
-
25
- * Fix Reloader method signature to work with the new Executor signature
26
-
27
-
28
- ## Rails 5.2.6.1 (February 11, 2022) ##
11
+ ## Rails 6.1.4.4 (December 15, 2021) ##
29
12
 
30
13
  * No changes.
31
14
 
32
15
 
33
- ## Rails 5.2.6 (May 05, 2021) ##
16
+ ## Rails 6.1.4.3 (December 14, 2021) ##
34
17
 
35
18
  * No changes.
36
19
 
37
20
 
38
- ## Rails 5.2.5 (March 26, 2021) ##
21
+ ## Rails 6.1.4.2 (December 14, 2021) ##
39
22
 
40
23
  * No changes.
41
24
 
42
25
 
43
- ## Rails 5.2.4.6 (May 05, 2021) ##
26
+ ## Rails 6.1.4.1 (August 19, 2021) ##
44
27
 
45
28
  * No changes.
46
29
 
47
30
 
48
- ## Rails 5.2.4.5 (February 10, 2021) ##
31
+ ## Rails 6.1.4 (June 24, 2021) ##
49
32
 
50
- * No changes.
33
+ * MemCacheStore: convert any underlying value (including `false`) to an `Entry`.
51
34
 
35
+ See [#42559](https://github.com/rails/rails/pull/42559).
52
36
 
53
- ## Rails 5.2.4.4 (September 09, 2020) ##
37
+ *Alex Ghiculescu*
54
38
 
55
- * No changes.
39
+ * Fix bug in `number_with_precision` when using large `BigDecimal` values.
56
40
 
41
+ Fixes #42302.
57
42
 
58
- ## Rails 5.2.4.3 (May 18, 2020) ##
43
+ *Federico Aldunate*, *Zachary Scott*
59
44
 
60
- * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
45
+ * Check byte size instead of length on `secure_compare`.
61
46
 
62
- * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
47
+ *Tietew*
63
48
 
64
- ## Rails 5.2.4.2 (March 19, 2020) ##
49
+ * Fix `Time.at` to not lose `:in` option.
65
50
 
66
- * No changes.
51
+ *Ryuta Kamizono*
67
52
 
53
+ * Require a path for `config.cache_store = :file_store`.
68
54
 
69
- ## Rails 5.2.4.1 (December 18, 2019) ##
55
+ *Alex Ghiculescu*
70
56
 
71
- * No changes.
57
+ * Avoid having to store complex object in the default translation file.
72
58
 
59
+ *Rafael Mendonça França*
73
60
 
74
- ## Rails 5.2.4 (November 27, 2019) ##
75
61
 
76
- * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
62
+ ## Rails 6.1.3.2 (May 05, 2021) ##
77
63
 
78
- Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
79
- to make log level local to Ruby Fibers in addition to Threads.
64
+ * No changes.
80
65
 
81
- Example:
82
66
 
83
- logger = ActiveSupport::Logger.new(STDOUT)
84
- logger.level = 1
85
- p "Main is debug? #{logger.debug?}"
67
+ ## Rails 6.1.3.1 (March 26, 2021) ##
86
68
 
87
- Fiber.new {
88
- logger.local_level = 0
89
- p "Thread is debug? #{logger.debug?}"
90
- }.resume
69
+ * No changes.
91
70
 
92
- p "Main is debug? #{logger.debug?}"
93
71
 
94
- Before:
72
+ ## Rails 6.1.3 (February 17, 2021) ##
95
73
 
96
- Main is debug? false
97
- Thread is debug? true
98
- Main is debug? true
74
+ * No changes.
99
75
 
100
- After:
101
76
 
102
- Main is debug? false
103
- Thread is debug? true
104
- Main is debug? false
77
+ ## Rails 6.1.2.1 (February 10, 2021) ##
105
78
 
106
- *Alexander Varnin*
79
+ * No changes.
107
80
 
108
81
 
109
- ## Rails 5.2.3 (March 27, 2019) ##
82
+ ## Rails 6.1.2 (February 09, 2021) ##
110
83
 
111
- * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
84
+ * `ActiveSupport::Cache::MemCacheStore` now accepts an explicit `nil` for its `addresses` argument.
112
85
 
113
- `assoc` can now be called with either a string or a symbol.
86
+ ```ruby
87
+ config.cache_store = :mem_cache_store, nil
114
88
 
115
- *Stefan Schüßler*
89
+ # is now equivalent to
116
90
 
117
- * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
91
+ config.cache_store = :mem_cache_store
118
92
 
119
- *Keenan Brock*
93
+ # and is also equivalent to
120
94
 
121
- * Allow Range#=== and Range#cover? on Range
95
+ config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
122
96
 
123
- `Range#cover?` can now accept a range argument like `Range#include?` and
124
- `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
125
- into a new file, with these two methods.
97
+ # which is the fallback behavior of Dalli
98
+ ```
126
99
 
127
- *utilum*
100
+ This helps those migrating from `:dalli_store`, where an explicit `nil` was permitted.
128
101
 
129
- * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
102
+ *Michael Overmeyer*
130
103
 
131
- *Mark J. Titorenko*, *Vlad Bokov*
132
104
 
105
+ ## Rails 6.1.1 (January 07, 2021) ##
133
106
 
134
- ## Rails 5.2.2.1 (March 11, 2019) ##
107
+ * Change `IPAddr#to_json` to match the behavior of the json gem returning the string representation
108
+ instead of the instance variables of the object.
135
109
 
136
- * No changes.
110
+ Before:
137
111
 
112
+ ```ruby
113
+ IPAddr.new("127.0.0.1").to_json
114
+ # => "{\"addr\":2130706433,\"family\":2,\"mask_addr\":4294967295}"
115
+ ```
138
116
 
139
- ## Rails 5.2.2 (December 04, 2018) ##
117
+ After:
140
118
 
141
- * Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
142
- would not act as alias for `#symbolize_keys`.
119
+ ```ruby
120
+ IPAddr.new("127.0.0.1").to_json
121
+ # => "\"127.0.0.1\""
122
+ ```
143
123
 
144
- *Nick Weiland*
145
124
 
146
- * Improve the logic that detects non-autoloaded constants.
125
+ ## Rails 6.1.0 (December 09, 2020) ##
147
126
 
148
- *Jan Habermann*, *Xavier Noria*
127
+ * Ensure `MemoryStore` disables compression by default. Reverts behavior of
128
+ `MemoryStore` to its prior rails `5.1` behavior.
149
129
 
150
- * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
130
+ *Max Gurewitz*
151
131
 
152
- URI.unescape("\xe3\x83\x90") # => "バ"
153
- URI.unescape("%E3%83%90") # => "バ"
154
- URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
132
+ * Calling `iso8601` on negative durations retains the negative sign on individual
133
+ digits instead of prepending it.
155
134
 
156
- *Ashe Connor*, *Aaron Patterson*
135
+ This change is required so we can interoperate with PostgreSQL, which prefers
136
+ negative signs for each component.
157
137
 
138
+ Compatibility with other iso8601 parsers which support leading negatives as well
139
+ as negatives per component is still retained.
158
140
 
159
- ## Rails 5.2.1.1 (November 27, 2018) ##
141
+ Before:
160
142
 
161
- * No changes.
143
+ (-1.year - 1.day).iso8601
144
+ # => "-P1Y1D"
162
145
 
146
+ After:
163
147
 
164
- ## Rails 5.2.1 (August 07, 2018) ##
148
+ (-1.year - 1.day).iso8601
149
+ # => "P-1Y-1D"
165
150
 
166
- * Redis cache store: `delete_matched` no longer blocks the Redis server.
167
- (Switches from evaled Lua to a batched SCAN + DEL loop.)
151
+ *Vipul A M*
168
152
 
169
- *Gleb Mazovetskiy*
153
+ * Remove deprecated `ActiveSupport::Notifications::Instrumenter#end=`.
170
154
 
171
- * Fix bug where `ActiveSupport::Timezone.all` would fail when tzinfo data for
172
- any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
155
+ *Rafael Mendonça França*
173
156
 
174
- *Dominik Sander*
157
+ * Deprecate `ActiveSupport::Multibyte::Unicode.default_normalization_form`.
175
158
 
176
- * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
177
- size when compression is enabled (which is true by default). This patch
178
- does not attempt to repair existing data: please manually flush the cache
179
- to clear out the problematic entries.
159
+ *Rafael Mendonça França*
180
160
 
181
- *Godfrey Chan*
161
+ * Remove deprecated `ActiveSupport::Multibyte::Unicode.pack_graphemes`,
162
+ `ActiveSupport::Multibyte::Unicode.unpack_graphemes`,
163
+ `ActiveSupport::Multibyte::Unicode.normalize`,
164
+ `ActiveSupport::Multibyte::Unicode.downcase`,
165
+ `ActiveSupport::Multibyte::Unicode.upcase` and `ActiveSupport::Multibyte::Unicode.swapcase`.
182
166
 
183
- * Fix `ActiveSupport::Cache#read_multi` bug with local cache enabled that was
184
- returning instances of `ActiveSupport::Cache::Entry` instead of the raw values.
167
+ *Rafael Mendonça França*
185
168
 
186
- *Jason Lee*
169
+ * Remove deprecated `ActiveSupport::Multibyte::Chars#consumes?` and `ActiveSupport::Multibyte::Chars#normalize`.
187
170
 
171
+ *Rafael Mendonça França*
188
172
 
189
- ## Rails 5.2.0 (April 09, 2018) ##
173
+ * Remove deprecated file `active_support/core_ext/range/include_range`.
190
174
 
191
- * Caching: MemCache and Redis `read_multi` and `fetch_multi` speedup.
192
- Read from the local in-memory cache before consulting the backend.
175
+ *Rafael Mendonça França*
193
176
 
194
- *Gabriel Sobrinho*
177
+ * Remove deprecated file `active_support/core_ext/hash/transform_values`.
195
178
 
196
- * Return all mappings for a timezone identifier in `country_zones`.
179
+ *Rafael Mendonça França*
197
180
 
198
- Some timezones like `Europe/London` have multiple mappings in
199
- `ActiveSupport::TimeZone::MAPPING` so return all of them instead
200
- of the first one found by using `Hash#value`. e.g:
181
+ * Remove deprecated file `active_support/core_ext/hash/compact`.
201
182
 
202
- # Before
203
- ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"]
183
+ *Rafael Mendonça França*
204
184
 
205
- # After
206
- ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"]
185
+ * Remove deprecated file `active_support/core_ext/array/prepend_and_append`.
207
186
 
208
- Fixes #31668.
187
+ *Rafael Mendonça França*
209
188
 
210
- *Andrew White*
189
+ * Remove deprecated file `active_support/core_ext/numeric/inquiry`.
211
190
 
212
- * Add support for connection pooling on RedisCacheStore.
191
+ *Rafael Mendonça França*
213
192
 
214
- *fatkodima*
193
+ * Remove deprecated file `active_support/core_ext/module/reachable`.
215
194
 
216
- * Support hash as first argument in `assert_difference`. This allows to specify multiple
217
- numeric differences in the same assertion.
195
+ *Rafael Mendonça França*
218
196
 
219
- assert_difference ->{ Article.count } => 1, ->{ Post.count } => 2
197
+ * Remove deprecated `Module#parent_name`, `Module#parent` and `Module#parents`.
220
198
 
221
- *Julien Meichelbeck*
199
+ *Rafael Mendonça França*
222
200
 
223
- * Add missing instrumentation for `read_multi` in `ActiveSupport::Cache::Store`.
201
+ * Remove deprecated `ActiveSupport::LoggerThreadSafeLevel#after_initialize`.
224
202
 
225
- *Ignatius Reza Lesmana*
203
+ *Rafael Mendonça França*
226
204
 
227
- * `assert_changes` will always assert that the expression changes,
228
- regardless of `from:` and `to:` argument combinations.
205
+ * Remove deprecated `LoggerSilence` constant.
229
206
 
230
- *Daniel Ma*
207
+ *Rafael Mendonça França*
231
208
 
232
- * Use SHA-1 to generate non-sensitive digests, such as the ETag header.
209
+ * Remove deprecated fallback to `I18n.default_local` when `config.i18n.fallbacks` is empty.
233
210
 
234
- Enabled by default for new apps; upgrading apps can opt in by setting
235
- `config.active_support.use_sha1_digests = true`.
211
+ *Rafael Mendonça França*
236
212
 
237
- *Dmitri Dolguikh*, *Eugene Kenny*
213
+ * Remove entries from local cache on `RedisCacheStore#delete_matched`
238
214
 
239
- * Changed default behaviour of `ActiveSupport::SecurityUtils.secure_compare`,
240
- to make it not leak length information even for variable length string.
215
+ Fixes #38627
241
216
 
242
- Renamed old `ActiveSupport::SecurityUtils.secure_compare` to `fixed_length_secure_compare`,
243
- and started raising `ArgumentError` in case of length mismatch of passed strings.
217
+ *ojab*
244
218
 
245
- *Vipul A M*
219
+ * Speed up `ActiveSupport::SecurityUtils.fixed_length_secure_compare` by using
220
+ `OpenSSL.fixed_length_secure_compare`, if available.
246
221
 
247
- * Make `ActiveSupport::TimeZone.all` return only time zones that are in
248
- `ActiveSupport::TimeZone::MAPPING`.
222
+ *Nate Matykiewicz*
249
223
 
250
- Fixes #7245.
224
+ * `ActiveSupport::Cache::MemCacheStore` now checks `ENV["MEMCACHE_SERVERS"]` before falling back to `"localhost:11211"` if configured without any addresses.
251
225
 
252
- *Chris LaRose*
226
+ ```ruby
227
+ config.cache_store = :mem_cache_store
253
228
 
254
- * MemCacheStore: Support expiring counters.
229
+ # is now equivalent to
255
230
 
256
- Pass `expires_in: [seconds]` to `#increment` and `#decrement` options
257
- to set the Memcached TTL (time-to-live) if the counter doesn't exist.
258
- If the counter exists, Memcached doesn't extend its expiry when it's
259
- incremented or decremented.
231
+ config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
260
232
 
261
- ```
262
- Rails.cache.increment("my_counter", 1, expires_in: 2.minutes)
263
- ```
233
+ # instead of
264
234
 
265
- *Takumasa Ochi*
235
+ config.cache_store = :mem_cache_store, "localhost:11211" # ignores ENV["MEMCACHE_SERVERS"]
236
+ ```
266
237
 
267
- * Handle `TZInfo::AmbiguousTime` errors.
238
+ *Sam Bostock*
268
239
 
269
- Make `ActiveSupport::TimeWithZone` match Ruby's handling of ambiguous
270
- times by choosing the later period, e.g.
240
+ * `ActiveSupport::Subscriber#attach_to` now accepts an `inherit_all:` argument. When set to true,
241
+ it allows a subscriber to receive events for methods defined in the subscriber's ancestor class(es).
271
242
 
272
- Ruby:
273
- ```
274
- ENV["TZ"] = "Europe/Moscow"
275
- Time.local(2014, 10, 26, 1, 0, 0) # => 2014-10-26 01:00:00 +0300
276
- ```
243
+ ```ruby
244
+ class ActionControllerSubscriber < ActiveSupport::Subscriber
245
+ attach_to :action_controller
277
246
 
278
- Before:
279
- ```
280
- >> "2014-10-26 01:00:00".in_time_zone("Moscow")
281
- TZInfo::AmbiguousTime: 26/10/2014 01:00 is an ambiguous local time.
282
- ```
247
+ def start_processing(event)
248
+ info "Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}"
249
+ end
283
250
 
284
- After:
285
- ```
286
- >> "2014-10-26 01:00:00".in_time_zone("Moscow")
287
- => Sun, 26 Oct 2014 01:00:00 MSK +03:00
288
- ```
251
+ def redirect_to(event)
252
+ info { "Redirected to #{event.payload[:location]}" }
253
+ end
254
+ end
289
255
 
290
- Fixes #17395.
256
+ # We detach ActionControllerSubscriber from the :action_controller namespace so that our CustomActionControllerSubscriber
257
+ # can provide its own instrumentation for certain events in the namespace
258
+ ActionControllerSubscriber.detach_from(:action_controller)
291
259
 
292
- *Andrew White*
260
+ class CustomActionControllerSubscriber < ActionControllerSubscriber
261
+ attach_to :action_controller, inherit_all: true
293
262
 
294
- * Redis cache store.
263
+ def start_processing(event)
264
+ info "A custom response to start_processing events"
265
+ end
295
266
 
296
- ```
297
- # Defaults to `redis://localhost:6379/0`. Only use for dev/test.
298
- config.cache_store = :redis_cache_store
299
-
300
- # Supports all common cache store options (:namespace, :compress,
301
- # :compress_threshold, :expires_in, :race_condition_ttl) and all
302
- # Redis options.
303
- cache_password = Rails.application.secrets.redis_cache_password
304
- config.cache_store = :redis_cache_store, driver: :hiredis,
305
- namespace: 'myapp-cache', compress: true, timeout: 1,
306
- url: "redis://:#{cache_password}@myapp-cache-1:6379/0"
307
-
308
- # Supports Redis::Distributed with multiple hosts
309
- config.cache_store = :redis_cache_store, driver: :hiredis
310
- namespace: 'myapp-cache', compress: true,
311
- url: %w[
312
- redis://myapp-cache-1:6379/0
313
- redis://myapp-cache-1:6380/0
314
- redis://myapp-cache-2:6379/0
315
- redis://myapp-cache-2:6380/0
316
- redis://myapp-cache-3:6379/0
317
- redis://myapp-cache-3:6380/0
318
- ]
319
-
320
- # Or pass a builder block
321
- config.cache_store = :redis_cache_store,
322
- namespace: 'myapp-cache', compress: true,
323
- redis: -> { Redis.new … }
267
+ # => CustomActionControllerSubscriber will process events for "start_processing.action_controller" notifications
268
+ # using its own #start_processing implementation, while retaining ActionControllerSubscriber's instrumentation
269
+ # for "redirect_to.action_controller" notifications
270
+ end
324
271
  ```
325
272
 
326
- Deployment note: Take care to use a *dedicated Redis cache* rather
327
- than pointing this at your existing Redis server. It won't cope well
328
- with mixed usage patterns and it won't expire cache entries by default.
273
+ *Adrianna Chang*
329
274
 
330
- Redis cache server setup guide: https://redis.io/topics/lru-cache
275
+ * Allow the digest class used to generate non-sensitive digests to be configured with `config.active_support.hash_digest_class`.
331
276
 
332
- *Jeremy Daer*
277
+ `config.active_support.use_sha1_digests` is deprecated in favour of `config.active_support.hash_digest_class = ::Digest::SHA1`.
333
278
 
334
- * Cache: Enable compression by default for values > 1kB.
279
+ *Dirkjan Bussink*
335
280
 
336
- Compression has long been available, but opt-in and at a 16kB threshold.
337
- It wasn't enabled by default due to CPU cost. Today it's cheap and typical
338
- cache data is eminently compressible, such as HTML or JSON fragments.
339
- Compression dramatically reduces Memcached/Redis mem usage, which means
340
- the same cache servers can store more data, which means higher hit rates.
281
+ * Fix bug to make memcached write_entry expire correctly with unless_exist
341
282
 
342
- To disable compression, pass `compress: false` to the initializer.
283
+ *Jye Lee*
343
284
 
344
- *Jeremy Daer*
285
+ * Add `ActiveSupport::Duration` conversion methods
345
286
 
346
- * Allow `Range#include?` on TWZ ranges.
287
+ `in_seconds`, `in_minutes`, `in_hours`, `in_days`, `in_weeks`, `in_months`, and `in_years` return the respective duration covered.
347
288
 
348
- In #11474 we prevented TWZ ranges being iterated over which matched
349
- Ruby's handling of Time ranges and as a consequence `include?`
350
- stopped working with both Time ranges and TWZ ranges. However in
351
- ruby/ruby@b061634 support was added for `include?` to use `cover?`
352
- for 'linear' objects. Since we have no way of making Ruby consider
353
- TWZ instances as 'linear' we have to override `Range#include?`.
289
+ *Jason York*
354
290
 
355
- Fixes #30799.
291
+ * Fixed issue in `ActiveSupport::Cache::RedisCacheStore` not passing options
292
+ to `read_multi` causing `fetch_multi` to not work properly
356
293
 
357
- *Andrew White*
294
+ *Rajesh Sharma*
358
295
 
359
- * Fix acronym support in `humanize`.
296
+ * Fixed issue in `ActiveSupport::Cache::MemCacheStore` which caused duplicate compression,
297
+ and caused the provided `compression_threshold` to not be respected.
360
298
 
361
- Acronym inflections are stored with lowercase keys in the hash but
362
- the match wasn't being lowercased before being looked up in the hash.
363
- This shouldn't have any performance impact because before it would
364
- fail to find the acronym and perform the `downcase` operation anyway.
299
+ *Max Gurewitz*
365
300
 
366
- Fixes #31052.
301
+ * Prevent `RedisCacheStore` and `MemCacheStore` from performing compression
302
+ when reading entries written with `raw: true`.
367
303
 
368
- *Andrew White*
304
+ *Max Gurewitz*
369
305
 
370
- * Add same method signature for `Time#prev_year` and `Time#next_year`
371
- in accordance with `Date#prev_year`, `Date#next_year`.
306
+ * `URI.parser` is deprecated and will be removed in Rails 6.2. Use
307
+ `URI::DEFAULT_PARSER` instead.
372
308
 
373
- Allows pass argument for `Time#prev_year` and `Time#next_year`.
309
+ *Jean Boussier*
374
310
 
375
- Before:
376
- ```
377
- Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
378
- Time.new(2017, 9, 16, 17, 0).prev_year(1)
379
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
311
+ * `require_dependency` has been documented to be _obsolete_ in `:zeitwerk`
312
+ mode. The method is not deprecated as such (yet), but applications are
313
+ encouraged to not use it.
380
314
 
381
- Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
382
- Time.new(2017, 9, 16, 17, 0).next_year(1)
383
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
384
- ```
315
+ In `:zeitwerk` mode, semantics match Ruby's and you do not need to be
316
+ defensive with load order. Just refer to classes and modules normally. If
317
+ the constant name is dynamic, camelize if needed, and constantize.
385
318
 
386
- After:
387
- ```
388
- Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
389
- Time.new(2017, 9, 16, 17, 0).prev_year(1) # => 2016-09-16 17:00:00 +0300
319
+ *Xavier Noria*
320
+
321
+ * Add 3rd person aliases of `Symbol#start_with?` and `Symbol#end_with?`.
390
322
 
391
- Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
392
- Time.new(2017, 9, 16, 17, 0).next_year(1) # => 2018-09-16 17:00:00 +0300
323
+ ```ruby
324
+ :foo.starts_with?("f") # => true
325
+ :foo.ends_with?("o") # => true
393
326
  ```
394
327
 
395
- *bogdanvlviv*
328
+ *Ryuta Kamizono*
396
329
 
397
- * Add same method signature for `Time#prev_month` and `Time#next_month`
398
- in accordance with `Date#prev_month`, `Date#next_month`.
330
+ * Add override of unary plus for `ActiveSupport::Duration`.
399
331
 
400
- Allows pass argument for `Time#prev_month` and `Time#next_month`.
332
+ `+ 1.second` is now identical to `+1.second` to prevent errors
333
+ where a seemingly innocent change of formatting leads to a change in the code behavior.
401
334
 
402
335
  Before:
403
- ```
404
- Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
405
- Time.new(2017, 9, 16, 17, 0).prev_month(1)
406
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
407
-
408
- Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
409
- Time.new(2017, 9, 16, 17, 0).next_month(1)
410
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
336
+ ```ruby
337
+ +1.second.class
338
+ # => ActiveSupport::Duration
339
+ (+ 1.second).class
340
+ # => Integer
411
341
  ```
412
342
 
413
343
  After:
414
- ```
415
- Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
416
- Time.new(2017, 9, 16, 17, 0).prev_month(1) # => 2017-08-16 17:00:00 +0300
417
-
418
- Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
419
- Time.new(2017, 9, 16, 17, 0).next_month(1) # => 2017-10-16 17:00:00 +0300
344
+ ```ruby
345
+ +1.second.class
346
+ # => ActiveSupport::Duration
347
+ (+ 1.second).class
348
+ # => ActiveSupport::Duration
420
349
  ```
421
350
 
422
- *bogdanvlviv*
351
+ Fixes #39079.
423
352
 
424
- * Add same method signature for `Time#prev_day` and `Time#next_day`
425
- in accordance with `Date#prev_day`, `Date#next_day`.
353
+ *Roman Kushnir*
426
354
 
427
- Allows pass argument for `Time#prev_day` and `Time#next_day`.
355
+ * Add subsec to `ActiveSupport::TimeWithZone#inspect`.
428
356
 
429
357
  Before:
430
- ```
431
- Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
432
- Time.new(2017, 9, 16, 17, 0).prev_day(1)
433
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
434
358
 
435
- Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
436
- Time.new(2017, 9, 16, 17, 0).next_day(1)
437
- # => ArgumentError: wrong number of arguments (given 1, expected 0)
438
- ```
359
+ Time.at(1498099140).in_time_zone.inspect
360
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
361
+ Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
362
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
363
+ Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
364
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
439
365
 
440
366
  After:
441
- ```
442
- Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
443
- Time.new(2017, 9, 16, 17, 0).prev_day(1) # => 2017-09-15 17:00:00 +0300
444
367
 
445
- Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
446
- Time.new(2017, 9, 16, 17, 0).next_day(1) # => 2017-09-17 17:00:00 +0300
447
- ```
368
+ Time.at(1498099140).in_time_zone.inspect
369
+ # => "Thu, 22 Jun 2017 02:39:00.000000000 UTC +00:00"
370
+ Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
371
+ # => "Thu, 22 Jun 2017 02:39:00.123456780 UTC +00:00"
372
+ Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
373
+ # => "Thu, 22 Jun 2017 02:39:00.333333333 UTC +00:00"
448
374
 
449
- *bogdanvlviv*
375
+ *akinomaeni*
450
376
 
451
- * `IO#to_json` now returns the `to_s` representation, rather than
452
- attempting to convert to an array. This fixes a bug where `IO#to_json`
453
- would raise an `IOError` when called on an unreadable object.
377
+ * Calling `ActiveSupport::TaggedLogging#tagged` without a block now returns a tagged logger.
454
378
 
455
- Fixes #26132.
379
+ ```ruby
380
+ logger.tagged("BCX").info("Funky time!") # => [BCX] Funky time!
381
+ ```
456
382
 
457
- *Paul Kuruvilla*
383
+ *Eugene Kenny*
458
384
 
459
- * Remove deprecated `halt_callback_chains_on_return_false` option.
385
+ * Align `Range#cover?` extension behavior with Ruby behavior for backwards ranges.
460
386
 
461
- *Rafael Mendonça França*
387
+ `(1..10).cover?(5..3)` now returns `false`, as it does in plain Ruby.
462
388
 
463
- * Remove deprecated `:if` and `:unless` string filter for callbacks.
389
+ Also update `#include?` and `#===` behavior to match.
464
390
 
465
- *Rafael Mendonça França*
391
+ *Michael Groeneman*
466
392
 
467
- * `Hash#slice` now falls back to Ruby 2.5+'s built-in definition if defined.
393
+ * Update to TZInfo v2.0.0.
468
394
 
469
- *Akira Matsuda*
395
+ This changes the output of `ActiveSupport::TimeZone.utc_to_local`, but
396
+ can be controlled with the
397
+ `ActiveSupport.utc_to_local_returns_utc_offset_times` config.
470
398
 
471
- * Deprecate `secrets.secret_token`.
399
+ New Rails 6.1 apps have it enabled by default, existing apps can upgrade
400
+ via the config in config/initializers/new_framework_defaults_6_1.rb
472
401
 
473
- The architecture for secrets had a big upgrade between Rails 3 and Rails 4,
474
- when the default changed from using `secret_token` to `secret_key_base`.
402
+ See the `utc_to_local_returns_utc_offset_times` documentation for details.
475
403
 
476
- `secret_token` has been soft deprecated in documentation for four years
477
- but is still in place to support apps created before Rails 4.
478
- Deprecation warnings have been added to help developers upgrade their
479
- applications to `secret_key_base`.
404
+ *Phil Ross*, *Jared Beck*
480
405
 
481
- *claudiob*, *Kasper Timm Hansen*
406
+ * Add Date and Time `#yesterday?` and `#tomorrow?` alongside `#today?`.
482
407
 
483
- * Return an instance of `HashWithIndifferentAccess` from `HashWithIndifferentAccess#transform_keys`.
408
+ Aliased to `#prev_day?` and `#next_day?` to match the existing `#prev/next_day` methods.
484
409
 
485
- *Yuji Yaginuma*
410
+ *Jatin Dhankhar*
486
411
 
487
- * Add key rotation support to `MessageEncryptor` and `MessageVerifier`.
412
+ * Add `Enumerable#pick` to complement `ActiveRecord::Relation#pick`.
488
413
 
489
- This change introduces a `rotate` method to both the `MessageEncryptor` and
490
- `MessageVerifier` classes. This method accepts the same arguments and
491
- options as the given classes' constructor. The `encrypt_and_verify` method
492
- for `MessageEncryptor` and the `verified` method for `MessageVerifier` also
493
- accept an optional keyword argument `:on_rotation` block which is called
494
- when a rotated instance is used to decrypt or verify the message.
414
+ *Eugene Kenny*
495
415
 
496
- *Michael J Coyne*
416
+ * [Breaking change] `ActiveSupport::Callbacks#halted_callback_hook` now receive a 2nd argument:
497
417
 
498
- * Deprecate `Module#reachable?` method.
418
+ `ActiveSupport::Callbacks#halted_callback_hook` now receive the name of the callback
419
+ being halted as second argument.
420
+ This change will allow you to differentiate which callbacks halted the chain
421
+ and act accordingly.
499
422
 
500
- *bogdanvlviv*
423
+ ```ruby
424
+ class Book < ApplicationRecord
425
+ before_save { throw(:abort) }
426
+ before_create { throw(:abort) }
501
427
 
502
- * Add `config/credentials.yml.enc` to store production app secrets.
428
+ def halted_callback_hook(filter, callback_name)
429
+ Rails.logger.info("Book couldn't be #{callback_name}d")
430
+ end
503
431
 
504
- Allows saving any authentication credentials for third party services
505
- directly in repo encrypted with `config/master.key` or `ENV["RAILS_MASTER_KEY"]`.
432
+ Book.create # => "Book couldn't be created"
433
+ book.save # => "Book couldn't be saved"
434
+ end
435
+ ```
506
436
 
507
- This will eventually replace `Rails.application.secrets` and the encrypted
508
- secrets introduced in Rails 5.1.
437
+ *Edouard Chin*
509
438
 
510
- *DHH*, *Kasper Timm Hansen*
439
+ * Support `prepend` with `ActiveSupport::Concern`.
511
440
 
512
- * Add `ActiveSupport::EncryptedFile` and `ActiveSupport::EncryptedConfiguration`.
441
+ Allows a module with `extend ActiveSupport::Concern` to be prepended.
513
442
 
514
- Allows for stashing encrypted files or configuration directly in repo by
515
- encrypting it with a key.
443
+ module Imposter
444
+ extend ActiveSupport::Concern
516
445
 
517
- Backs the new credentials setup above, but can also be used independently.
446
+ # Same as `included`, except only run when prepended.
447
+ prepended do
448
+ end
449
+ end
518
450
 
519
- *DHH*, *Kasper Timm Hansen*
451
+ class Person
452
+ prepend Imposter
453
+ end
520
454
 
521
- * `Module#delegate_missing_to` now raises `DelegationError` if target is nil,
522
- similar to `Module#delegate`.
455
+ Class methods are prepended to the base class, concerning is also
456
+ updated: `concerning :Imposter, prepend: true do`.
523
457
 
524
- *Anton Khamets*
458
+ *Jason Karns*, *Elia Schito*
525
459
 
526
- * Update `String#camelize` to provide feedback when wrong option is passed.
460
+ * Deprecate using `Range#include?` method to check the inclusion of a value
461
+ in a date time range. It is recommended to use `Range#cover?` method
462
+ instead of `Range#include?` to check the inclusion of a value
463
+ in a date time range.
527
464
 
528
- `String#camelize` was returning nil without any feedback when an
529
- invalid option was passed as a parameter.
465
+ *Vishal Telangre*
530
466
 
531
- Previously:
467
+ * Support added for a `round_mode` parameter, in all number helpers. (See: `BigDecimal::mode`.)
532
468
 
533
- 'one_two'.camelize(true)
534
- # => nil
469
+ ```ruby
470
+ number_to_currency(1234567890.50, precision: 0, round_mode: :half_down) # => "$1,234,567,890"
471
+ number_to_percentage(302.24398923423, precision: 5, round_mode: :down) # => "302.24398%"
472
+ number_to_rounded(389.32314, precision: 0, round_mode: :ceil) # => "390"
473
+ number_to_human_size(483989, precision: 2, round_mode: :up) # => "480 KB"
474
+ number_to_human(489939, precision: 2, round_mode: :floor) # => "480 Thousand"
535
475
 
536
- Now:
476
+ 485000.to_s(:human, precision: 2, round_mode: :half_even) # => "480 Thousand"
477
+ ```
537
478
 
538
- 'one_two'.camelize(true)
539
- # => ArgumentError: Invalid option, use either :upper or :lower.
479
+ *Tom Lord*
540
480
 
541
- *Ricardo Díaz*
481
+ * `Array#to_sentence` no longer returns a frozen string.
542
482
 
543
- * Fix modulo operations involving durations.
483
+ Before:
544
484
 
545
- Rails 5.1 introduced `ActiveSupport::Duration::Scalar` as a wrapper
546
- around numeric values as a way of ensuring a duration was the outcome of
547
- an expression. However, the implementation was missing support for modulo
548
- operations. This support has now been added and should result in a duration
549
- being returned from expressions involving modulo operations.
485
+ ['one', 'two'].to_sentence.frozen?
486
+ # => true
550
487
 
551
- Prior to Rails 5.1:
488
+ After:
552
489
 
553
- 5.minutes % 2.minutes
554
- # => 60
490
+ ['one', 'two'].to_sentence.frozen?
491
+ # => false
555
492
 
556
- Now:
493
+ *Nicolas Dular*
557
494
 
558
- 5.minutes % 2.minutes
559
- # => 1 minute
495
+ * When an instance of `ActiveSupport::Duration` is converted to an `iso8601` duration string, if `weeks` are mixed with `date` parts, the `week` part will be converted to days.
496
+ This keeps the parser and serializer on the same page.
560
497
 
561
- Fixes #29603 and #29743.
498
+ ```ruby
499
+ duration = ActiveSupport::Duration.build(1000000)
500
+ # 1 week, 4 days, 13 hours, 46 minutes, and 40.0 seconds
562
501
 
563
- *Sayan Chakraborty*, *Andrew White*
502
+ duration_iso = duration.iso8601
503
+ # P11DT13H46M40S
564
504
 
565
- * Fix division where a duration is the denominator.
505
+ ActiveSupport::Duration.parse(duration_iso)
506
+ # 11 days, 13 hours, 46 minutes, and 40 seconds
566
507
 
567
- PR #29163 introduced a change in behavior when a duration was the denominator
568
- in a calculation - this was incorrect as dividing by a duration should always
569
- return a `Numeric`. The behavior of previous versions of Rails has been restored.
508
+ duration = ActiveSupport::Duration.build(604800)
509
+ # 1 week
570
510
 
571
- Fixes #29592.
511
+ duration_iso = duration.iso8601
512
+ # P1W
572
513
 
573
- *Andrew White*
514
+ ActiveSupport::Duration.parse(duration_iso)
515
+ # 1 week
516
+ ```
574
517
 
575
- * Add purpose and expiry support to `ActiveSupport::MessageVerifier` and
576
- `ActiveSupport::MessageEncryptor`.
518
+ *Abhishek Sarkar*
577
519
 
578
- For instance, to ensure a message is only usable for one intended purpose:
520
+ * Add block support to `ActiveSupport::Testing::TimeHelpers#travel_back`.
579
521
 
580
- token = @verifier.generate("x", purpose: :shipping)
522
+ *Tim Masliuchenko*
581
523
 
582
- @verifier.verified(token, purpose: :shipping) # => "x"
583
- @verifier.verified(token) # => nil
524
+ * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
525
+ `ActiveSupport.parse_json_times = true`.
584
526
 
585
- Or make it expire after a set time:
527
+ *Christian Gregg*
586
528
 
587
- @verifier.generate("x", expires_in: 1.month)
588
- @verifier.generate("y", expires_at: Time.now.end_of_year)
529
+ * Support symbolic links for `content_path` in `ActiveSupport::EncryptedFile`.
589
530
 
590
- Showcased with `ActiveSupport::MessageVerifier`, but works the same for
591
- `ActiveSupport::MessageEncryptor`'s `encrypt_and_sign` and `decrypt_and_verify`.
531
+ *Takumi Shotoku*
592
532
 
593
- Pull requests: #29599, #29854
533
+ * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
534
+ and endless range targets.
594
535
 
595
- *Assain Jaleel*
536
+ *Allen Hsu*, *Andrew Hodgkinson*
596
537
 
597
- * Make the order of `Hash#reverse_merge!` consistent with `HashWithIndifferentAccess`.
538
+ * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
598
539
 
599
- *Erol Fornoles*
540
+ *Iain Beeston*
600
541
 
601
- * Add `freeze_time` helper which freezes time to `Time.now` in tests.
542
+ * Prevent `ActiveSupport::Duration.build(value)` from creating instances of
543
+ `ActiveSupport::Duration` unless `value` is of type `Numeric`.
602
544
 
603
- *Prathamesh Sonpatki*
545
+ Addresses the errant set of behaviours described in #37012 where
546
+ `ActiveSupport::Duration` comparisons would fail confusingly
547
+ or return unexpected results when comparing durations built from instances of `String`.
604
548
 
605
- * Default `ActiveSupport::MessageEncryptor` to use AES 256 GCM encryption.
549
+ Before:
606
550
 
607
- On for new Rails 5.2 apps. Upgrading apps can find the config as a new
608
- framework default.
551
+ small_duration_from_string = ActiveSupport::Duration.build('9')
552
+ large_duration_from_string = ActiveSupport::Duration.build('100000000000000')
553
+ small_duration_from_int = ActiveSupport::Duration.build(9)
609
554
 
610
- *Assain Jaleel*
555
+ large_duration_from_string > small_duration_from_string
556
+ # => false
611
557
 
612
- * Cache: `write_multi`.
558
+ small_duration_from_string == small_duration_from_int
559
+ # => false
613
560
 
614
- Rails.cache.write_multi foo: 'bar', baz: 'qux'
561
+ small_duration_from_int < large_duration_from_string
562
+ # => ArgumentError (comparison of ActiveSupport::Duration::Scalar with ActiveSupport::Duration failed)
615
563
 
616
- Plus faster fetch_multi with stores that implement `write_multi_entries`.
617
- Keys that aren't found may be written to the cache store in one shot
618
- instead of separate writes.
564
+ large_duration_from_string > small_duration_from_int
565
+ # => ArgumentError (comparison of String with ActiveSupport::Duration failed)
619
566
 
620
- The default implementation simply calls `write_entry` for each entry.
621
- Stores may override if they're capable of one-shot bulk writes, like
622
- Redis `MSET`.
567
+ After:
623
568
 
624
- *Jeremy Daer*
569
+ small_duration_from_string = ActiveSupport::Duration.build('9')
570
+ # => TypeError (can't build an ActiveSupport::Duration from a String)
625
571
 
626
- * Add default option to module and class attribute accessors.
572
+ *Alexei Emam*
627
573
 
628
- mattr_accessor :settings, default: {}
574
+ * Add `ActiveSupport::Cache::Store#delete_multi` method to delete multiple keys from the cache store.
629
575
 
630
- Works for `mattr_reader`, `mattr_writer`, `cattr_accessor`, `cattr_reader`,
631
- and `cattr_writer` as well.
576
+ *Peter Zhu*
632
577
 
633
- *Genadi Samokovarov*
578
+ * Support multiple arguments in `HashWithIndifferentAccess` for `merge` and `update` methods, to
579
+ follow Ruby 2.6 addition.
634
580
 
635
- * Add `Date#prev_occurring` and `Date#next_occurring` to return specified next/previous occurring day of week.
581
+ *Wojciech Wnętrzak*
636
582
 
637
- *Shota Iguchi*
583
+ * Allow initializing `thread_mattr_*` attributes via `:default` option.
638
584
 
639
- * Add default option to `class_attribute`.
585
+ class Scraper
586
+ thread_mattr_reader :client, default: Api::Client.new
587
+ end
640
588
 
641
- Before:
589
+ *Guilherme Mansur*
642
590
 
643
- class_attribute :settings
644
- self.settings = {}
591
+ * Add `compact_blank` for those times when you want to remove #blank? values from
592
+ an Enumerable (also `compact_blank!` on Hash, Array, ActionController::Parameters).
645
593
 
646
- Now:
594
+ *Dana Sherson*
647
595
 
648
- class_attribute :settings, default: {}
596
+ * Make ActiveSupport::Logger Fiber-safe.
649
597
 
650
- *DHH*
598
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
599
+ to make log level local to Ruby Fibers in addition to Threads.
651
600
 
652
- * `#singularize` and `#pluralize` now respect uncountables for the specified locale.
601
+ Example:
653
602
 
654
- *Eilis Hamilton*
603
+ logger = ActiveSupport::Logger.new(STDOUT)
604
+ logger.level = 1
605
+ puts "Main is debug? #{logger.debug?}"
606
+
607
+ Fiber.new {
608
+ logger.local_level = 0
609
+ puts "Thread is debug? #{logger.debug?}"
610
+ }.resume
655
611
 
656
- * Add `ActiveSupport::CurrentAttributes` to provide a thread-isolated attributes singleton.
657
- Primary use case is keeping all the per-request attributes easily available to the whole system.
612
+ puts "Main is debug? #{logger.debug?}"
658
613
 
659
- *DHH*
614
+ Before:
660
615
 
661
- * Fix implicit coercion calculations with scalars and durations.
616
+ Main is debug? false
617
+ Thread is debug? true
618
+ Main is debug? true
662
619
 
663
- Previously, calculations where the scalar is first would be converted to a duration
664
- of seconds, but this causes issues with dates being converted to times, e.g:
620
+ After:
665
621
 
666
- Time.zone = "Beijing" # => Asia/Shanghai
667
- date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
668
- 2 * 1.day # => 172800 seconds
669
- date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00
622
+ Main is debug? false
623
+ Thread is debug? true
624
+ Main is debug? false
670
625
 
671
- Now, the `ActiveSupport::Duration::Scalar` calculation methods will try to maintain
672
- the part structure of the duration where possible, e.g:
626
+ Fixes #36752.
673
627
 
674
- Time.zone = "Beijing" # => Asia/Shanghai
675
- date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
676
- 2 * 1.day # => 2 days
677
- date + 2 * 1.day # => Mon, 22 May 2017
628
+ *Alexander Varnin*
678
629
 
679
- Fixes #29160, #28970.
630
+ * Allow the `on_rotation` proc used when decrypting/verifying a message to be
631
+ passed at the constructor level.
680
632
 
681
- *Andrew White*
633
+ Before:
682
634
 
683
- * Add support for versioned cache entries. This enables the cache stores to recycle cache keys, greatly saving
684
- on storage in cases with frequent churn. Works together with the separation of `#cache_key` and `#cache_version`
685
- in Active Record and its use in Action Pack's fragment caching.
635
+ crypt = ActiveSupport::MessageEncryptor.new('long_secret')
636
+ crypt.decrypt_and_verify(encrypted_message, on_rotation: proc { ... })
637
+ crypt.decrypt_and_verify(another_encrypted_message, on_rotation: proc { ... })
686
638
 
687
- *DHH*
639
+ After:
688
640
 
689
- * Pass gem name and deprecation horizon to deprecation notifications.
641
+ crypt = ActiveSupport::MessageEncryptor.new('long_secret', on_rotation: proc { ... })
642
+ crypt.decrypt_and_verify(encrypted_message)
643
+ crypt.decrypt_and_verify(another_encrypted_message)
690
644
 
691
- *Willem van Bergen*
645
+ *Edouard Chin*
692
646
 
693
- * Add support for `:offset` and `:zone` to `ActiveSupport::TimeWithZone#change`.
647
+ * `delegate_missing_to` would raise a `DelegationError` if the object
648
+ delegated to was `nil`. Now the `allow_nil` option has been added to enable
649
+ the user to specify they want `nil` returned in this case.
694
650
 
695
- *Andrew White*
651
+ *Matthew Tanous*
696
652
 
697
- * Add support for `:offset` to `Time#change`.
653
+ * `truncate` would return the original string if it was too short to be truncated
654
+ and a frozen string if it were long enough to be truncated. Now truncate will
655
+ consistently return an unfrozen string regardless. This behavior is consistent
656
+ with `gsub` and `strip`.
698
657
 
699
- Fixes #28723.
658
+ Before:
700
659
 
701
- *Andrew White*
660
+ 'foobar'.truncate(5).frozen?
661
+ # => true
662
+ 'foobar'.truncate(6).frozen?
663
+ # => false
702
664
 
703
- * Add `fetch_values` for `HashWithIndifferentAccess`.
665
+ After:
704
666
 
705
- The method was originally added to `Hash` in Ruby 2.3.0.
667
+ 'foobar'.truncate(5).frozen?
668
+ # => false
669
+ 'foobar'.truncate(6).frozen?
670
+ # => false
706
671
 
707
- *Josh Pencheon*
672
+ *Jordan Thomas*
708
673
 
709
674
 
710
- Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activesupport/CHANGELOG.md) for previous changes.
675
+ Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activesupport/CHANGELOG.md) for previous changes.