activesupport 5.0.0 → 6.1.0

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

Potentially problematic release.


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

Files changed (268) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +343 -590
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +5 -4
  5. data/lib/active_support/actionable_error.rb +48 -0
  6. data/lib/active_support/all.rb +5 -3
  7. data/lib/active_support/array_inquirer.rb +11 -5
  8. data/lib/active_support/backtrace_cleaner.rb +33 -5
  9. data/lib/active_support/benchmarkable.rb +5 -3
  10. data/lib/active_support/builder.rb +3 -1
  11. data/lib/active_support/cache/file_store.rb +45 -53
  12. data/lib/active_support/cache/mem_cache_store.rb +81 -79
  13. data/lib/active_support/cache/memory_store.rb +69 -41
  14. data/lib/active_support/cache/null_store.rb +11 -4
  15. data/lib/active_support/cache/redis_cache_store.rb +493 -0
  16. data/lib/active_support/cache/strategy/local_cache.rb +74 -37
  17. data/lib/active_support/cache/strategy/local_cache_middleware.rb +10 -9
  18. data/lib/active_support/cache.rb +332 -161
  19. data/lib/active_support/callbacks.rb +657 -586
  20. data/lib/active_support/concern.rb +79 -6
  21. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +35 -0
  22. data/lib/active_support/concurrency/share_lock.rb +59 -19
  23. data/lib/active_support/configurable.rb +15 -17
  24. data/lib/active_support/configuration_file.rb +46 -0
  25. data/lib/active_support/core_ext/array/access.rb +21 -7
  26. data/lib/active_support/core_ext/array/conversions.rb +20 -18
  27. data/lib/active_support/core_ext/array/extract.rb +21 -0
  28. data/lib/active_support/core_ext/array/extract_options.rb +2 -0
  29. data/lib/active_support/core_ext/array/grouping.rb +3 -1
  30. data/lib/active_support/core_ext/array/inquiry.rb +3 -1
  31. data/lib/active_support/core_ext/array/wrap.rb +2 -0
  32. data/lib/active_support/core_ext/array.rb +9 -7
  33. data/lib/active_support/core_ext/benchmark.rb +5 -3
  34. data/lib/active_support/core_ext/big_decimal/conversions.rb +6 -6
  35. data/lib/active_support/core_ext/big_decimal.rb +3 -1
  36. data/lib/active_support/core_ext/class/attribute.rb +52 -49
  37. data/lib/active_support/core_ext/class/attribute_accessors.rb +3 -1
  38. data/lib/active_support/core_ext/class/subclasses.rb +18 -26
  39. data/lib/active_support/core_ext/class.rb +4 -2
  40. data/lib/active_support/core_ext/date/acts_like.rb +3 -1
  41. data/lib/active_support/core_ext/date/blank.rb +3 -1
  42. data/lib/active_support/core_ext/date/calculations.rb +16 -13
  43. data/lib/active_support/core_ext/date/conversions.rb +23 -21
  44. data/lib/active_support/core_ext/date/zones.rb +4 -2
  45. data/lib/active_support/core_ext/date.rb +7 -5
  46. data/lib/active_support/core_ext/date_and_time/calculations.rb +82 -53
  47. data/lib/active_support/core_ext/date_and_time/compatibility.rb +18 -5
  48. data/lib/active_support/core_ext/date_and_time/zones.rb +9 -9
  49. data/lib/active_support/core_ext/date_time/acts_like.rb +4 -2
  50. data/lib/active_support/core_ext/date_time/blank.rb +3 -1
  51. data/lib/active_support/core_ext/date_time/calculations.rb +23 -11
  52. data/lib/active_support/core_ext/date_time/compatibility.rb +15 -2
  53. data/lib/active_support/core_ext/date_time/conversions.rb +14 -13
  54. data/lib/active_support/core_ext/date_time.rb +7 -5
  55. data/lib/active_support/core_ext/digest/uuid.rb +7 -5
  56. data/lib/active_support/core_ext/digest.rb +3 -0
  57. data/lib/active_support/core_ext/enumerable.rb +165 -29
  58. data/lib/active_support/core_ext/file/atomic.rb +7 -5
  59. data/lib/active_support/core_ext/file.rb +3 -1
  60. data/lib/active_support/core_ext/hash/conversions.rb +40 -39
  61. data/lib/active_support/core_ext/hash/deep_merge.rb +8 -12
  62. data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
  63. data/lib/active_support/core_ext/hash/except.rb +4 -2
  64. data/lib/active_support/core_ext/hash/indifferent_access.rb +3 -2
  65. data/lib/active_support/core_ext/hash/keys.rb +9 -36
  66. data/lib/active_support/core_ext/hash/reverse_merge.rb +5 -2
  67. data/lib/active_support/core_ext/hash/slice.rb +8 -29
  68. data/lib/active_support/core_ext/hash.rb +10 -9
  69. data/lib/active_support/core_ext/integer/inflections.rb +3 -1
  70. data/lib/active_support/core_ext/integer/multiple.rb +3 -1
  71. data/lib/active_support/core_ext/integer/time.rb +11 -18
  72. data/lib/active_support/core_ext/integer.rb +5 -3
  73. data/lib/active_support/core_ext/kernel/concern.rb +3 -1
  74. data/lib/active_support/core_ext/kernel/reporting.rb +3 -1
  75. data/lib/active_support/core_ext/kernel/singleton_class.rb +2 -0
  76. data/lib/active_support/core_ext/kernel.rb +5 -4
  77. data/lib/active_support/core_ext/load_error.rb +2 -23
  78. data/lib/active_support/core_ext/marshal.rb +6 -2
  79. data/lib/active_support/core_ext/module/aliasing.rb +5 -48
  80. data/lib/active_support/core_ext/module/anonymous.rb +2 -0
  81. data/lib/active_support/core_ext/module/attr_internal.rb +7 -5
  82. data/lib/active_support/core_ext/module/attribute_accessors.rb +53 -59
  83. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +31 -24
  84. data/lib/active_support/core_ext/module/concerning.rb +16 -11
  85. data/lib/active_support/core_ext/module/delegation.rb +159 -44
  86. data/lib/active_support/core_ext/module/deprecation.rb +2 -0
  87. data/lib/active_support/core_ext/module/introspection.rb +23 -26
  88. data/lib/active_support/core_ext/module/redefine_method.rb +40 -0
  89. data/lib/active_support/core_ext/module/remove_method.rb +5 -23
  90. data/lib/active_support/core_ext/module.rb +13 -12
  91. data/lib/active_support/core_ext/name_error.rb +36 -2
  92. data/lib/active_support/core_ext/numeric/bytes.rb +2 -0
  93. data/lib/active_support/core_ext/numeric/conversions.rb +129 -134
  94. data/lib/active_support/core_ext/numeric/time.rb +18 -26
  95. data/lib/active_support/core_ext/numeric.rb +5 -4
  96. data/lib/active_support/core_ext/object/acts_like.rb +12 -1
  97. data/lib/active_support/core_ext/object/blank.rb +14 -2
  98. data/lib/active_support/core_ext/object/conversions.rb +6 -4
  99. data/lib/active_support/core_ext/object/deep_dup.rb +4 -2
  100. data/lib/active_support/core_ext/object/duplicable.rb +13 -62
  101. data/lib/active_support/core_ext/object/inclusion.rb +3 -1
  102. data/lib/active_support/core_ext/object/instance_variables.rb +2 -0
  103. data/lib/active_support/core_ext/object/json.rb +42 -15
  104. data/lib/active_support/core_ext/object/to_param.rb +3 -1
  105. data/lib/active_support/core_ext/object/to_query.rb +10 -5
  106. data/lib/active_support/core_ext/object/try.rb +20 -8
  107. data/lib/active_support/core_ext/object/with_options.rb +15 -2
  108. data/lib/active_support/core_ext/object.rb +14 -12
  109. data/lib/active_support/core_ext/range/compare_range.rb +82 -0
  110. data/lib/active_support/core_ext/range/conversions.rb +35 -25
  111. data/lib/active_support/core_ext/range/each.rb +5 -2
  112. data/lib/active_support/core_ext/range/include_time_with_zone.rb +28 -0
  113. data/lib/active_support/core_ext/range/overlaps.rb +2 -0
  114. data/lib/active_support/core_ext/range.rb +7 -4
  115. data/lib/active_support/core_ext/regexp.rb +10 -1
  116. data/lib/active_support/core_ext/securerandom.rb +28 -6
  117. data/lib/active_support/core_ext/string/access.rb +9 -18
  118. data/lib/active_support/core_ext/string/behavior.rb +2 -0
  119. data/lib/active_support/core_ext/string/conversions.rb +5 -2
  120. data/lib/active_support/core_ext/string/exclude.rb +2 -0
  121. data/lib/active_support/core_ext/string/filters.rb +47 -4
  122. data/lib/active_support/core_ext/string/indent.rb +6 -4
  123. data/lib/active_support/core_ext/string/inflections.rb +78 -29
  124. data/lib/active_support/core_ext/string/inquiry.rb +4 -1
  125. data/lib/active_support/core_ext/string/multibyte.rb +10 -5
  126. data/lib/active_support/core_ext/string/output_safety.rb +86 -31
  127. data/lib/active_support/core_ext/string/starts_ends_with.rb +4 -2
  128. data/lib/active_support/core_ext/string/strip.rb +5 -1
  129. data/lib/active_support/core_ext/string/zones.rb +4 -2
  130. data/lib/active_support/core_ext/string.rb +15 -13
  131. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +14 -0
  132. data/lib/active_support/core_ext/symbol.rb +3 -0
  133. data/lib/active_support/core_ext/time/acts_like.rb +3 -1
  134. data/lib/active_support/core_ext/time/calculations.rb +117 -45
  135. data/lib/active_support/core_ext/time/compatibility.rb +13 -2
  136. data/lib/active_support/core_ext/time/conversions.rb +18 -12
  137. data/lib/active_support/core_ext/time/zones.rb +9 -7
  138. data/lib/active_support/core_ext/time.rb +7 -5
  139. data/lib/active_support/core_ext/uri.rb +12 -7
  140. data/lib/active_support/core_ext.rb +3 -2
  141. data/lib/active_support/current_attributes/test_helper.rb +13 -0
  142. data/lib/active_support/current_attributes.rb +208 -0
  143. data/lib/active_support/dependencies/autoload.rb +2 -0
  144. data/lib/active_support/dependencies/interlock.rb +7 -1
  145. data/lib/active_support/dependencies/zeitwerk_integration.rb +117 -0
  146. data/lib/active_support/dependencies.rb +172 -98
  147. data/lib/active_support/deprecation/behaviors.rb +45 -13
  148. data/lib/active_support/deprecation/constant_accessor.rb +52 -0
  149. data/lib/active_support/deprecation/disallowed.rb +56 -0
  150. data/lib/active_support/deprecation/instance_delegator.rb +16 -2
  151. data/lib/active_support/deprecation/method_wrappers.rb +32 -17
  152. data/lib/active_support/deprecation/proxy_wrappers.rb +35 -7
  153. data/lib/active_support/deprecation/reporting.rb +61 -16
  154. data/lib/active_support/deprecation.rb +17 -9
  155. data/lib/active_support/descendants_tracker.rb +61 -9
  156. data/lib/active_support/digest.rb +20 -0
  157. data/lib/active_support/duration/iso8601_parser.rb +67 -66
  158. data/lib/active_support/duration/iso8601_serializer.rb +25 -17
  159. data/lib/active_support/duration.rb +349 -46
  160. data/lib/active_support/encrypted_configuration.rb +45 -0
  161. data/lib/active_support/encrypted_file.rb +117 -0
  162. data/lib/active_support/environment_inquirer.rb +20 -0
  163. data/lib/active_support/evented_file_update_checker.rb +88 -112
  164. data/lib/active_support/execution_wrapper.rb +25 -13
  165. data/lib/active_support/executor.rb +3 -1
  166. data/lib/active_support/file_update_checker.rb +56 -51
  167. data/lib/active_support/fork_tracker.rb +62 -0
  168. data/lib/active_support/gem_version.rb +4 -2
  169. data/lib/active_support/gzip.rb +7 -5
  170. data/lib/active_support/hash_with_indifferent_access.rb +153 -49
  171. data/lib/active_support/i18n.rb +9 -6
  172. data/lib/active_support/i18n_railtie.rb +30 -20
  173. data/lib/active_support/inflections.rb +13 -11
  174. data/lib/active_support/inflector/inflections.rb +28 -15
  175. data/lib/active_support/inflector/methods.rb +120 -109
  176. data/lib/active_support/inflector/transliterate.rb +60 -25
  177. data/lib/active_support/inflector.rb +7 -5
  178. data/lib/active_support/json/decoding.rb +30 -29
  179. data/lib/active_support/json/encoding.rb +22 -11
  180. data/lib/active_support/json.rb +4 -2
  181. data/lib/active_support/key_generator.rb +6 -36
  182. data/lib/active_support/lazy_load_hooks.rb +53 -20
  183. data/lib/active_support/locale/en.rb +33 -0
  184. data/lib/active_support/locale/en.yml +7 -3
  185. data/lib/active_support/log_subscriber/test_helper.rb +11 -9
  186. data/lib/active_support/log_subscriber.rb +51 -18
  187. data/lib/active_support/logger.rb +9 -22
  188. data/lib/active_support/logger_silence.rb +14 -21
  189. data/lib/active_support/logger_thread_safe_level.rb +55 -8
  190. data/lib/active_support/message_encryptor.rb +170 -53
  191. data/lib/active_support/message_verifier.rb +91 -20
  192. data/lib/active_support/messages/metadata.rb +80 -0
  193. data/lib/active_support/messages/rotation_configuration.rb +23 -0
  194. data/lib/active_support/messages/rotator.rb +57 -0
  195. data/lib/active_support/multibyte/chars.rb +24 -78
  196. data/lib/active_support/multibyte/unicode.rb +21 -352
  197. data/lib/active_support/multibyte.rb +4 -2
  198. data/lib/active_support/notifications/fanout.rb +121 -19
  199. data/lib/active_support/notifications/instrumenter.rb +78 -14
  200. data/lib/active_support/notifications.rb +80 -12
  201. data/lib/active_support/number_helper/number_converter.rb +17 -16
  202. data/lib/active_support/number_helper/number_to_currency_converter.rb +6 -9
  203. data/lib/active_support/number_helper/number_to_delimited_converter.rb +5 -3
  204. data/lib/active_support/number_helper/number_to_human_converter.rb +13 -12
  205. data/lib/active_support/number_helper/number_to_human_size_converter.rb +11 -13
  206. data/lib/active_support/number_helper/number_to_percentage_converter.rb +5 -1
  207. data/lib/active_support/number_helper/number_to_phone_converter.rb +5 -4
  208. data/lib/active_support/number_helper/number_to_rounded_converter.rb +18 -55
  209. data/lib/active_support/number_helper/rounding_helper.rb +50 -0
  210. data/lib/active_support/number_helper.rb +45 -16
  211. data/lib/active_support/option_merger.rb +25 -4
  212. data/lib/active_support/ordered_hash.rb +6 -4
  213. data/lib/active_support/ordered_options.rb +23 -9
  214. data/lib/active_support/parameter_filter.rb +133 -0
  215. data/lib/active_support/per_thread_registry.rb +7 -5
  216. data/lib/active_support/proxy_object.rb +2 -0
  217. data/lib/active_support/rails.rb +8 -9
  218. data/lib/active_support/railtie.rb +62 -11
  219. data/lib/active_support/reloader.rb +12 -11
  220. data/lib/active_support/rescuable.rb +20 -11
  221. data/lib/active_support/secure_compare_rotator.rb +51 -0
  222. data/lib/active_support/security_utils.rb +26 -15
  223. data/lib/active_support/string_inquirer.rb +12 -3
  224. data/lib/active_support/subscriber.rb +77 -23
  225. data/lib/active_support/tagged_logging.rb +52 -17
  226. data/lib/active_support/test_case.rb +106 -29
  227. data/lib/active_support/testing/assertions.rb +144 -8
  228. data/lib/active_support/testing/autorun.rb +5 -10
  229. data/lib/active_support/testing/constant_lookup.rb +2 -1
  230. data/lib/active_support/testing/declarative.rb +3 -1
  231. data/lib/active_support/testing/deprecation.rb +4 -2
  232. data/lib/active_support/testing/file_fixtures.rb +4 -0
  233. data/lib/active_support/testing/isolation.rb +19 -24
  234. data/lib/active_support/testing/method_call_assertions.rb +31 -2
  235. data/lib/active_support/testing/parallelization/server.rb +78 -0
  236. data/lib/active_support/testing/parallelization/worker.rb +100 -0
  237. data/lib/active_support/testing/parallelization.rb +51 -0
  238. data/lib/active_support/testing/setup_and_teardown.rb +13 -8
  239. data/lib/active_support/testing/stream.rb +30 -29
  240. data/lib/active_support/testing/tagged_logging.rb +3 -1
  241. data/lib/active_support/testing/time_helpers.rb +125 -24
  242. data/lib/active_support/time.rb +14 -12
  243. data/lib/active_support/time_with_zone.rb +142 -55
  244. data/lib/active_support/values/time_zone.rb +160 -53
  245. data/lib/active_support/version.rb +3 -1
  246. data/lib/active_support/xml_mini/jdom.rb +115 -114
  247. data/lib/active_support/xml_mini/libxml.rb +15 -14
  248. data/lib/active_support/xml_mini/libxmlsax.rb +16 -18
  249. data/lib/active_support/xml_mini/nokogiri.rb +13 -13
  250. data/lib/active_support/xml_mini/nokogirisax.rb +15 -16
  251. data/lib/active_support/xml_mini/rexml.rb +18 -9
  252. data/lib/active_support/xml_mini.rb +44 -42
  253. data/lib/active_support.rb +19 -10
  254. metadata +79 -37
  255. data/lib/active_support/concurrency/latch.rb +0 -19
  256. data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -7
  257. data/lib/active_support/core_ext/hash/compact.rb +0 -20
  258. data/lib/active_support/core_ext/hash/transform_values.rb +0 -29
  259. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -11
  260. data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
  261. data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
  262. data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
  263. data/lib/active_support/core_ext/module/reachable.rb +0 -8
  264. data/lib/active_support/core_ext/numeric/inquiry.rb +0 -26
  265. data/lib/active_support/core_ext/range/include_range.rb +0 -23
  266. data/lib/active_support/core_ext/struct.rb +0 -3
  267. data/lib/active_support/core_ext/time/marshal.rb +0 -3
  268. data/lib/active_support/values/unicode_tables.dat +0 -0
