activesupport 5.2.8.1 → 6.1.6.1

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