data/CHANGELOG.md CHANGED
@@ -1,798 +1,551 @@
1
- ## Rails 5.0.0 (June 30, 2016) ##
1
+ ## Rails 6.1.0 (December 09, 2020) ##
2
2
 
3
- * Support parsing JSON time in ISO8601 local time strings in
4
- `ActiveSupport::JSON.decode` when `parse_json_times` is enabled.
5
- Strings in the format of `YYYY-MM-DD hh:mm:ss` (without a `Z` at
6
- the end) will be parsed in the local timezone (`Time.zone`). In
7
- addition, date strings (`YYYY-MM-DD`) are now parsed into `Date`
8
- objects.
3
+ * Ensure `MemoryStore` disables compression by default. Reverts behavior of
4
+ `MemoryStore` to its prior rails `5.1` behavior.
9
5
 
10
- *Grzegorz Witek*
6
+ *Max Gurewitz*
11
7
 
12
- * `Date.to_s` doesn't produce too many spaces. For example, `to_s(:short)`
13
- will now produce `01 Feb` instead of ` 1 Feb`.
8
+ * Calling `iso8601` on negative durations retains the negative sign on individual
9
+ digits instead of prepending it.
14
10
 
15
- Fixes #25251.
11
+ This change is required so we can interoperate with PostgreSQL, which prefers
12
+ negative signs for each component.
16
13
 
17
- *Sean Griffin*
14
+ Compatibility with other iso8601 parsers which support leading negatives as well
15
+ as negatives per component is still retained.
18
16
 
19
- * Rescuable: If a handler doesn't match the exception, check for handlers
20
- matching the exception's cause.
21
-
22
- *Jeremy Daer*
23
-
24
- * `ActiveSupport::Duration` supports weeks and hours.
25
-
26
- [1.hour.inspect, 1.hour.value, 1.hour.parts]
27
- # => ["3600 seconds", 3600, [[:seconds, 3600]]] # Before
28
- # => ["1 hour", 3600, [[:hours, 1]]] # After
17
+ Before:
29
18
 
30
- [1.week.inspect, 1.week.value, 1.week.parts]
31
- # => ["7 days", 604800, [[:days, 7]]] # Before
32
- # => ["1 week", 604800, [[:weeks, 1]]] # After
19
+ (-1.year - 1.day).iso8601
20
+ # => "-P1Y1D"
33
21
 
34
- This brings us into closer conformance with ISO8601 and relieves some
35
- astonishment about getting `1.hour.inspect # => 3600 seconds`.
22
+ After:
36
23
 
37
- Compatibility: The duration's `value` remains the same, so apps using
38
- durations are oblivious to the new time periods. Apps, libraries, and
39
- plugins that work with the internal `parts` hash will need to broaden
40
- their time period handling to cover hours & weeks.
24
+ (-1.year - 1.day).iso8601
25
+ # => "P-1Y-1D"
41
26
 
42
- *Andrey Novikov*
27
+ *Vipul A M*
43
28
 
44
- * Time zones: Ensure that the UTC offset reflects DST changes that occurred
45
- since the app started. Removes UTC offset caching, reducing performance,
46
- but this is still relatively quick and isn't in any hot paths.
29
+ * Remove deprecated `ActiveSupport::Notifications::Instrumenter#end=`.
47
30
 
48
- *Alexey Shein*
31
+ *Rafael Mendonça França*
49
32
 
50
- * Make `getlocal` and `getutc` always return instances of `Time` for
51
- `ActiveSupport::TimeWithZone` and `DateTime`. This eliminates a possible
52
- stack level too deep error in `to_time` where `ActiveSupport::TimeWithZone`
53
- was wrapping a `DateTime` instance. As a consequence of this the internal
54
- time value in `ActiveSupport::TimeWithZone` is now always an instance of
55
- `Time` in the UTC timezone, whether that's as the UTC time directly or
56
- a representation of the local time in the timezone. There should be no
57
- consequences of this internal change and if there are it's a bug due to
58
- leaky abstractions.
33
+ * Deprecate `ActiveSupport::Multibyte::Unicode.default_normalization_form`.
59
34
 
60
- *Andrew White*
35
+ *Rafael Mendonça França*
61
36
 
62
- * Add `DateTime#subsec` to return the fraction of a second as a `Rational`.
37
+ * Remove deprecated `ActiveSupport::Multibyte::Unicode.pack_graphemes`,
38
+ `ActiveSupport::Multibyte::Unicode.unpack_graphemes`,
39
+ `ActiveSupport::Multibyte::Unicode.normalize`,
40
+ `ActiveSupport::Multibyte::Unicode.downcase`,
41
+ `ActiveSupport::Multibyte::Unicode.upcase` and `ActiveSupport::Multibyte::Unicode.swapcase`.
63
42
 
64
- *Andrew White*
43
+ *Rafael Mendonça França*
65
44
 
66
- * Add additional aliases for `DateTime#utc` to mirror the ones on
67
- `ActiveSupport::TimeWithZone` and `Time`.
45
+ * Remove deprecated `ActiveSupport::Multibyte::Chars#consumes?` and `ActiveSupport::Multibyte::Chars#normalize`.
68
46
 
69
- *Andrew White*
47
+ *Rafael Mendonça França*
70
48
 
71
- * Add `DateTime#localtime` to return an instance of `Time` in the system's
72
- local timezone. Also aliased to `getlocal`.
49
+ * Remove deprecated file `active_support/core_ext/range/include_range`.
73
50
 
74
- *Andrew White*, *Yuichiro Kaneko*
51
+ *Rafael Mendonça França*
75
52
 
76
- * Add `Time#sec_fraction` to return the fraction of a second as a `Rational`.
53
+ * Remove deprecated file `active_support/core_ext/hash/transform_values`.
77
54
 
78
- *Andrew White*
55
+ *Rafael Mendonça França*
79
56
 
80
- * Add `ActiveSupport.to_time_preserves_timezone` config option to control
81
- how `to_time` handles timezones. In Ruby 2.4+ the behavior will change
82
- from converting to the local system timezone, to preserving the timezone
83
- of the receiver. This config option defaults to false so that apps made
84
- with earlier versions of Rails are not affected when upgrading, e.g:
57
+ * Remove deprecated file `active_support/core_ext/hash/compact`.
85
58
 
86
- >> ENV['TZ'] = 'US/Eastern'
59
+ *Rafael Mendonça França*
87
60
 
88
- >> "2016-04-23T10:23:12.000Z".to_time
89
- => "2016-04-23T06:23:12.000-04:00"
61
+ * Remove deprecated file `active_support/core_ext/array/prepend_and_append`.
90
62
 
91
- >> ActiveSupport.to_time_preserves_timezone = true
63
+ *Rafael Mendonça França*
92
64
 
93
- >> "2016-04-23T10:23:12.000Z".to_time
94
- => "2016-04-23T10:23:12.000Z"
65
+ * Remove deprecated file `active_support/core_ext/numeric/inquiry`.
95
66
 
96
- Fixes #24617.
67
+ *Rafael Mendonça França*
97
68
 
98
- *Andrew White*
69
+ * Remove deprecated file `active_support/core_ext/module/reachable`.
99
70
 
100
- * `ActiveSupport::TimeZone.country_zones(country_code)` looks up the
101
- country's time zones by its two-letter ISO3166 country code, e.g.
71
+ *Rafael Mendonça França*
102
72
 
103
- >> ActiveSupport::TimeZone.country_zones(:jp).map(&:to_s)
104
- => ["(GMT+09:00) Osaka"]
73
+ * Remove deprecated `Module#parent_name`, `Module#parent` and `Module#parents`.
105
74
 
106
- >> ActiveSupport::TimeZone.country_zones(:uy).map(&:to_s)
107
- => ["(GMT-03:00) Montevideo"]
75
+ *Rafael Mendonça França*
108
76
 
109
- *Andrey Novikov*
77
+ * Remove deprecated `ActiveSupport::LoggerThreadSafeLevel#after_initialize`.
110
78
 
111
- * `Array#sum` compat with Ruby 2.4's native method.
79
+ *Rafael Mendonça França*
112
80
 
113
- Ruby 2.4 introduces `Array#sum`, but it only supports numeric elements,
114
- breaking our `Enumerable#sum` which supports arbitrary `Object#+`.
115
- To fix, override `Array#sum` with our compatible implementation.
81
+ * Remove deprecated `LoggerSilence` constant.
116
82
 
117
- Native Ruby 2.4:
83
+ *Rafael Mendonça França*
118
84
 
119
- %w[ a b ].sum
120
- # => TypeError: String can't be coerced into Fixnum
85
+ * Remove deprecated fallback to `I18n.default_local` when `config.i18n.fallbacks` is empty.
121
86
 
122
- With `Enumerable#sum` shim:
87
+ *Rafael Mendonça França*
123
88
 
124
- %w[ a b ].sum
125
- # => 'ab'
89
+ * Remove entries from local cache on `RedisCacheStore#delete_matched`
126
90
 
127
- We tried shimming the fast path and falling back to the compatible path
128
- if it fails, but that ends up slower even in simple cases due to the cost
129
- of exception handling. Our only choice is to override the native `Array#sum`
130
- with our `Enumerable#sum`.
91
+ Fixes #38627
131
92
 
132
- *Jeremy Daer*
93
+ *ojab*
133
94
 
134
- * `ActiveSupport::Duration` supports ISO8601 formatting and parsing.
95
+ * Speed up `ActiveSupport::SecurityUtils.fixed_length_secure_compare` by using
96
+ `OpenSSL.fixed_length_secure_compare`, if available.
135
97
 
136
- ActiveSupport::Duration.parse('P3Y6M4DT12H30M5S')
137
- # => 3 years, 6 months, 4 days, 12 hours, 30 minutes, and 5 seconds
98
+ *Nate Matykiewicz*
138
99
 
139
- (3.years + 3.days).iso8601
140
- # => "P3Y3D"
100
+ * `ActiveSupport::Cache::MemCacheStore` now checks `ENV["MEMCACHE_SERVERS"]` before falling back to `"localhost:11211"` if configured without any addresses.
141
101
 
142
- Inspired by Arnau Siches' [ISO8601 gem](https://github.com/arnau/ISO8601/)
143
- and rewritten by Andrey Novikov with suggestions from Andrew White. Test
144
- data from the ISO8601 gem redistributed under MIT license.
102
+ ```ruby
103
+ config.cache_store = :mem_cache_store
145
104
 
146
- (Will be used to support the PostgreSQL interval data type.)
105
+ # is now equivalent to
147
106
 
148
- *Andrey Novikov*, *Arnau Siches*, *Andrew White*
107
+ config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
149
108
 
150
- * `Cache#fetch(key, force: true)` forces a cache miss, so it must be called
151
- with a block to provide a new value to cache. Fetching with `force: true`
152
- but without a block now raises ArgumentError.
109
+ # instead of
153
110
 
154
- cache.fetch('key', force: true) # => ArgumentError
111
+ config.cache_store = :mem_cache_store, "localhost:11211" # ignores ENV["MEMCACHE_SERVERS"]
112
+ ```
155
113
 
156
- *Santosh Wadghule*
114
+ *Sam Bostock*
157
115
 
158
- * Fix behavior of JSON encoding for `Exception`.
116
+ * `ActiveSupport::Subscriber#attach_to` now accepts an `inherit_all:` argument. When set to true,
117
+ it allows a subscriber to receive events for methods defined in the subscriber's ancestor class(es).
159
118
 
160
- *namusyaka*
119
+ ```ruby
120
+ class ActionControllerSubscriber < ActiveSupport::Subscriber
121
+ attach_to :action_controller
161
122
 
162
- * Make `number_to_phone` format number with regexp pattern.
123
+ def start_processing(event)
124
+ info "Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}"
125
+ end
163
126
 
164
- number_to_phone(18812345678, pattern: /(\d{3})(\d{4})(\d{4})/)
165
- # => 188-1234-5678
127
+ def redirect_to(event)
128
+ info { "Redirected to #{event.payload[:location]}" }
129
+ end
130
+ end
166
131
 
167
- *Pan Gaoyong*
132
+ # We detach ActionControllerSubscriber from the :action_controller namespace so that our CustomActionControllerSubscriber
133
+ # can provide its own instrumentation for certain events in the namespace
134
+ ActionControllerSubscriber.detach_from(:action_controller)
168
135
 
169
- * Match `String#to_time`'s behaviour to that of ruby's implementation for edge cases.
136
+ class CustomActionControllerSubscriber < ActionControllerSubscriber
137
+ attach_to :action_controller, inherit_all: true
170
138
 
171
- `nil` is now returned instead of the current date if the string provided does
172
- contain time information, but none that is used to build the `Time` object.
139
+ def start_processing(event)
140
+ info "A custom response to start_processing events"
141
+ end
173
142
 
174
- Fixes #22958.
143
+ # => CustomActionControllerSubscriber will process events for "start_processing.action_controller" notifications
144
+ # using its own #start_processing implementation, while retaining ActionControllerSubscriber's instrumentation
145
+ # for "redirect_to.action_controller" notifications
146
+ end
147
+ ```
175
148
 
176
- *Siim Liiser*
149
+ *Adrianna Chang*
177
150
 
178
- * Rely on the native DateTime#<=> implementation to handle non-datetime like
179
- objects instead of returning `nil` ourselves. This restores the ability
180
- of `DateTime` instances to be compared with a `Numeric` that represents an
181
- astronomical julian day number.
151
+ * Allow the digest class used to generate non-sensitive digests to be configured with `config.active_support.hash_digest_class`.
182
152
 
183
- Fixes #24228.
153
+ `config.active_support.use_sha1_digests` is deprecated in favour of `config.active_support.hash_digest_class = ::Digest::SHA1`.
184
154
 
185
- *Andrew White*
155
+ *Dirkjan Bussink*
186
156
 
187
- * Add `String#upcase_first` method.
157
+ * Fix bug to make memcached write_entry expire correctly with unless_exist
188
158
 
189
- *Glauco Custódio*, *bogdanvlviv*
159
+ *Jye Lee*
190
160
 
191
- * Prevent `Marshal.load` from looping infinitely when trying to autoload a constant
192
- which resolves to a different name.
161
+ * Add `ActiveSupport::Duration` conversion methods
193
162
 
194
- *Olek Janiszewski*
163
+ `in_seconds`, `in_minutes`, `in_hours`, `in_days`, `in_weeks`, `in_months`, and `in_years` return the respective duration covered.
195
164
 
196
- * Deprecate `Module.local_constants`. Please use `Module.constants(false)` instead.
165
+ *Jason York*
197
166
 
198
- *Yuichiro Kaneko*
167
+ * Fixed issue in `ActiveSupport::Cache::RedisCacheStore` not passing options
168
+ to `read_multi` causing `fetch_multi` to not work properly
199
169
 
200
- * Publish `ActiveSupport::Executor` and `ActiveSupport::Reloader` APIs to allow
201
- components and libraries to manage, and participate in, the execution of
202
- application code, and the application reloading process.
170
+ *Rajesh Sharma*
203
171
 
204
- *Matthew Draper*
172
+ * Fixed issue in `ActiveSupport::Cache::MemCacheStore` which caused duplicate compression,
173
+ and caused the provided `compression_threshold` to not be respected.
205
174
 
206
- * Deprecate arguments on `assert_nothing_raised`.
175
+ *Max Gurewitz*
207
176
 
208
- `assert_nothing_raised` does not assert the arguments that have been passed
209
- in (usually a specific exception class) since the method only yields the
210
- block. So as not to confuse the users that the arguments have meaning, they
211
- are being deprecated.
177
+ * Prevent `RedisCacheStore` and `MemCacheStore` from performing compression
178
+ when reading entries written with `raw: true`.
212
179
 
213
- *Tara Scherner de la Fuente*
180
+ *Max Gurewitz*
214
181
 
215
- * Make `benchmark('something', silence: true)` actually work.
182
+ * `URI.parser` is deprecated and will be removed in Rails 6.2. Use
183
+ `URI::DEFAULT_PARSER` instead.
216
184
 
217
- *DHH*
185
+ *Jean Boussier*
218
186
 
219
- * Add `#on_weekday?` method to `Date`, `Time`, and `DateTime`.
187
+ * `require_dependency` has been documented to be _obsolete_ in `:zeitwerk`
188
+ mode. The method is not deprecated as such (yet), but applications are
189
+ encouraged to not use it.
220
190
 
221
- `#on_weekday?` returns `true` if the receiving date/time does not fall on a Saturday
222
- or Sunday.
191
+ In `:zeitwerk` mode, semantics match Ruby's and you do not need to be
192
+ defensive with load order. Just refer to classes and modules normally. If
193
+ the constant name is dynamic, camelize if needed, and constantize.
223
194
 
224
- *Vipul A M*
195
+ *Xavier Noria*
225
196
 
226
- * Add `Array#second_to_last` and `Array#third_to_last` methods.
197
+ * Add 3rd person aliases of `Symbol#start_with?` and `Symbol#end_with?`.
227
198
 
228
- *Brian Christian*
199
+ ```ruby
200
+ :foo.starts_with?("f") # => true
201
+ :foo.ends_with?("o") # => true
202
+ ```
229
203
 
230
- * Fix regression in `Hash#dig` for HashWithIndifferentAccess.
204
+ *Ryuta Kamizono*
231
205
 
232
- *Jon Moss*
206
+ * Add override of unary plus for `ActiveSupport::Duration`.
233
207
 
234
- * Change `number_to_currency` behavior for checking negativity.
208
+ `+ 1.second` is now identical to `+1.second` to prevent errors
209
+ where a seemingly innocent change of formatting leads to a change in the code behavior.
235
210
 
236
- Used `to_f.negative` instead of using `to_f.phase` for checking negativity
237
- of a number in number_to_currency helper.
238
- This change works same for all cases except when number is "-0.0".
211
+ Before:
212
+ ```ruby
213
+ +1.second.class
214
+ # => ActiveSupport::Duration
215
+ (+ 1.second).class
216
+ # => Integer
217
+ ```
239
218
 
240
- -0.0.to_f.negative? => false
241
- -0.0.to_f.phase? => 3.14
219
+ After:
220
+ ```ruby
221
+ +1.second.class
222
+ # => ActiveSupport::Duration
223
+ (+ 1.second).class
224
+ # => ActiveSupport::Duration
225
+ ```
242
226
 
243
- This change reverts changes from https://github.com/rails/rails/pull/6512.
244
- But it should be acceptable as we could not find any currency which
245
- supports negative zeros.
227
+ Fixes #39079.
246
228
 
247
- *Prathamesh Sonpatki*, *Rafael Mendonça França*
229
+ *Roman Kushnir*
248
230
 
249
- * Match `HashWithIndifferentAccess#default`'s behaviour with `Hash#default`.
231
+ * Add subsec to `ActiveSupport::TimeWithZone#inspect`.
250
232
 
251
- *David Cornu*
233
+ Before:
252
234
 
253
- * Adds `:exception_object` key to `ActiveSupport::Notifications::Instrumenter`
254
- payload when an exception is raised.
235
+ Time.at(1498099140).in_time_zone.inspect
236
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
237
+ Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
238
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
239
+ Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
240
+ # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
255
241
 
256
- Adds new key/value pair to payload when an exception is raised:
257
- e.g. `:exception_object => #<RuntimeError: FAIL>`.
242
+ After:
258
243
 
259
- *Ryan T. Hosford*
244
+ Time.at(1498099140).in_time_zone.inspect
245
+ # => "Thu, 22 Jun 2017 02:39:00.000000000 UTC +00:00"
246
+ Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
247
+ # => "Thu, 22 Jun 2017 02:39:00.123456780 UTC +00:00"
248
+ Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
249
+ # => "Thu, 22 Jun 2017 02:39:00.333333333 UTC +00:00"
260
250
 
261
- * Support extended grapheme clusters and UAX 29.
251
+ *akinomaeni*
262
252
 
263
- *Adam Roben*
253
+ * Calling `ActiveSupport::TaggedLogging#tagged` without a block now returns a tagged logger.
264
254
 
265
- * Add petabyte and exabyte numeric conversion.
255
+ ```ruby
256
+ logger.tagged("BCX").info("Funky time!") # => [BCX] Funky time!
257
+ ```
266
258
 
267
- *Akshay Vishnoi*
259
+ *Eugene Kenny*
268
260
 
269
- * Add thread_m/cattr_accessor/reader/writer suite of methods for declaring class and module variables that live per-thread.
270
- This makes it easy to declare per-thread globals that are encapsulated. Note: This is a sharp edge. A wild proliferation
271
- of globals is A Bad Thing. But like other sharp tools, when it's right, it's right.
261
+ * Align `Range#cover?` extension behavior with Ruby behavior for backwards ranges.
272
262
 
273
- Here's an example of a simple event tracking system where the object being tracked needs not pass a creator that it
274
- doesn't need itself along:
263
+ `(1..10).cover?(5..3)` now returns `false`, as it does in plain Ruby.
275
264
 
276
- module Current
277
- thread_mattr_accessor :account
278
- thread_mattr_accessor :user
265
+ Also update `#include?` and `#===` behavior to match.
279
266
 
280
- def self.reset() self.account = self.user = nil end
281
- end
267
+ *Michael Groeneman*
282
268
 
283
- class ApplicationController < ActionController::Base
284
- before_action :set_current
285
- after_action { Current.reset }
269
+ * Update to TZInfo v2.0.0.
286
270
 
287
- private
288
- def set_current
289
- Current.account = Account.find(params[:account_id])
290
- Current.user = Current.account.users.find(params[:user_id])
291
- end
292
- end
271
+ This changes the output of `ActiveSupport::TimeZone.utc_to_local`, but
272
+ can be controlled with the
273
+ `ActiveSupport.utc_to_local_returns_utc_offset_times` config.
293
274
 
294
- class MessagesController < ApplicationController
295
- def create
296
- @message = Message.create!(message_params)
297
- end
298
- end
275
+ New Rails 6.1 apps have it enabled by default, existing apps can upgrade
276
+ via the config in config/initializers/new_framework_defaults_6_1.rb
299
277
 
300
- class Message < ApplicationRecord
301
- has_many :events
302
- after_create :track_created
278
+ See the `utc_to_local_returns_utc_offset_times` documentation for details.
303
279
 
304
- private
305
- def track_created
306
- events.create! origin: self, action: :create
307
- end
308
- end
280
+ *Phil Ross*, *Jared Beck*
309
281
 
310
- class Event < ApplicationRecord
311
- belongs_to :creator, class_name: 'User'
312
- before_validation { self.creator ||= Current.user }
313
- end
282
+ * Add Date and Time `#yesterday?` and `#tomorrow?` alongside `#today?`.
314
283
 
315
- *DHH*
284
+ Aliased to `#prev_day?` and `#next_day?` to match the existing `#prev/next_day` methods.
316
285
 
286
+ *Jatin Dhankhar*
317
287
 
318
- * Deprecated `Module#qualified_const_` in favour of the builtin Module#const_
319
- methods.
288
+ * Add `Enumerable#pick` to complement `ActiveRecord::Relation#pick`.
320
289
 
321
- *Genadi Samokovarov*
290
+ *Eugene Kenny*
322
291
 
323
- * Deprecate passing string to define callback.
292
+ * [Breaking change] `ActiveSupport::Callbacks#halted_callback_hook` now receive a 2nd argument:
324
293
 
325
- *Yuichiro Kaneko*
294
+ `ActiveSupport::Callbacks#halted_callback_hook` now receive the name of the callback
295
+ being halted as second argument.
296
+ This change will allow you to differentiate which callbacks halted the chain
297
+ and act accordingly.
326
298
 
327
- * `ActiveSupport::Cache::Store#namespaced_key`,
328
- `ActiveSupport::Cache::MemCachedStore#escape_key`, and
329
- `ActiveSupport::Cache::FileStore#key_file_path`
330
- are deprecated and replaced with `normalize_key` that now calls `super`.
299
+ ```ruby
300
+ class Book < ApplicationRecord
301
+ before_save { throw(:abort) }
302
+ before_create { throw(:abort) }
331
303
 
332
- `ActiveSupport::Cache::LocaleCache#set_cache_value` is deprecated and replaced with `write_cache_value`.
304
+ def halted_callback_hook(filter, callback_name)
305
+ Rails.logger.info("Book couldn't be #{callback_name}d")
306
+ end
333
307
 
334
- *Michael Grosser*
308
+ Book.create # => "Book couldn't be created"
309
+ book.save # => "Book couldn't be saved"
310
+ end
311
+ ```
335
312
 
336
- * Implements an evented file watcher to asynchronously detect changes in the
337
- application source code, routes, locales, etc.
313
+ *Edouard Chin*
338
314
 
339
- This watcher is disabled by default, applications my enable it in the configuration:
315
+ * Support `prepend` with `ActiveSupport::Concern`.
340
316
 
341
- # config/environments/development.rb
342
- config.file_watcher = ActiveSupport::EventedFileUpdateChecker
317
+ Allows a module with `extend ActiveSupport::Concern` to be prepended.
343
318
 
344
- This feature depends on the [listen](https://github.com/guard/listen) gem:
319
+ module Imposter
320
+ extend ActiveSupport::Concern
345
321
 
346
- group :development do
347
- gem 'listen', '~> 3.0.5'
322
+ # Same as `included`, except only run when prepended.
323
+ prepended do
324
+ end
348
325
  end
349
326
 
350
- *Puneet Agarwal* and *Xavier Noria*
327
+ class Person
328
+ prepend Imposter
329
+ end
351
330
 
352
- * Added `Time.days_in_year` to return the number of days in the given year, or the
353
- current year if no argument is provided.
331
+ Class methods are prepended to the base class, concerning is also
332
+ updated: `concerning :Imposter, prepend: true do`.
354
333
 
355
- *Jon Pascoe*
334
+ *Jason Karns*, *Elia Schito*
356
335
 
357
- * Updated `parameterize` to preserve the case of a string, optionally.
336
+ * Deprecate using `Range#include?` method to check the inclusion of a value
337
+ in a date time range. It is recommended to use `Range#cover?` method
338
+ instead of `Range#include?` to check the inclusion of a value
339
+ in a date time range.
358
340
 
359
- Example:
341
+ *Vishal Telangre*
360
342
 
361
- parameterize("Donald E. Knuth", separator: '_') # => "donald_e_knuth"
362
- parameterize("Donald E. Knuth", preserve_case: true) # => "Donald-E-Knuth"
343
+ * Support added for a `round_mode` parameter, in all number helpers. (See: `BigDecimal::mode`.)
363
344
 
364
- *Swaathi Kakarla*
345
+ ```ruby
346
+ number_to_currency(1234567890.50, precision: 0, round_mode: :half_down) # => "$1,234,567,890"
347
+ number_to_percentage(302.24398923423, precision: 5, round_mode: :down) # => "302.24398%"
348
+ number_to_rounded(389.32314, precision: 0, round_mode: :ceil) # => "390"
349
+ number_to_human_size(483989, precision: 2, round_mode: :up) # => "480 KB"
350
+ number_to_human(489939, precision: 2, round_mode: :floor) # => "480 Thousand"
365
351
 
366
- * `HashWithIndifferentAccess.new` respects the default value or proc on objects
367
- that respond to `#to_hash`. `.new_from_hash_copying_default` simply invokes `.new`.
368
- All calls to `.new_from_hash_copying_default` are replaced with `.new`.
352
+ 485000.to_s(:human, precision: 2, round_mode: :half_even) # => "480 Thousand"
353
+ ```
369
354
 
370
- *Gordon Chan*
355
+ *Tom Lord*
371
356
 
372
- * Change Integer#year to return a Fixnum instead of a Float to improve
373
- consistency.
374
-
375
- Integer#years returned a Float while the rest of the accompanying methods
376
- (days, weeks, months, etc.) return a Fixnum.
357
+ * `Array#to_sentence` no longer returns a frozen string.
377
358
 
378
359
  Before:
379
360
 
380
- 1.year # => 31557600.0
361
+ ['one', 'two'].to_sentence.frozen?
362
+ # => true
381
363
 
382
364
  After:
383
365
 
384
- 1.year # => 31557600
385
-
386
- *Konstantinos Rousis*
366
+ ['one', 'two'].to_sentence.frozen?
367
+ # => false
387
368
 
388
- * Handle invalid UTF-8 strings when HTML escaping.
369
+ *Nicolas Dular*
389
370
 
390
- Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8
391
- strings in `ERB::Util.unwrapped_html_escape` and `ERB::Util.html_escape_once`.
392
- Prevents user-entered input passed from a querystring into a form field from
393
- causing invalid byte sequence errors.
371
+ * 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.
372
+ This keeps the parser and serializer on the same page.
394
373
 
395
- *Grey Baker*
374
+ ```ruby
375
+ duration = ActiveSupport::Duration.build(1000000)
376
+ # 1 week, 4 days, 13 hours, 46 minutes, and 40.0 seconds
396
377
 
397
- * Update `ActiveSupport::Multibyte::Chars#slice!` to return `nil` if the
398
- arguments are out of bounds, to mirror the behavior of `String#slice!`
378
+ duration_iso = duration.iso8601
379
+ # P11DT13H46M40S
399
380
 
400
- *Gourav Tiwari*
381
+ ActiveSupport::Duration.parse(duration_iso)
382
+ # 11 days, 13 hours, 46 minutes, and 40 seconds
401
383
 
402
- * Fix `number_to_human` so that 999999999 rounds to "1 Billion" instead of
403
- "1000 Million".
384
+ duration = ActiveSupport::Duration.build(604800)
385
+ # 1 week
404
386
 
405
- *Max Jacobson*
387
+ duration_iso = duration.iso8601
388
+ # P1W
406
389
 
407
- * Fix `ActiveSupport::Deprecation#deprecate_methods` to report using the
408
- current deprecator instance, where applicable.
390
+ ActiveSupport::Duration.parse(duration_iso)
391
+ # 1 week
392
+ ```
409
393
 
410
- *Brandon Dunne*
394
+ *Abhishek Sarkar*
411
395
 
412
- * `Cache#fetch` instrumentation marks whether it was a `:hit`.
396
+ * Add block support to `ActiveSupport::Testing::TimeHelpers#travel_back`.
413
397
 
414
- *Robin Clowers*
398
+ *Tim Masliuchenko*
415
399
 
416
- * `assert_difference` and `assert_no_difference` now returns the result of the
417
- yielded block.
400
+ * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
401
+ `ActiveSupport.parse_json_times = true`.
418
402
 
419
- Example:
420
-
421
- post = assert_difference -> { Post.count }, 1 do
422
- Post.create
423
- end
403
+ *Christian Gregg*
424
404
 
425
- *Lucas Mazza*
405
+ * Support symbolic links for `content_path` in `ActiveSupport::EncryptedFile`.
426
406
 
427
- * Short-circuit `blank?` on date and time values since they are never blank.
407
+ *Takumi Shotoku*
428
408
 
429
- Fixes #21657.
409
+ * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
410
+ and endless range targets.
430
411
 
431
- *Andrew White*
412
+ *Allen Hsu*, *Andrew Hodgkinson*
432
413
 
433
- * Replaced deprecated `ThreadSafe::Cache` with its successor `Concurrent::Map` now that
434
- the thread_safe gem has been merged into concurrent-ruby.
414
+ * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
435
415
 
436
- *Jerry D'Antonio*
416
+ *Iain Beeston*
437
417
 
438
- * Updated Unicode version to 8.0.0
418
+ * Prevent `ActiveSupport::Duration.build(value)` from creating instances of
419
+ `ActiveSupport::Duration` unless `value` is of type `Numeric`.
439
420
 
440
- *Anshul Sharma*
421
+ Addresses the errant set of behaviours described in #37012 where
422
+ `ActiveSupport::Duration` comparisons would fail confusingly
423
+ or return unexpected results when comparing durations built from instances of `String`.
441
424
 
442
- * `number_to_currency` and `number_with_delimiter` now accept custom `delimiter_pattern` option
443
- to handle placement of delimiter, to support currency formats like INR
425
+ Before:
444
426
 
445
- Example:
427
+ small_duration_from_string = ActiveSupport::Duration.build('9')
428
+ large_duration_from_string = ActiveSupport::Duration.build('100000000000000')
429
+ small_duration_from_int = ActiveSupport::Duration.build(9)
446
430
 
447
- number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: '₹', format: "%u %n")
448
- # => '₹ 12,30,000.00'
431
+ large_duration_from_string > small_duration_from_string
432
+ # => false
449
433
 
450
- *Vipul A M*
434
+ small_duration_from_string == small_duration_from_int
435
+ # => false
451
436
 
452
- * Deprecate `:prefix` option of `number_to_human_size` with no replacement.
437
+ small_duration_from_int < large_duration_from_string
438
+ # => ArgumentError (comparison of ActiveSupport::Duration::Scalar with ActiveSupport::Duration failed)
453
439
 
454
- *Jean Boussier*
440
+ large_duration_from_string > small_duration_from_int
441
+ # => ArgumentError (comparison of String with ActiveSupport::Duration failed)
455
442
 
456
- * Fix `TimeWithZone#eql?` to properly handle `TimeWithZone` created from `DateTime`:
457
- twz = DateTime.now.in_time_zone
458
- twz.eql?(twz.dup) => true
443
+ After:
459
444
 
460
- Fixes #14178.
445
+ small_duration_from_string = ActiveSupport::Duration.build('9')
446
+ # => TypeError (can't build an ActiveSupport::Duration from a String)
461
447
 
462
- *Roque Pinel*
448
+ *Alexei Emam*
463
449
 
464
- * ActiveSupport::HashWithIndifferentAccess `select` and `reject` will now return
465
- enumerator if called without block.
450
+ * Add `ActiveSupport::Cache::Store#delete_multi` method to delete multiple keys from the cache store.
466
451
 
467
- Fixes #20095.
452
+ *Peter Zhu*
468
453
 
469
- *Bernard Potocki*
454
+ * Support multiple arguments in `HashWithIndifferentAccess` for `merge` and `update` methods, to
455
+ follow Ruby 2.6 addition.
470
456
 
471
- * Removed `ActiveSupport::Concurrency::Latch`, superseded by `Concurrent::CountDownLatch`
472
- from the concurrent-ruby gem.
457
+ *Wojciech Wnętrzak*
473
458
 
474
- *Jerry D'Antonio*
459
+ * Allow initializing `thread_mattr_*` attributes via `:default` option.
475
460
 
476
- * Fix not calling `#default` on `HashWithIndifferentAccess#to_hash` when only
477
- `default_proc` is set, which could raise.
461
+ class Scraper
462
+ thread_mattr_reader :client, default: Api::Client.new
463
+ end
478
464
 
479
- *Simon Eskildsen*
465
+ *Guilherme Mansur*
480
466
 
481
- * Fix setting `default_proc` on `HashWithIndifferentAccess#dup`.
467
+ * Add `compact_blank` for those times when you want to remove #blank? values from
468
+ an Enumerable (also `compact_blank!` on Hash, Array, ActionController::Parameters).
482
469
 
483
- *Simon Eskildsen*
470
+ *Dana Sherson*
484
471
 
485
- * Fix a range of values for parameters of the Time#change.
472
+ * Make ActiveSupport::Logger Fiber-safe.
486
473
 
487
- *Nikolay Kondratyev*
474
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
475
+ to make log level local to Ruby Fibers in addition to Threads.
488
476
 
489
- * Add `Enumerable#pluck` to get the same values from arrays as from ActiveRecord
490
- associations.
477
+ Example:
491
478
 
492
- Fixes #20339.
479
+ logger = ActiveSupport::Logger.new(STDOUT)
480
+ logger.level = 1
481
+ puts "Main is debug? #{logger.debug?}"
493
482
 
494
- *Kevin Deisz*
483
+ Fiber.new {
484
+ logger.local_level = 0
485
+ puts "Thread is debug? #{logger.debug?}"
486
+ }.resume
495
487
 
496
- * Add a bang version to `ActiveSupport::OrderedOptions` get methods which will raise
497
- an `KeyError` if the value is `.blank?`.
488
+ puts "Main is debug? #{logger.debug?}"
498
489
 
499
490
  Before:
500
491
 
501
- if (slack_url = Rails.application.secrets.slack_url).present?
502
- # Do something worthwhile
503
- else
504
- # Raise as important secret password is not specified
505
- end
492
+ Main is debug? false
493
+ Thread is debug? true
494
+ Main is debug? true
506
495
 
507
496
  After:
508
497
 
509
- slack_url = Rails.application.secrets.slack_url!
510
-
511
- *Aditya Sanghi*, *Gaurish Sharma*
512
-
513
- * Remove deprecated `Class#superclass_delegating_accessor`.
514
- Use `Class#class_attribute` instead.
515
-
516
- *Akshay Vishnoi*
517
-
518
- * Patch `Delegator` to work with `#try`.
519
-
520
- Fixes #5790.
521
-
522
- *Nate Smith*
523
-
524
- * Add `Integer#positive?` and `Integer#negative?` query methods
525
- in the vein of `Fixnum#zero?`.
526
-
527
- This makes it nicer to do things like `bunch_of_numbers.select(&:positive?)`.
528
-
529
- *DHH*
530
-
531
- * Encoding `ActiveSupport::TimeWithZone` to YAML now preserves the timezone information.
532
-
533
- Fixes #9183.
534
-
535
- *Andrew White*
536
-
537
- * Added `ActiveSupport::TimeZone#strptime` to allow parsing times as if
538
- from a given timezone.
539
-
540
- *Paul A Jungwirth*
541
-
542
- * `ActiveSupport::Callbacks#skip_callback` now raises an `ArgumentError` if
543
- an unrecognized callback is removed.
544
-
545
- *Iain Beeston*
546
-
547
- * Added `ActiveSupport::ArrayInquirer` and `Array#inquiry`.
548
-
549
- Wrapping an array in an `ArrayInquirer` gives a friendlier way to check its
550
- contents:
551
-
552
- variants = ActiveSupport::ArrayInquirer.new([:phone, :tablet])
553
-
554
- variants.phone? # => true
555
- variants.tablet? # => true
556
- variants.desktop? # => false
557
-
558
- variants.any?(:phone, :tablet) # => true
559
- variants.any?(:phone, :desktop) # => true
560
- variants.any?(:desktop, :watch) # => false
561
-
562
- `Array#inquiry` is a shortcut for wrapping the receiving array in an
563
- `ArrayInquirer`.
564
-
565
- *George Claghorn*
566
-
567
- * Deprecate `alias_method_chain` in favour of `Module#prepend` introduced in
568
- Ruby 2.0.
569
-
570
- *Kir Shatrov*
498
+ Main is debug? false
499
+ Thread is debug? true
500
+ Main is debug? false
571
501
 
572
- * Added `#without` on `Enumerable` and `Array` to return a copy of an
573
- enumerable without the specified elements.
502
+ Fixes #36752.
574
503
 
575
- *Todd Bealmear*
504
+ *Alexander Varnin*
576
505
 
577
- * Fixed a problem where `String#truncate_words` would get stuck with a complex
578
- string.
579
-
580
- *Henrik Nygren*
581
-
582
- * Fixed a roundtrip problem with `AS::SafeBuffer` where primitive-like strings
583
- will be dumped as primitives:
506
+ * Allow the `on_rotation` proc used when decrypting/verifying a message to be
507
+ passed at the constructor level.
584
508
 
585
509
  Before:
586
510
 
587
- YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
588
- YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
589
- YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
590
- YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
591
- YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
511
+ crypt = ActiveSupport::MessageEncryptor.new('long_secret')
512
+ crypt.decrypt_and_verify(encrypted_message, on_rotation: proc { ... })
513
+ crypt.decrypt_and_verify(another_encrypted_message, on_rotation: proc { ... })
592
514
 
593
515
  After:
594
516
 
595
- YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
596
- YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
597
- YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
598
- YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
599
- YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
600
-
601
- *Godfrey Chan*
602
-
603
- * Enable `number_to_percentage` to keep the number's precision by allowing
604
- `:precision` to be `nil`.
605
-
606
- *Jack Xu*
607
-
608
- * `config_accessor` became a private method, as with Ruby's `attr_accessor`.
609
-
610
- *Akira Matsuda*
611
-
612
- * `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as
613
- `Time.now` and `Date.today`.
614
-
615
- *Yuki Nishijima*
616
-
617
- * Add `file_fixture` to `ActiveSupport::TestCase`.
618
- It provides a simple mechanism to access sample files in your test cases.
619
-
620
- By default file fixtures are stored in `test/fixtures/files`. This can be
621
- configured per test-case using the `file_fixture_path` class attribute.
622
-
623
- *Yves Senn*
624
-
625
- * Return value of yielded block in `File.atomic_write`.
626
-
627
- *Ian Ker-Seymer*
628
-
629
- * Duplicate frozen array when assigning it to a `HashWithIndifferentAccess` so
630
- that it doesn't raise a `RuntimeError` when calling `map!` on it in `convert_value`.
631
-
632
- Fixes #18550.
633
-
634
- *Aditya Kapoor*
635
-
636
- * Add missing time zone definitions for Russian Federation and sync them
637
- with `zone.tab` file from tzdata version 2014j (latest).
638
-
639
- *Andrey Novikov*
640
-
641
- * Add `SecureRandom.base58` for generation of random base58 strings.
517
+ crypt = ActiveSupport::MessageEncryptor.new('long_secret', on_rotation: proc { ... })
518
+ crypt.decrypt_and_verify(encrypted_message)
519
+ crypt.decrypt_and_verify(another_encrypted_message)
642
520
 
643
- *Matthew Draper*, *Guillermo Iguaran*
521
+ *Edouard Chin*
644
522
 
645
- * Add `#prev_day` and `#next_day` counterparts to `#yesterday` and
646
- `#tomorrow` for `Date`, `Time`, and `DateTime`.
523
+ * `delegate_missing_to` would raise a `DelegationError` if the object
524
+ delegated to was `nil`. Now the `allow_nil` option has been added to enable
525
+ the user to specify they want `nil` returned in this case.
647
526
 
648
- *George Claghorn*
527
+ *Matthew Tanous*
649
528
 
650
- * Add `same_time` option to `#next_week` and `#prev_week` for `Date`, `Time`,
651
- and `DateTime`.
652
-
653
- *George Claghorn*
654
-
655
- * Add `#on_weekend?`, `#next_weekday`, `#prev_weekday` methods to `Date`,
656
- `Time`, and `DateTime`.
657
-
658
- `#on_weekend?` returns `true` if the receiving date/time falls on a Saturday
659
- or Sunday.
660
-
661
- `#next_weekday` returns a new date/time representing the next day that does
662
- not fall on a Saturday or Sunday.
663
-
664
- `#prev_weekday` returns a new date/time representing the previous day that
665
- does not fall on a Saturday or Sunday.
666
-
667
- *George Claghorn*
668
-
669
- * Added ability to `TaggedLogging` to allow loggers to be instantiated multiple times
670
- so that they don't share tags with each other.
671
-
672
- Rails.logger = Logger.new(STDOUT)
673
-
674
- # Before
675
- custom_logger = ActiveSupport::TaggedLogging.new(Rails.logger)
676
- custom_logger.push_tags "custom_tag"
677
- custom_logger.info "test" # => "[custom_tag] [custom_tag] test"
678
- Rails.logger.info "test" # => "[custom_tag] [custom_tag] test"
679
-
680
- # After
681
- custom_logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
682
- custom_logger.push_tags "custom_tag"
683
- custom_logger.info "test" # => "[custom_tag] test"
684
- Rails.logger.info "test" # => "test"
685
-
686
- *Alexander Staubo*
687
-
688
- * Change the default test order from `:sorted` to `:random`.
689
-
690
- *Rafael Mendonça França*
691
-
692
- * Remove deprecated `ActiveSupport::JSON::Encoding::CircularReferenceError`.
693
-
694
- *Rafael Mendonça França*
695
-
696
- * Remove deprecated methods `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string=`
697
- and `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string`.
698
-
699
- *Rafael Mendonça França*
529
+ * `truncate` would return the original string if it was too short to be truncated
530
+ and a frozen string if it were long enough to be truncated. Now truncate will
531
+ consistently return an unfrozen string regardless. This behavior is consistent
532
+ with `gsub` and `strip`.
700
533
 
701
- * Remove deprecated `ActiveSupport::SafeBuffer#prepend`.
702
-
703
- *Rafael Mendonça França*
704
-
705
- * Remove deprecated methods at `Kernel`.
706
-
707
- `silence_stderr`, `silence_stream`, `capture` and `quietly`.
708
-
709
- *Rafael Mendonça França*
710
-
711
- * Remove deprecated `active_support/core_ext/big_decimal/yaml_conversions`
712
- file.
713
-
714
- *Rafael Mendonça França*
715
-
716
- * Remove deprecated methods `ActiveSupport::Cache::Store.instrument` and
717
- `ActiveSupport::Cache::Store.instrument=`.
718
-
719
- *Rafael Mendonça França*
720
-
721
- * Change the way in which callback chains can be halted.
722
-
723
- The preferred method to halt a callback chain from now on is to explicitly
724
- `throw(:abort)`.
725
- In the past, callbacks could only be halted by explicitly providing a
726
- terminator and by having a callback match the conditions of the terminator.
727
-
728
- * Add `ActiveSupport.halt_callback_chains_on_return_false`
729
-
730
- Setting `ActiveSupport.halt_callback_chains_on_return_false`
731
- to `true` will let an app support the deprecated way of halting Active Record,
732
- and Active Model callback chains by returning `false`.
733
-
734
- Setting the value to `false` will tell the app to ignore any `false` value
735
- returned by those callbacks, and only halt the chain upon `throw(:abort)`.
736
-
737
- When the configuration option is missing, its value is `true`, so older apps
738
- ported to Rails 5.0 will not break (but display a deprecation warning).
739
- For new Rails 5.0 apps, its value is set to `false` in an initializer, so
740
- these apps will support the new behavior by default.
741
-
742
- *claudiob*, *Roque Pinel*
743
-
744
- * Changes arguments and default value of CallbackChain's `:terminator` option
745
-
746
- Chains of callbacks defined without an explicit `:terminator` option will
747
- now be halted as soon as a `before_` callback throws `:abort`.
748
-
749
- Chains of callbacks defined with a `:terminator` option will maintain their
750
- existing behavior of halting as soon as a `before_` callback matches the
751
- terminator's expectation.
752
-
753
- *claudiob*
754
-
755
- * Deprecate `MissingSourceFile` in favor of `LoadError`.
756
-
757
- `MissingSourceFile` was just an alias to `LoadError` and was not being
758
- raised inside the framework.
759
-
760
- *Rafael Mendonça França*
761
-
762
- * Remove `Object#itself` as it is implemented in Ruby 2.2.
763
-
764
- *Cristian Bica*
765
-
766
- * Add support for error dispatcher classes in `ActiveSupport::Rescuable`.
767
- Now it acts closer to Ruby's rescue.
768
-
769
- Example:
770
-
771
- class BaseController < ApplicationController
772
- module ErrorDispatcher
773
- def self.===(other)
774
- Exception === other && other.respond_to?(:status)
775
- end
776
- end
777
-
778
- rescue_from ErrorDispatcher do |error|
779
- render status: error.status, json: { error: error.to_s }
780
- end
781
- end
534
+ Before:
782
535
 
783
- *Genadi Samokovarov*
536
+ 'foobar'.truncate(5).frozen?
537
+ # => true
538
+ 'foobar'.truncate(6).frozen?
539
+ # => false
784
540
 
785
- * Add `#verified` and `#valid_message?` methods to `ActiveSupport::MessageVerifier`
541
+ After:
786
542
 
787
- Previously, the only way to decode a message with `ActiveSupport::MessageVerifier`
788
- was to use `#verify`, which would raise an exception on invalid messages. Now
789
- `#verified` can also be used, which returns `nil` on messages that cannot be
790
- decoded.
543
+ 'foobar'.truncate(5).frozen?
544
+ # => false
545
+ 'foobar'.truncate(6).frozen?
546
+ # => false
791
547
 
792
- Previously, there was no way to check if a message's format was valid without
793
- attempting to decode it. `#valid_message?` is a boolean convenience method that
794
- checks whether the message is valid without actually decoding it.
548
+ *Jordan Thomas*
795
549
 
796
- *Logan Leger*
797
550
 
798
- Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md) for previous changes.
551
+ Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activesupport/CHANGELOG.md) for previous changes.