activesupport 4.2.11.1 → 6.0.3.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 (263) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +399 -411
  3. data/MIT-LICENSE +2 -2
  4. data/README.rdoc +7 -7
  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 +48 -0
  8. data/lib/active_support/backtrace_cleaner.rb +34 -6
  9. data/lib/active_support/benchmarkable.rb +6 -4
  10. data/lib/active_support/builder.rb +3 -1
  11. data/lib/active_support/cache/file_store.rb +58 -53
  12. data/lib/active_support/cache/mem_cache_store.rb +95 -91
  13. data/lib/active_support/cache/memory_store.rb +39 -36
  14. data/lib/active_support/cache/null_store.rb +11 -7
  15. data/lib/active_support/cache/redis_cache_store.rb +493 -0
  16. data/lib/active_support/cache/strategy/local_cache.rb +75 -42
  17. data/lib/active_support/cache/strategy/local_cache_middleware.rb +10 -9
  18. data/lib/active_support/cache.rb +331 -217
  19. data/lib/active_support/callbacks.rb +650 -592
  20. data/lib/active_support/concern.rb +35 -6
  21. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +35 -0
  22. data/lib/active_support/concurrency/share_lock.rb +226 -0
  23. data/lib/active_support/configurable.rb +13 -14
  24. data/lib/active_support/core_ext/array/access.rb +41 -1
  25. data/lib/active_support/core_ext/array/conversions.rb +24 -20
  26. data/lib/active_support/core_ext/array/extract.rb +21 -0
  27. data/lib/active_support/core_ext/array/extract_options.rb +2 -0
  28. data/lib/active_support/core_ext/array/grouping.rb +11 -18
  29. data/lib/active_support/core_ext/array/inquiry.rb +19 -0
  30. data/lib/active_support/core_ext/array/prepend_and_append.rb +4 -6
  31. data/lib/active_support/core_ext/array/wrap.rb +7 -4
  32. data/lib/active_support/core_ext/array.rb +9 -6
  33. data/lib/active_support/core_ext/benchmark.rb +3 -1
  34. data/lib/active_support/core_ext/big_decimal/conversions.rb +10 -12
  35. data/lib/active_support/core_ext/big_decimal.rb +3 -1
  36. data/lib/active_support/core_ext/class/attribute.rb +45 -31
  37. data/lib/active_support/core_ext/class/attribute_accessors.rb +3 -1
  38. data/lib/active_support/core_ext/class/subclasses.rb +20 -6
  39. data/lib/active_support/core_ext/class.rb +4 -3
  40. data/lib/active_support/core_ext/date/acts_like.rb +3 -1
  41. data/lib/active_support/core_ext/date/blank.rb +14 -0
  42. data/lib/active_support/core_ext/date/calculations.rb +17 -14
  43. data/lib/active_support/core_ext/date/conversions.rb +25 -23
  44. data/lib/active_support/core_ext/date/zones.rb +4 -2
  45. data/lib/active_support/core_ext/date.rb +6 -4
  46. data/lib/active_support/core_ext/date_and_time/calculations.rb +154 -65
  47. data/lib/active_support/core_ext/date_and_time/compatibility.rb +4 -3
  48. data/lib/active_support/core_ext/date_and_time/zones.rb +12 -13
  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 +14 -0
  51. data/lib/active_support/core_ext/date_time/calculations.rb +37 -19
  52. data/lib/active_support/core_ext/date_time/compatibility.rb +8 -6
  53. data/lib/active_support/core_ext/date_time/conversions.rb +16 -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 +114 -22
  58. data/lib/active_support/core_ext/file/atomic.rb +38 -31
  59. data/lib/active_support/core_ext/file.rb +3 -1
  60. data/lib/active_support/core_ext/hash/compact.rb +4 -23
  61. data/lib/active_support/core_ext/hash/conversions.rb +62 -41
  62. data/lib/active_support/core_ext/hash/deep_merge.rb +9 -13
  63. data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
  64. data/lib/active_support/core_ext/hash/except.rb +12 -9
  65. data/lib/active_support/core_ext/hash/indifferent_access.rb +4 -3
  66. data/lib/active_support/core_ext/hash/keys.rb +19 -42
  67. data/lib/active_support/core_ext/hash/reverse_merge.rb +5 -2
  68. data/lib/active_support/core_ext/hash/slice.rb +5 -27
  69. data/lib/active_support/core_ext/hash/transform_values.rb +4 -22
  70. data/lib/active_support/core_ext/hash.rb +10 -9
  71. data/lib/active_support/core_ext/integer/inflections.rb +3 -1
  72. data/lib/active_support/core_ext/integer/multiple.rb +3 -1
  73. data/lib/active_support/core_ext/integer/time.rb +11 -18
  74. data/lib/active_support/core_ext/integer.rb +5 -3
  75. data/lib/active_support/core_ext/kernel/concern.rb +5 -1
  76. data/lib/active_support/core_ext/kernel/reporting.rb +4 -84
  77. data/lib/active_support/core_ext/kernel/singleton_class.rb +2 -0
  78. data/lib/active_support/core_ext/kernel.rb +5 -5
  79. data/lib/active_support/core_ext/load_error.rb +3 -22
  80. data/lib/active_support/core_ext/marshal.rb +8 -8
  81. data/lib/active_support/core_ext/module/aliasing.rb +6 -44
  82. data/lib/active_support/core_ext/module/anonymous.rb +12 -1
  83. data/lib/active_support/core_ext/module/attr_internal.rb +8 -9
  84. data/lib/active_support/core_ext/module/attribute_accessors.rb +46 -46
  85. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +144 -0
  86. data/lib/active_support/core_ext/module/concerning.rb +11 -12
  87. data/lib/active_support/core_ext/module/delegation.rb +133 -30
  88. data/lib/active_support/core_ext/module/deprecation.rb +4 -2
  89. data/lib/active_support/core_ext/module/introspection.rb +44 -19
  90. data/lib/active_support/core_ext/module/reachable.rb +5 -7
  91. data/lib/active_support/core_ext/module/redefine_method.rb +40 -0
  92. data/lib/active_support/core_ext/module/remove_method.rb +8 -3
  93. data/lib/active_support/core_ext/module.rb +13 -11
  94. data/lib/active_support/core_ext/name_error.rb +22 -2
  95. data/lib/active_support/core_ext/numeric/bytes.rb +22 -0
  96. data/lib/active_support/core_ext/numeric/conversions.rb +129 -136
  97. data/lib/active_support/core_ext/numeric/inquiry.rb +5 -0
  98. data/lib/active_support/core_ext/numeric/time.rb +35 -23
  99. data/lib/active_support/core_ext/numeric.rb +5 -3
  100. data/lib/active_support/core_ext/object/acts_like.rb +12 -1
  101. data/lib/active_support/core_ext/object/blank.rb +27 -3
  102. data/lib/active_support/core_ext/object/conversions.rb +6 -4
  103. data/lib/active_support/core_ext/object/deep_dup.rb +13 -4
  104. data/lib/active_support/core_ext/object/duplicable.rb +13 -93
  105. data/lib/active_support/core_ext/object/inclusion.rb +5 -3
  106. data/lib/active_support/core_ext/object/instance_variables.rb +3 -1
  107. data/lib/active_support/core_ext/object/json.rb +51 -20
  108. data/lib/active_support/core_ext/object/to_param.rb +3 -1
  109. data/lib/active_support/core_ext/object/to_query.rb +10 -5
  110. data/lib/active_support/core_ext/object/try.rb +81 -23
  111. data/lib/active_support/core_ext/object/with_options.rb +16 -3
  112. data/lib/active_support/core_ext/object.rb +14 -13
  113. data/lib/active_support/core_ext/range/compare_range.rb +76 -0
  114. data/lib/active_support/core_ext/range/conversions.rb +37 -15
  115. data/lib/active_support/core_ext/range/each.rb +18 -17
  116. data/lib/active_support/core_ext/range/include_range.rb +7 -21
  117. data/lib/active_support/core_ext/range/include_time_with_zone.rb +23 -0
  118. data/lib/active_support/core_ext/range/overlaps.rb +2 -0
  119. data/lib/active_support/core_ext/range.rb +7 -4
  120. data/lib/active_support/core_ext/regexp.rb +2 -0
  121. data/lib/active_support/core_ext/securerandom.rb +45 -0
  122. data/lib/active_support/core_ext/string/access.rb +16 -6
  123. data/lib/active_support/core_ext/string/behavior.rb +3 -1
  124. data/lib/active_support/core_ext/string/conversions.rb +7 -4
  125. data/lib/active_support/core_ext/string/exclude.rb +2 -0
  126. data/lib/active_support/core_ext/string/filters.rb +48 -6
  127. data/lib/active_support/core_ext/string/indent.rb +6 -4
  128. data/lib/active_support/core_ext/string/inflections.rb +66 -24
  129. data/lib/active_support/core_ext/string/inquiry.rb +3 -1
  130. data/lib/active_support/core_ext/string/multibyte.rb +16 -7
  131. data/lib/active_support/core_ext/string/output_safety.rb +93 -40
  132. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -0
  133. data/lib/active_support/core_ext/string/strip.rb +6 -5
  134. data/lib/active_support/core_ext/string/zones.rb +4 -2
  135. data/lib/active_support/core_ext/string.rb +15 -13
  136. data/lib/active_support/core_ext/time/acts_like.rb +3 -1
  137. data/lib/active_support/core_ext/time/calculations.rb +115 -52
  138. data/lib/active_support/core_ext/time/compatibility.rb +4 -2
  139. data/lib/active_support/core_ext/time/conversions.rb +20 -13
  140. data/lib/active_support/core_ext/time/zones.rb +41 -7
  141. data/lib/active_support/core_ext/time.rb +7 -6
  142. data/lib/active_support/core_ext/uri.rb +6 -7
  143. data/lib/active_support/core_ext.rb +3 -1
  144. data/lib/active_support/current_attributes.rb +203 -0
  145. data/lib/active_support/dependencies/autoload.rb +2 -0
  146. data/lib/active_support/dependencies/interlock.rb +57 -0
  147. data/lib/active_support/dependencies/zeitwerk_integration.rb +117 -0
  148. data/lib/active_support/dependencies.rb +208 -166
  149. data/lib/active_support/deprecation/behaviors.rb +44 -11
  150. data/lib/active_support/deprecation/constant_accessor.rb +52 -0
  151. data/lib/active_support/deprecation/instance_delegator.rb +17 -2
  152. data/lib/active_support/deprecation/method_wrappers.rb +61 -21
  153. data/lib/active_support/deprecation/proxy_wrappers.rb +81 -30
  154. data/lib/active_support/deprecation/reporting.rb +32 -12
  155. data/lib/active_support/deprecation.rb +12 -9
  156. data/lib/active_support/descendants_tracker.rb +57 -9
  157. data/lib/active_support/digest.rb +20 -0
  158. data/lib/active_support/duration/iso8601_parser.rb +123 -0
  159. data/lib/active_support/duration/iso8601_serializer.rb +53 -0
  160. data/lib/active_support/duration.rb +315 -40
  161. data/lib/active_support/encrypted_configuration.rb +45 -0
  162. data/lib/active_support/encrypted_file.rb +100 -0
  163. data/lib/active_support/evented_file_update_checker.rb +234 -0
  164. data/lib/active_support/execution_wrapper.rb +129 -0
  165. data/lib/active_support/executor.rb +8 -0
  166. data/lib/active_support/file_update_checker.rb +62 -37
  167. data/lib/active_support/gem_version.rb +6 -4
  168. data/lib/active_support/gzip.rb +7 -5
  169. data/lib/active_support/hash_with_indifferent_access.rb +129 -30
  170. data/lib/active_support/i18n.rb +9 -6
  171. data/lib/active_support/i18n_railtie.rb +50 -14
  172. data/lib/active_support/inflections.rb +13 -11
  173. data/lib/active_support/inflector/inflections.rb +58 -13
  174. data/lib/active_support/inflector/methods.rb +159 -145
  175. data/lib/active_support/inflector/transliterate.rb +84 -34
  176. data/lib/active_support/inflector.rb +7 -5
  177. data/lib/active_support/json/decoding.rb +32 -30
  178. data/lib/active_support/json/encoding.rb +17 -60
  179. data/lib/active_support/json.rb +4 -2
  180. data/lib/active_support/key_generator.rb +11 -43
  181. data/lib/active_support/lazy_load_hooks.rb +53 -20
  182. data/lib/active_support/locale/en.rb +33 -0
  183. data/lib/active_support/locale/en.yml +2 -0
  184. data/lib/active_support/log_subscriber/test_helper.rb +14 -12
  185. data/lib/active_support/log_subscriber.rb +44 -19
  186. data/lib/active_support/logger.rb +9 -23
  187. data/lib/active_support/logger_silence.rb +32 -14
  188. data/lib/active_support/logger_thread_safe_level.rb +32 -8
  189. data/lib/active_support/message_encryptor.rb +166 -53
  190. data/lib/active_support/message_verifier.rb +149 -16
  191. data/lib/active_support/messages/metadata.rb +72 -0
  192. data/lib/active_support/messages/rotation_configuration.rb +22 -0
  193. data/lib/active_support/messages/rotator.rb +56 -0
  194. data/lib/active_support/multibyte/chars.rb +56 -63
  195. data/lib/active_support/multibyte/unicode.rb +56 -290
  196. data/lib/active_support/multibyte.rb +4 -2
  197. data/lib/active_support/notifications/fanout.rb +109 -22
  198. data/lib/active_support/notifications/instrumenter.rb +107 -16
  199. data/lib/active_support/notifications.rb +51 -10
  200. data/lib/active_support/number_helper/number_converter.rb +16 -15
  201. data/lib/active_support/number_helper/number_to_currency_converter.rb +14 -15
  202. data/lib/active_support/number_helper/number_to_delimited_converter.rb +11 -4
  203. data/lib/active_support/number_helper/number_to_human_converter.rb +13 -10
  204. data/lib/active_support/number_helper/number_to_human_size_converter.rb +11 -9
  205. data/lib/active_support/number_helper/number_to_percentage_converter.rb +5 -1
  206. data/lib/active_support/number_helper/number_to_phone_converter.rb +15 -5
  207. data/lib/active_support/number_helper/number_to_rounded_converter.rb +25 -57
  208. data/lib/active_support/number_helper/rounding_helper.rb +66 -0
  209. data/lib/active_support/number_helper.rb +105 -68
  210. data/lib/active_support/option_merger.rb +24 -4
  211. data/lib/active_support/ordered_hash.rb +7 -5
  212. data/lib/active_support/ordered_options.rb +27 -5
  213. data/lib/active_support/parameter_filter.rb +128 -0
  214. data/lib/active_support/per_thread_registry.rb +9 -4
  215. data/lib/active_support/proxy_object.rb +2 -0
  216. data/lib/active_support/rails.rb +10 -8
  217. data/lib/active_support/railtie.rb +43 -9
  218. data/lib/active_support/reloader.rb +130 -0
  219. data/lib/active_support/rescuable.rb +108 -53
  220. data/lib/active_support/security_utils.rb +15 -11
  221. data/lib/active_support/string_inquirer.rb +11 -4
  222. data/lib/active_support/subscriber.rb +74 -30
  223. data/lib/active_support/tagged_logging.rb +25 -13
  224. data/lib/active_support/test_case.rb +107 -44
  225. data/lib/active_support/testing/assertions.rb +151 -20
  226. data/lib/active_support/testing/autorun.rb +4 -2
  227. data/lib/active_support/testing/constant_lookup.rb +2 -1
  228. data/lib/active_support/testing/declarative.rb +3 -1
  229. data/lib/active_support/testing/deprecation.rb +13 -10
  230. data/lib/active_support/testing/file_fixtures.rb +38 -0
  231. data/lib/active_support/testing/isolation.rb +35 -26
  232. data/lib/active_support/testing/method_call_assertions.rb +70 -0
  233. data/lib/active_support/testing/parallelization.rb +134 -0
  234. data/lib/active_support/testing/setup_and_teardown.rb +13 -8
  235. data/lib/active_support/testing/stream.rb +43 -0
  236. data/lib/active_support/testing/tagged_logging.rb +3 -1
  237. data/lib/active_support/testing/time_helpers.rb +84 -20
  238. data/lib/active_support/time.rb +14 -12
  239. data/lib/active_support/time_with_zone.rb +179 -39
  240. data/lib/active_support/values/time_zone.rb +203 -63
  241. data/lib/active_support/version.rb +3 -1
  242. data/lib/active_support/xml_mini/jdom.rb +116 -115
  243. data/lib/active_support/xml_mini/libxml.rb +16 -13
  244. data/lib/active_support/xml_mini/libxmlsax.rb +15 -14
  245. data/lib/active_support/xml_mini/nokogiri.rb +14 -12
  246. data/lib/active_support/xml_mini/nokogirisax.rb +14 -13
  247. data/lib/active_support/xml_mini/rexml.rb +11 -9
  248. data/lib/active_support/xml_mini.rb +38 -46
  249. data/lib/active_support.rb +13 -11
  250. metadata +84 -26
  251. data/lib/active_support/concurrency/latch.rb +0 -27
  252. data/lib/active_support/core_ext/big_decimal/yaml_conversions.rb +0 -16
  253. data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -45
  254. data/lib/active_support/core_ext/date_time/zones.rb +0 -6
  255. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -11
  256. data/lib/active_support/core_ext/kernel/debugger.rb +0 -10
  257. data/lib/active_support/core_ext/module/method_transplanting.rb +0 -13
  258. data/lib/active_support/core_ext/module/qualified_const.rb +0 -52
  259. data/lib/active_support/core_ext/object/itself.rb +0 -15
  260. data/lib/active_support/core_ext/struct.rb +0 -6
  261. data/lib/active_support/core_ext/thread.rb +0 -86
  262. data/lib/active_support/core_ext/time/marshal.rb +0 -30
  263. data/lib/active_support/values/unicode_tables.dat +0 -0
data/CHANGELOG.md CHANGED
@@ -1,678 +1,666 @@
1
- ## Rails 4.2.11.1 (March 11, 2019) ##
1
+ ## Rails 6.0.3.1 (May 18, 2020) ##
2
2
 
3
- * No changes.
4
-
5
-
6
- ## Rails 4.2.11 (November 27, 2018) ##
7
-
8
- * No changes.
3
+ * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
9
4
 
5
+ * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
10
6
 
11
- ## Rails 4.2.10 (September 27, 2017) ##
7
+ ## Rails 6.0.3 (May 06, 2020) ##
12
8
 
13
- * No changes.
9
+ * `Array#to_sentence` no longer returns a frozen string.
14
10
 
11
+ Before:
15
12
 
16
- ## Rails 4.2.9 (June 26, 2017) ##
13
+ ['one', 'two'].to_sentence.frozen?
14
+ # => true
17
15
 
18
- * Fixed bug in `DateAndTime::Compatibility#to_time` that caused it to
19
- raise `RuntimeError: can't modify frozen Time` when called on any frozen `Time`.
20
- Properly pass through the frozen `Time` or `ActiveSupport::TimeWithZone` object
21
- when calling `#to_time`.
16
+ After:
22
17
 
23
- *Kevin McPhillips* & *Andrew White*
18
+ ['one', 'two'].to_sentence.frozen?
19
+ # => false
24
20
 
25
- * Restore the return type of `DateTime#utc`
21
+ *Nicolas Dular*
26
22
 
27
- In Rails 5.0 the return type of `DateTime#utc` was changed to `Time` to be
28
- consistent with the new `DateTime#localtime` method. When these changes were
29
- backported in #27553 this inadvertently changed the return type in a patcn
30
- release. Since `DateTime#localtime` was new in Rails 4.2.8 it's okay to
31
- restore the return type of `DateTime#utc` but keep `DateTime#localtime` as
32
- returning `Time` without breaking backwards compatibility.
23
+ * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
24
+ `ActiveSupport.parse_json_times = true`.
33
25
 
34
- *Andrew White*
26
+ *Christian Gregg*
35
27
 
36
- * In Core Extensions, make `MarshalWithAutoloading#load` pass through the second, optional
37
- argument for `Marshal#load( source [, proc] )`. This way we don't have to do
38
- `Marshal.method(:load).super_method.call(sourse, proc)` just to be able to pass a proc.
39
28
 
40
- *Jeff Latz*
29
+ ## Rails 6.0.2.2 (March 19, 2020) ##
41
30
 
42
- * Cache `ActiveSupport::TimeWithZone#to_datetime` before freezing.
43
-
44
- *Adam Rice*
31
+ * No changes.
45
32
 
46
- * `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as
47
- `Time.now` and `Date.today`.
48
33
 
49
- *Yuki Nishijima*
34
+ ## Rails 6.0.2.1 (December 18, 2019) ##
50
35
 
36
+ * No changes.
51
37
 
52
- ## Rails 4.2.8 (February 21, 2017) ##
53
38
 
54
- * Make `getlocal` and `getutc` always return instances of `Time` for
55
- `ActiveSupport::TimeWithZone` and `DateTime`. This eliminates a possible
56
- stack level too deep error in `to_time` where `ActiveSupport::TimeWithZone`
57
- was wrapping a `DateTime` instance. As a consequence of this the internal
58
- time value in `ActiveSupport::TimeWithZone` is now always an instance of
59
- `Time` in the UTC timezone, whether that's as the UTC time directly or
60
- a representation of the local time in the timezone. There should be no
61
- consequences of this internal change and if there are it's a bug due to
62
- leaky abstractions.
39
+ ## Rails 6.0.2 (December 13, 2019) ##
63
40
 
64
- *Andrew White*
41
+ * Eager load translations during initialization.
65
42
 
66
- * Add `DateTime#subsec` to return the fraction of a second as a `Rational`.
43
+ *Diego Plentz*
67
44
 
68
- *Andrew White*
45
+ * Use per-thread CPU time clock on `ActiveSupport::Notifications`.
69
46
 
70
- * Add additional aliases for `DateTime#utc` to mirror the ones on
71
- `ActiveSupport::TimeWithZone` and `Time`.
47
+ *George Claghorn*
72
48
 
73
- *Andrew White*
74
49
 
75
- * Add `DateTime#localtime` to return an instance of `Time` in the system's
76
- local timezone. Also aliased to `getlocal`.
50
+ ## Rails 6.0.1 (November 5, 2019) ##
77
51
 
78
- *Andrew White*, *Yuichiro Kaneko*
52
+ * `ActiveSupport::SafeBuffer` supports `Enumerator` methods.
79
53
 
80
- * Add `Time#sec_fraction` to return the fraction of a second as a `Rational`.
54
+ *Shugo Maeda*
81
55
 
82
- *Andrew White*
56
+ * The Redis cache store fails gracefully when the server returns a "max number
57
+ of clients reached" error.
83
58
 
84
- * Add `ActiveSupport.to_time_preserves_timezone` config option to control
85
- how `to_time` handles timezones. In Ruby 2.4+ the behavior will change
86
- from converting to the local system timezone, to preserving the timezone
87
- of the receiver. This config option defaults to false so that apps made
88
- with earlier versions of Rails are not affected when upgrading, e.g:
59
+ *Brandon Medenwald*
89
60
 
90
- >> ENV['TZ'] = 'US/Eastern'
61
+ * Fixed that mutating a value returned by a memory cache store would
62
+ unexpectedly change the cached value.
91
63
 
92
- >> "2016-04-23T10:23:12.000Z".to_time
93
- => "2016-04-23T06:23:12.000-04:00"
64
+ *Jonathan Hyman*
94
65
 
95
- >> ActiveSupport.to_time_preserves_timezone = true
66
+ * The default inflectors in `zeitwerk` mode support overrides:
96
67
 
97
- >> "2016-04-23T10:23:12.000Z".to_time
98
- => "2016-04-23T10:23:12.000Z"
68
+ ```ruby
69
+ # config/initializers/zeitwerk.rb
70
+ Rails.autoloaders.each do |autoloader|
71
+ autoloader.inflector.inflect(
72
+ "html_parser" => "HTMLParser",
73
+ "ssl_error" => "SSLError"
74
+ )
75
+ end
76
+ ```
99
77
 
100
- Fixes #24617.
78
+ That way, you can tweak how individual basenames are inflected without touching Active Support inflection rules, which are global. These inflectors fallback to `String#camelize`, so existing inflection rules are still taken into account for non-overridden basenames.
101
79
 
102
- *Andrew White*
80
+ Please, check the [autoloading guide for `zeitwerk` mode](https://guides.rubyonrails.org/v6.0/autoloading_and_reloading_constants.html#customizing-inflections) if you prefer not to depend on `String#camelize` at all.
103
81
 
104
- * Add `init_with` to `ActiveSupport::TimeWithZone` and `ActiveSupport::TimeZone`
82
+ *Xavier Noria*
105
83
 
106
- It is helpful to be able to run apps concurrently written in successive
107
- versions of Rails to aid migration, e.g. run Rails 4.2 and 5.0 variants
108
- of your application at the same time to carry out A/B testing.
84
+ * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
85
+ and endless range targets.
109
86
 
110
- To do this serialization formats need to be cross compatible and the
111
- change in 3aa26cf didn't meet this criteria because the Psych loader
112
- checks for the existence of `init_with` before setting the instance
113
- variables and the wrapping behavior of `ActiveSupport::TimeWithZone`
114
- tries to see if the `Time` instance responds to `init_with` before the
115
- `@time` variable is set.
87
+ *Allen Hsu*, *Andrew Hodgkinson*
116
88
 
117
- To fix this we backported just the `init_with` behavior from the change
118
- in 3aa26cf. If the revived instance is then written out to YAML again
119
- it will revert to the default Rails 4.2 behavior of converting it to
120
- a UTC timestamp string.
89
+ * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
121
90
 
122
- Fixes #26296.
91
+ *Iain Beeston*
123
92
 
124
- *Andrew White*
125
93
 
126
- * Fix `ActiveSupport::TimeWithZone#in` across DST boundaries.
94
+ ## Rails 6.0.0 (August 16, 2019) ##
127
95
 
128
- Previously calls to `in` were being sent to the non-DST aware
129
- method `Time#since` via `method_missing`. It is now aliased to
130
- the DST aware `ActiveSupport::TimeWithZone#since` which handles
131
- transitions across DST boundaries, e.g:
96
+ * Let `require_dependency` in `zeitwerk` mode look the autoload paths up for
97
+ better backwards compatibility.
132
98
 
133
- Time.zone = "US/Eastern"
99
+ *Xavier Noria*
134
100
 
135
- t = Time.zone.local(2016,11,6,1)
136
- # => Sun, 06 Nov 2016 01:00:00 EDT -05:00
101
+ * Let `require_dependency` in `zeitwerk` mode support arguments that respond
102
+ to `to_path` for better backwards compatibility.
137
103
 
138
- t.in(1.hour)
139
- # => Sun, 06 Nov 2016 01:00:00 EST -05:00
104
+ *Xavier Noria*
140
105
 
141
- Fixes #26580.
106
+ * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
142
107
 
143
- *Thomas Balthazar*
108
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
109
+ to make log level local to Ruby Fibers in addition to Threads.
144
110
 
111
+ Example:
145
112
 
146
- ## Rails 4.2.7 (July 12, 2016) ##
113
+ logger = ActiveSupport::Logger.new(STDOUT)
114
+ logger.level = 1
115
+ p "Main is debug? #{logger.debug?}"
147
116
 
148
- * Fixed `ActiveSupport::Logger.broadcast` so that calls to `#silence` now
149
- properly delegate to all loggers. Silencing now properly suppresses logging
150
- to both the log and the console.
117
+ Fiber.new {
118
+ logger.local_level = 0
119
+ p "Thread is debug? #{logger.debug?}"
120
+ }.resume
151
121
 
152
- *Kevin McPhillips*
122
+ p "Main is debug? #{logger.debug?}"
153
123
 
154
- * Backported `ActiveSupport::LoggerThreadSafeLevel`. Assigning the
155
- `Rails.logger.level` is now thread safe.
124
+ Before:
156
125
 
157
- *Kevin McPhillips*
126
+ Main is debug? false
127
+ Thread is debug? true
128
+ Main is debug? true
158
129
 
159
- * Fixed a problem with ActiveSupport::SafeBuffer.titleize calling capitalize
160
- on nil.
130
+ After:
161
131
 
162
- *Brian McManus*
132
+ Main is debug? false
133
+ Thread is debug? true
134
+ Main is debug? false
163
135
 
164
- * Time zones: Ensure that the UTC offset reflects DST changes that occurred
165
- since the app started. Removes UTC offset caching, reducing performance,
166
- but this is still relatively quick and isn't in any hot paths.
136
+ *Alexander Varnin*
167
137
 
168
- *Alexey Shein*
138
+ * Do not delegate missing `marshal_dump` and `_dump` methods via the
139
+ `delegate_missing_to` extension. This avoids unintentionally adding instance
140
+ variables when calling `Marshal.dump(object)`, should the delegation target of
141
+ `object` be a method which would otherwise add them. Fixes #36522.
169
142
 
170
- * Prevent `Marshal.load` from looping infinitely when trying to autoload a constant
171
- which resolves to a different name.
143
+ *Aaron Lipman*
172
144
 
173
- *Olek Janiszewski*
174
145
 
146
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
175
147
 
176
- ## Rails 4.2.6 (March 07, 2016) ##
148
+ * `truncate` would return the original string if it was too short to be truncated
149
+ and a frozen string if it were long enough to be truncated. Now truncate will
150
+ consistently return an unfrozen string regardless. This behavior is consistent
151
+ with `gsub` and `strip`.
177
152
 
178
- * No changes.
153
+ Before:
179
154
 
155
+ 'foobar'.truncate(5).frozen?
156
+ # => true
157
+ 'foobar'.truncate(6).frozen?
158
+ # => false
180
159
 
181
- ## Rails 4.2.5.2 (February 26, 2016) ##
160
+ After:
182
161
 
183
- * No changes.
162
+ 'foobar'.truncate(5).frozen?
163
+ # => false
164
+ 'foobar'.truncate(6).frozen?
165
+ # => false
184
166
 
167
+ *Jordan Thomas*
185
168
 
186
- ## Rails 4.2.5.1 (January 25, 2015) ##
187
169
 
188
- * No changes.
170
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
189
171
 
172
+ * Introduce `ActiveSupport::ActionableError`.
190
173
 
191
- ## Rails 4.2.5 (November 12, 2015) ##
174
+ Actionable errors let's you dispatch actions from Rails' error pages. This
175
+ can help you save time if you have a clear action for the resolution of
176
+ common development errors.
192
177
 
193
- * Fix `TimeWithZone#eql?` to properly handle `TimeWithZone` created from `DateTime`:
194
- twz = DateTime.now.in_time_zone
195
- twz.eql?(twz.dup) => true
178
+ The de-facto example are pending migrations. Every time pending migrations
179
+ are found, a middleware raises an error. With actionable errors, you can
180
+ run the migrations right from the error page. Other examples include Rails
181
+ plugins that need to run a rake task to setup themselves. They can now
182
+ raise actionable errors to run the setup straight from the error pages.
196
183
 
197
- Fixes #14178.
184
+ Here is how to define an actionable error:
198
185
 
199
- *Roque Pinel*
186
+ ```ruby
187
+ class PendingMigrationError < MigrationError #:nodoc:
188
+ include ActiveSupport::ActionableError
200
189
 
201
- * Handle invalid UTF-8 characters in `MessageVerifier.verify`.
190
+ action "Run pending migrations" do
191
+ ActiveRecord::Tasks::DatabaseTasks.migrate
192
+ end
193
+ end
194
+ ```
202
195
 
203
- *Roque Pinel*, *Grey Baker*
196
+ To make an error actionable, include the `ActiveSupport::ActionableError`
197
+ module and invoke the `action` class macro to define the action. An action
198
+ needs a name and a procedure to execute. The name is shown as the name of a
199
+ button on the error pages. Once clicked, it will invoke the given
200
+ procedure.
204
201
 
202
+ *Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
205
203
 
206
- ## Rails 4.2.4 (August 24, 2015) ##
204
+ * Preserve `html_safe?` status on `ActiveSupport::SafeBuffer#*`.
207
205
 
208
- * Fix a `SystemStackError` when encoding an `Enumerable` with `json` gem and
209
- with the Active Support JSON encoder loaded.
206
+ Before:
210
207
 
211
- Fixes #20775.
208
+ ("<br />".html_safe * 2).html_safe? #=> nil
212
209
 
213
- *Sammy Larbi*, *Prathamesh Sonpatki*
210
+ After:
214
211
 
215
- * Fix not calling `#default` on `HashWithIndifferentAcess#to_hash` when only
216
- `default_proc` is set, which could raise.
212
+ ("<br />".html_safe * 2).html_safe? #=> true
217
213
 
218
- *Simon Eskildsen*
214
+ *Ryo Nakamura*
219
215
 
220
- * Fix setting `default_proc` on `HashWithIndifferentAccess#dup`
216
+ * Calling test methods with `with_info_handler` method to allow minitest-hooks
217
+ plugin to work.
221
218
 
222
- *Simon Eskildsen*
219
+ *Mauri Mustonen*
223
220
 
221
+ * The Zeitwerk compatibility interface for `ActiveSupport::Dependencies` no
222
+ longer implements `autoloaded_constants` or `autoloaded?` (undocumented,
223
+ anyway). Experience shows introspection does not have many use cases, and
224
+ troubleshooting is done by logging. With this design trade-off we are able
225
+ to use even less memory in all environments.
224
226
 
225
- ## Rails 4.2.3 (June 25, 2015) ##
227
+ *Xavier Noria*
226
228
 
227
- * Fix a range of values for parameters of the Time#change
229
+ * Depends on Zeitwerk 2, which stores less metadata if reloading is disabled
230
+ and hence uses less memory when `config.cache_classes` is `true`, a standard
231
+ setup in production.
228
232
 
229
- *Nikolay Kondratyev*
233
+ *Xavier Noria*
230
234
 
231
- * Add some missing `require 'active_support/deprecation'`
235
+ * In `:zeitwerk` mode, eager load directories in engines and applications only
236
+ if present in their respective `config.eager_load_paths`.
232
237
 
233
- *Akira Matsuda*
238
+ A common use case for this is adding `lib` to `config.autoload_paths`, but
239
+ not to `config.eager_load_paths`. In that configuration, for example, files
240
+ in the `lib` directory should not be eager loaded.
234
241
 
242
+ *Xavier Noria*
235
243
 
236
- ## Rails 4.2.2 (June 16, 2015) ##
244
+ * Fix bug in Range comparisons when comparing to an excluded-end Range
237
245
 
238
- * Fix XSS vulnerability in `ActiveSupport::JSON.encode` method.
246
+ Before:
239
247
 
240
- CVE-2015-3226.
248
+ (1..10).cover?(1...11) # => false
241
249
 
242
- *Rafael Mendonça França*
250
+ After:
243
251
 
244
- * Fix denial of service vulnerability in the XML processing.
252
+ (1..10).cover?(1...11) # => true
245
253
 
246
- CVE-2015-3227.
254
+ With the same change for `Range#include?` and `Range#===`.
247
255
 
248
- *Aaron Patterson*
256
+ *Owen Stephens*
249
257
 
258
+ * Use weak references in descendants tracker to allow anonymous subclasses to
259
+ be garbage collected.
250
260
 
251
- ## Rails 4.2.1 (March 19, 2015) ##
261
+ *Edgars Beigarts*
252
262
 
253
- * Fixed a problem where String#truncate_words would get stuck with a complex
254
- string.
263
+ * Update `ActiveSupport::Notifications::Instrumenter#instrument` to make
264
+ passing a block optional. This will let users use
265
+ `ActiveSupport::Notifications` messaging features outside of
266
+ instrumentation.
255
267
 
256
- *Henrik Nygren*
268
+ *Ali Ibrahim*
257
269
 
258
- * Fixed a roundtrip problem with AS::SafeBuffer where primitive-like strings
259
- will be dumped as primitives:
270
+ * Fix `Time#advance` to work with dates before 1001-03-07
260
271
 
261
272
  Before:
262
273
 
263
- YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
264
- YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
265
- YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
266
- YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
267
- YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
268
-
269
- After:
270
-
271
- YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
272
- YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
273
- YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
274
- YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
275
- YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
276
-
277
- *Godfrey Chan*
278
-
279
- * Replace fixed `:en` with `I18n.default_locale` in `Duration#inspect`.
274
+ Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-05 00:00:00 UTC
280
275
 
281
- *Dominik Masur*
276
+ After
282
277
 
283
- * Add missing time zone definitions for Russian Federation and sync them
284
- with `zone.tab` file from tzdata version 2014j (latest).
278
+ Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-06 00:00:00 UTC
285
279
 
286
- *Andrey Novikov*
280
+ Note that this doesn't affect `DateTime#advance` as that doesn't use a proleptic calendar.
287
281
 
282
+ *Andrew White*
288
283
 
289
- ## Rails 4.2.0 (December 20, 2014) ##
290
-
291
- * The decorated `load` and `require` methods are now kept private.
292
-
293
- Fixes #17553.
284
+ * In Zeitwerk mode, engines are now managed by the `main` autoloader. Engines may reference application constants, if the application is reloaded and we do not reload engines, they won't use the reloaded application code.
294
285
 
295
286
  *Xavier Noria*
296
287
 
297
- * `String#remove` and `String#remove!` accept multiple arguments.
288
+ * Add support for supplying `locale` to `transliterate` and `parameterize`.
298
289
 
299
- *Pavel Pravosud*
290
+ I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { "ü" => "ue" } } })
300
291
 
301
- * `TimeWithZone#strftime` now delegates every directive to `Time#strftime` except for '%Z',
302
- it also now correctly handles escaped '%' characters placed just before time zone related directives.
292
+ ActiveSupport::Inflector.transliterate("ü", locale: :de) # => "ue"
293
+ "Fünf autos".parameterize(locale: :de) # => "fuenf-autos"
294
+ ActiveSupport::Inflector.parameterize("Fünf autos", locale: :de) # => "fuenf-autos"
303
295
 
304
- *Pablo Herrero*
296
+ *Kaan Ozkan*, *Sharang Dashputre*
305
297
 
306
- * Corrected `Inflector#underscore` handling of multiple successive acroynms.
298
+ * Allow `Array#excluding` and `Enumerable#excluding` to deal with a passed array gracefully.
307
299
 
308
- *James Le Cuirot*
300
+ [ 1, 2, 3, 4, 5 ].excluding([4, 5]) # => [ 1, 2, 3 ]
309
301
 
310
- * Delegation now works with ruby reserved words passed to `:to` option.
311
-
312
- Fixes #16956.
302
+ *DHH*
313
303
 
314
- *Agis Anastasopoulos*
304
+ * Renamed `Array#without` and `Enumerable#without` to `Array#excluding` and `Enumerable#excluding`, to create parity with
305
+ `Array#including` and `Enumerable#including`. Retained the old names as aliases.
315
306
 
316
- * Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`.
307
+ *DHH*
317
308
 
318
- Currently, the following returns `false`, contrary to expectation:
309
+ * Added `Array#including` and `Enumerable#including` to conveniently enlarge a collection with more members using a method rather than an operator:
319
310
 
320
- 1.minute.eql?(1.minute)
311
+ [ 1, 2, 3 ].including(4, 5) # => [ 1, 2, 3, 4, 5 ]
312
+ post.authors.including(Current.person) # => All the authors plus the current person!
321
313
 
322
- Adding method `#eql?` will make this behave like expected. Method `#eql?` is
323
- just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their
324
- parts may be different though.
314
+ *DHH*
325
315
 
326
- 1.minute.eql?(60.seconds) # => true
327
- 1.minute.eql?(60) # => false
328
316
 
329
- *Joost Lubach*
317
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
330
318
 
331
- * `Time#change` can now change nanoseconds (`:nsec`) as a higher-precision
332
- alternative to microseconds (`:usec`).
319
+ * No changes.
333
320
 
334
- *Agis Anastasooulos*
335
321
 
336
- * `MessageVerifier.new` raises an appropriate exception if the secret is `nil`.
337
- This prevents `MessageVerifier#generate` from raising a cryptic error later on.
322
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
338
323
 
339
- *Kostiantyn Kahanskyi*
324
+ * New autoloading based on [Zeitwerk](https://github.com/fxn/zeitwerk).
340
325
 
341
- * Introduced new configuration option `active_support.test_order` for
342
- specifying the order in which test cases are executed. This option currently defaults
343
- to `:sorted` but will be changed to `:random` in Rails 5.0.
326
+ *Xavier Noria*
344
327
 
345
- *Akira Matsuda*, *Godfrey Chan*
328
+ * Revise `ActiveSupport::Notifications.unsubscribe` to correctly handle Regex or other multiple-pattern subscribers.
346
329
 
347
- * Fixed a bug in `Inflector#underscore` where acroynms in nested constant names
348
- are incorrectly parsed as camelCase.
330
+ *Zach Kemp*
349
331
 
350
- Fixes #8015.
332
+ * Add `before_reset` callback to `CurrentAttributes` and define `after_reset` as an alias of `resets` for symmetry.
351
333
 
352
- *Fred Wu*, *Matthew Draper*
334
+ *Rosa Gutierrez*
353
335
 
354
- * Make `Time#change` throw an exception if the `:usec` option is out of range and
355
- the time has an offset other than UTC or local.
336
+ * Remove the `` Kernel#` `` override that suppresses ENOENT and accidentally returns nil on Unix systems.
356
337
 
357
- *Agis Anastasopoulos*
338
+ *Akinori Musha*
358
339
 
359
- * `Method` objects now report themselves as not `duplicable?`. This allows
360
- hashes and arrays containing `Method` objects to be `deep_dup`ed.
340
+ * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
361
341
 
362
- *Peter Jaros*
342
+ `assoc` can now be called with either a string or a symbol.
363
343
 
364
- * `determine_constant_from_test_name` does no longer shadow `NameError`s
365
- which happens during constant autoloading.
344
+ *Stefan Schüßler*
366
345
 
367
- Fixes #9933.
346
+ * Add `Hash#deep_transform_values`, and `Hash#deep_transform_values!`.
368
347
 
369
- *Guo Xiang Tan*
348
+ *Guillermo Iguaran*
370
349
 
371
- * Added instance_eval version to Object#try and Object#try!, so you can do this:
372
350
 
373
- person.try { name.first }
351
+ ## Rails 6.0.0.beta1 (January 18, 2019) ##
374
352
 
375
- instead of:
353
+ * Remove deprecated `Module#reachable?` method.
376
354
 
377
- person.try { |person| person.name.first }
355
+ *Rafael Mendonça França*
378
356
 
379
- *DHH*, *Ari Pollak*
357
+ * Remove deprecated `#acronym_regex` method from `Inflections`.
380
358
 
381
- * Fix the `ActiveSupport::Duration#instance_of?` method to return the right
382
- value with the class itself since it was previously delegated to the
383
- internal value.
359
+ *Rafael Mendonça França*
384
360
 
385
- *Robin Dupret*
361
+ * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
386
362
 
387
- * Fix rounding errors with `#travel_to` by resetting the usec on any passed time to zero, so we only travel
388
- with per-second precision, not anything deeper than that.
363
+ *Keenan Brock*
389
364
 
390
- *DHH*
365
+ * Preserve key order passed to `ActiveSupport::CacheStore#fetch_multi`.
391
366
 
392
- * Fix DateTime comparison with `DateTime::Infinity` object.
367
+ `fetch_multi(*names)` now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
393
368
 
394
- *Rafael Mendonça França*
369
+ *Gannon McGibbon*
395
370
 
396
- * Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
371
+ * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
397
372
 
398
- Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at)
373
+ *Mark J. Titorenko*, *Vlad Bokov*
399
374
 
400
- *DHH*
375
+ * Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
376
+ would not act as alias for `#symbolize_keys`.
401
377
 
402
- * `Object#with_options` executes block in merging option context when
403
- explicit receiver in not passed.
378
+ *Nick Weiland*
404
379
 
405
- *Pavel Pravosud*
380
+ * Improve the logic that detects non-autoloaded constants.
406
381
 
407
- * Fixed a compatibility issue with the `Oj` gem when cherry-picking the file
408
- `active_support/core_ext/object/json` without requiring `active_support/json`.
382
+ *Jan Habermann*, *Xavier Noria*
409
383
 
410
- Fixes #16131.
384
+ * Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSupport::Multibyte::Unicode#unpack_graphemes(string)`
385
+ in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
411
386
 
412
- *Godfrey Chan*
387
+ *Francesco Rodríguez*
413
388
 
414
- * Make `Hash#with_indifferent_access` copy the default proc too.
389
+ * Deprecate `ActiveSupport::Multibyte::Chars.consumes?` in favor of `String#is_utf8?`.
415
390
 
416
- *arthurnn*, *Xanders*
391
+ *Francesco Rodríguez*
417
392
 
418
- * Add `String#truncate_words` to truncate a string by a number of words.
393
+ * Fix duration being rounded to a full second.
394
+ ```
395
+ time = DateTime.parse("2018-1-1")
396
+ time += 0.51.seconds
397
+ ```
398
+ Will now correctly add 0.51 second and not 1 full second.
419
399
 
420
- *Mohamed Osama*
400
+ *Edouard Chin*
421
401
 
422
- * Deprecate `capture` and `quietly`.
402
+ * Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSupport::Multibyte::Chars#normalize`
403
+ in favor of `String#unicode_normalize`
423
404
 
424
- These methods are not thread safe and may cause issues when used in threaded environments.
425
- To avoid problems we are deprecating them.
405
+ *Francesco Rodríguez*
426
406
 
427
- *Tom Meier*
407
+ * Deprecate `ActiveSupport::Multibyte::Unicode#downcase/upcase/swapcase` in favor of
408
+ `String#downcase/upcase/swapcase`.
428
409
 
429
- * `DateTime#to_f` now preserves the fractional seconds instead of always
430
- rounding to `.0`.
410
+ *Francesco Rodríguez*
431
411
 
432
- Fixes #15994.
412
+ * Add `ActiveSupport::ParameterFilter`.
433
413
 
434
- *John Paul Ashenfelter*
414
+ *Yoshiyuki Kinjo*
435
415
 
436
- * Add `Hash#transform_values` to simplify a common pattern where the values of a
437
- hash must change, but the keys are left the same.
416
+ * Rename `Module#parent`, `Module#parents`, and `Module#parent_name` to
417
+ `module_parent`, `module_parents`, and `module_parent_name`.
438
418
 
439
- *Sean Griffin*
419
+ *Gannon McGibbon*
440
420
 
441
- * Always instrument `ActiveSupport::Cache`.
421
+ * Deprecate the use of `LoggerSilence` in favor of `ActiveSupport::LoggerSilence`
442
422
 
443
- Since `ActiveSupport::Notifications` only instruments items when there
444
- are attached subscribers, we don't need to disable instrumentation.
423
+ *Edouard Chin*
445
424
 
446
- *Peter Wagenet*
425
+ * Deprecate using negative limits in `String#first` and `String#last`.
447
426
 
448
- * Make the `apply_inflections` method case-insensitive when checking
449
- whether a word is uncountable or not.
427
+ *Gannon McGibbon*, *Eric Turner*
450
428
 
451
- *Robin Dupret*
429
+ * Fix bug where `#without` for `ActiveSupport::HashWithIndifferentAccess` would fail
430
+ with symbol arguments
452
431
 
453
- * Make Dependencies pass a name to NameError error.
432
+ *Abraham Chan*
454
433
 
455
- *arthurnn*
434
+ * Treat `#delete_prefix`, `#delete_suffix` and `#unicode_normalize` results as non-`html_safe`.
435
+ Ensure safety of arguments for `#insert`, `#[]=` and `#replace` calls on `html_safe` Strings.
456
436
 
457
- * Fixed `ActiveSupport::Cache::FileStore` exploding with long paths.
437
+ *Janosch Müller*
458
438
 
459
- *Adam Panzer*, *Michael Grosser*
439
+ * Changed `ActiveSupport::TaggedLogging.new` to return a new logger instance instead
440
+ of mutating the one received as parameter.
460
441
 
461
- * Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
462
- when working with objects with a nanosecond component.
442
+ *Thierry Joyal*
463
443
 
464
- `ActiveSupport::TimeWithZone#-` should return the same result as if we were
465
- using `Time#-`:
444
+ * Define `unfreeze_time` as an alias of `travel_back` in `ActiveSupport::Testing::TimeHelpers`.
466
445
 
467
- Time.now.end_of_day - Time.now.beginning_of_day # => 86399.999999999
446
+ The alias is provided for symmetry with `freeze_time`.
468
447
 
469
- Before:
448
+ *Ryan Davidson*
470
449
 
471
- Time.zone.now.end_of_day.nsec # => 999999999
472
- Time.zone.now.end_of_day - Time.zone.now.beginning_of_day # => 86400.0
450
+ * Add support for tracing constant autoloads. Just throw
473
451
 
474
- After:
452
+ ActiveSupport::Dependencies.logger = Rails.logger
453
+ ActiveSupport::Dependencies.verbose = true
475
454
 
476
- Time.zone.now.end_of_day - Time.zone.now.beginning_of_day
477
- # => 86399.999999999
455
+ in an initializer.
478
456
 
479
- *Gordon Chan*
457
+ *Xavier Noria*
480
458
 
481
- * Fixed precision error in NumberHelper when using Rationals.
459
+ * Maintain `html_safe?` on html_safe strings when sliced.
482
460
 
483
- Before:
461
+ string = "<div>test</div>".html_safe
462
+ string[-1..1].html_safe? # => true
484
463
 
485
- ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
486
- # => "330.00"
464
+ *Elom Gomez*, *Yumin Wong*
487
465
 
488
- After:
466
+ * Add `Array#extract!`.
489
467
 
490
- ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
491
- # => "333.33"
468
+ The method removes and returns the elements for which the block returns a true value.
469
+ If no block is given, an Enumerator is returned instead.
492
470
 
493
- See #15379.
471
+ numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
472
+ odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
473
+ numbers # => [0, 2, 4, 6, 8]
494
474
 
495
- *Juanjo Bazán*
475
+ *bogdanvlviv*
496
476
 
497
- * Removed deprecated `Numeric#ago` and friends
477
+ * Support not to cache `nil` for `ActiveSupport::Cache#fetch`.
498
478
 
499
- Replacements:
479
+ cache.fetch('bar', skip_nil: true) { nil }
480
+ cache.exist?('bar') # => false
500
481
 
501
- 5.ago => 5.seconds.ago
502
- 5.until => 5.seconds.until
503
- 5.since => 5.seconds.since
504
- 5.from_now => 5.seconds.from_now
482
+ *Martin Hong*
505
483
 
506
- See #12389 for the history and rationale behind this.
484
+ * Add "event object" support to the notification system.
485
+ Before this change, end users were forced to create hand made artisanal
486
+ event objects on their own, like this:
507
487
 
508
- *Godfrey Chan*
488
+ ActiveSupport::Notifications.subscribe('wait') do |*args|
489
+ @event = ActiveSupport::Notifications::Event.new(*args)
490
+ end
509
491
 
510
- * DateTime `advance` now supports partial days.
492
+ ActiveSupport::Notifications.instrument('wait') do
493
+ sleep 1
494
+ end
511
495
 
512
- Before:
496
+ @event.duration # => 1000.138
513
497
 
514
- DateTime.now.advance(days: 1, hours: 12)
498
+ After this change, if the block passed to `subscribe` only takes one
499
+ parameter, the framework will yield an event object to the block. Now
500
+ end users are no longer required to make their own:
515
501
 
516
- After:
502
+ ActiveSupport::Notifications.subscribe('wait') do |event|
503
+ @event = event
504
+ end
517
505
 
518
- DateTime.now.advance(days: 1.5)
506
+ ActiveSupport::Notifications.instrument('wait') do
507
+ sleep 1
508
+ end
519
509
 
520
- Fixes #12005.
510
+ p @event.allocations # => 7
511
+ p @event.cpu_time # => 0.256
512
+ p @event.idle_time # => 1003.2399
521
513
 
522
- *Shay Davidson*
514
+ Now you can enjoy event objects without making them yourself. Neat!
523
515
 
524
- * `Hash#deep_transform_keys` and `Hash#deep_transform_keys!` now transform hashes
525
- in nested arrays. This change also applies to `Hash#deep_stringify_keys`,
526
- `Hash#deep_stringify_keys!`, `Hash#deep_symbolize_keys` and
527
- `Hash#deep_symbolize_keys!`.
516
+ *Aaron "t.lo" Patterson*
528
517
 
529
- *OZAWA Sakuro*
518
+ * Add cpu_time, idle_time, and allocations to Event.
530
519
 
531
- * Fixed confusing `DelegationError` in `Module#delegate`.
520
+ *Eileen M. Uchitelle*, *Aaron Patterson*
532
521
 
533
- See #15186.
522
+ * RedisCacheStore: support key expiry in increment/decrement.
534
523
 
535
- *Vladimir Yarotsky*
524
+ Pass `:expires_in` to `#increment` and `#decrement` to set a Redis EXPIRE on the key.
536
525
 
537
- * Fixed `ActiveSupport::Subscriber` so that no duplicate subscriber is created
538
- when a subscriber method is redefined.
526
+ If the key is already set to expire, RedisCacheStore won't extend its expiry.
539
527
 
540
- *Dennis Schön*
528
+ Rails.cache.increment("some_key", 1, expires_in: 2.minutes)
541
529
 
542
- * Remove deprecated string based terminators for `ActiveSupport::Callbacks`.
530
+ *Jason Lee*
543
531
 
544
- *Eileen M. Uchitelle*
532
+ * Allow `Range#===` and `Range#cover?` on Range.
545
533
 
546
- * Fixed an issue when using
547
- `ActiveSupport::NumberHelper::NumberToDelimitedConverter` to
548
- convert a value that is an `ActiveSupport::SafeBuffer` introduced
549
- in 2da9d67.
534
+ `Range#cover?` can now accept a range argument like `Range#include?` and
535
+ `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
536
+ into a new file, with these two methods.
550
537
 
551
- See #15064.
538
+ *Requiring active_support/core_ext/range/include_range is now deprecated.*
539
+ *Use `require "active_support/core_ext/range/compare_range"` instead.*
552
540
 
553
- *Mark J. Titorenko*
541
+ *utilum*
554
542
 
555
- * `TimeZone#parse` defaults the day of the month to '1' if any other date
556
- components are specified. This is more consistent with the behavior of
557
- `Time#parse`.
543
+ * Add `index_with` to Enumerable.
558
544
 
559
- *Ulysse Carion*
545
+ Allows creating a hash from an enumerable with the value from a passed block
546
+ or a default argument.
560
547
 
561
- * `humanize` strips leading underscores, if any.
548
+ %i( title body ).index_with { |attr| post.public_send(attr) }
549
+ # => { title: "hey", body: "what's up?" }
562
550
 
563
- Before:
551
+ %i( title body ).index_with(nil)
552
+ # => { title: nil, body: nil }
564
553
 
565
- '_id'.humanize # => ""
554
+ Closely linked with `index_by`, which creates a hash where the keys are extracted from a block.
566
555
 
567
- After:
556
+ *Kasper Timm Hansen*
568
557
 
569
- '_id'.humanize # => "Id"
558
+ * Fix bug where `ActiveSupport::TimeZone.all` would fail when tzinfo data for
559
+ any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
570
560
 
571
- *Xavier Noria*
561
+ *Dominik Sander*
572
562
 
573
- * Fixed backward compatibility issues introduced in 326e652.
563
+ * Redis cache store: `delete_matched` no longer blocks the Redis server.
564
+ (Switches from evaled Lua to a batched SCAN + DEL loop.)
574
565
 
575
- Empty Hash or Array should not be present in serialization result.
566
+ *Gleb Mazovetskiy*
576
567
 
577
- {a: []}.to_query # => ""
578
- {a: {}}.to_query # => ""
568
+ * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
569
+ size when compression is enabled (which is true by default). This patch
570
+ does not attempt to repair existing data: please manually flush the cache
571
+ to clear out the problematic entries.
579
572
 
580
- For more info see #14948.
573
+ *Godfrey Chan*
581
574
 
582
- *Bogdan Gusiev*
575
+ * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
583
576
 
584
- * Add `Digest::UUID::uuid_v3` and `Digest::UUID::uuid_v5` to support stable
585
- UUID fixtures on PostgreSQL.
577
+ URI.unescape("\xe3\x83\x90") # => "バ"
578
+ URI.unescape("%E3%83%90") # => "バ"
579
+ URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
586
580
 
587
- *Roderick van Domburg*
581
+ *Ashe Connor*, *Aaron Patterson*
588
582
 
589
- * Fixed `ActiveSupport::Duration#eql?` so that `1.second.eql?(1.second)` is
590
- true.
583
+ * Add `before?` and `after?` methods to `Date`, `DateTime`,
584
+ `Time`, and `TimeWithZone`.
591
585
 
592
- This fixes the current situation of:
586
+ *Nick Holden*
593
587
 
594
- 1.second.eql?(1.second) # => false
588
+ * `ActiveSupport::Inflector#ordinal` and `ActiveSupport::Inflector#ordinalize` now support
589
+ translations through I18n.
595
590
 
596
- `eql?` also requires that the other object is an `ActiveSupport::Duration`.
597
- This requirement makes `ActiveSupport::Duration`'s behavior consistent with
598
- the behavior of Ruby's numeric types:
591
+ # locale/fr.rb
599
592
 
600
- 1.eql?(1.0) # => false
601
- 1.0.eql?(1) # => false
593
+ {
594
+ fr: {
595
+ number: {
596
+ nth: {
597
+ ordinals: lambda do |_key, number:, **_options|
598
+ if number.to_i.abs == 1
599
+ 'er'
600
+ else
601
+ 'e'
602
+ end
603
+ end,
602
604
 
603
- 1.second.eql?(1) # => false (was true)
604
- 1.eql?(1.second) # => false
605
+ ordinalized: lambda do |_key, number:, **_options|
606
+ "#{number}#{ActiveSupport::Inflector.ordinal(number)}"
607
+ end
608
+ }
609
+ }
610
+ }
611
+ }
605
612
 
606
- { 1 => "foo", 1.0 => "bar" }
607
- # => { 1 => "foo", 1.0 => "bar" }
608
613
 
609
- { 1 => "foo", 1.second => "bar" }
610
- # now => { 1 => "foo", 1.second => "bar" }
611
- # was => { 1 => "bar" }
614
+ *Christian Blais*
612
615
 
613
- And though the behavior of these hasn't changed, for reference:
616
+ * Add `:private` option to ActiveSupport's `Module#delegate`
617
+ in order to delegate methods as private:
614
618
 
615
- 1 == 1.0 # => true
616
- 1.0 == 1 # => true
619
+ class User < ActiveRecord::Base
620
+ has_one :profile
621
+ delegate :date_of_birth, to: :profile, private: true
617
622
 
618
- 1 == 1.second # => true
619
- 1.second == 1 # => true
623
+ def age
624
+ Date.today.year - date_of_birth.year
625
+ end
626
+ end
620
627
 
621
- *Emily Dobervich*
628
+ # User.new.age # => 29
629
+ # User.new.date_of_birth
630
+ # => NoMethodError: private method `date_of_birth' called for #<User:0x00000008221340>
622
631
 
623
- * `ActiveSupport::SafeBuffer#prepend` acts like `String#prepend` and modifies
624
- instance in-place, returning self. `ActiveSupport::SafeBuffer#prepend!` is
625
- deprecated.
632
+ *Tomas Valent*
626
633
 
627
- *Pavel Pravosud*
634
+ * `String#truncate_bytes` to truncate a string to a maximum bytesize without
635
+ breaking multibyte characters or grapheme clusters like 👩‍👩‍👦‍👦.
628
636
 
629
- * `HashWithIndifferentAccess` better respects `#to_hash` on objects it
630
- receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept
631
- objects which respond to `#to_hash`, even if those objects are not hashes
632
- directly.
637
+ *Jeremy Daer*
633
638
 
634
- *Peter Jaros*
639
+ * `String#strip_heredoc` preserves frozenness.
635
640
 
636
- * Deprecate `Class#superclass_delegating_accessor`, use `Class#class_attribute` instead.
641
+ "foo".freeze.strip_heredoc.frozen? # => true
637
642
 
638
- *Akshay Vishnoi*
643
+ Fixes that frozen string literals would inadvertently become unfrozen:
639
644
 
640
- * Ensure classes which `include Enumerable` get `#to_json` in addition to
641
- `#as_json`.
645
+ # frozen_string_literal: true
642
646
 
643
- *Sammy Larbi*
647
+ foo = <<-MSG.strip_heredoc
648
+ la la la
649
+ MSG
644
650
 
645
- * Change the signature of `fetch_multi` to return a hash rather than an
646
- array. This makes it consistent with the output of `read_multi`.
651
+ foo.frozen? # => false !??
647
652
 
648
- *Parker Selbert*
653
+ *Jeremy Daer*
649
654
 
650
- * Introduce `Concern#class_methods` as a sleek alternative to clunky
651
- `module ClassMethods`. Add `Kernel#concern` to define at the toplevel
652
- without chunky `module Foo; extend ActiveSupport::Concern` boilerplate.
655
+ * Rails 6 requires Ruby 2.5.0 or newer.
653
656
 
654
- # app/models/concerns/authentication.rb
655
- concern :Authentication do
656
- included do
657
- after_create :generate_private_key
658
- end
657
+ *Jeremy Daer*, *Kasper Timm Hansen*
659
658
 
660
- class_methods do
661
- def authenticate(credentials)
662
- # ...
663
- end
664
- end
659
+ * Adds parallel testing to Rails.
665
660
 
666
- def generate_private_key
667
- # ...
668
- end
669
- end
661
+ Parallelize your test suite with forked processes or threads.
670
662
 
671
- # app/models/user.rb
672
- class User < ActiveRecord::Base
673
- include Authentication
674
- end
663
+ *Eileen M. Uchitelle*, *Aaron Patterson*
675
664
 
676
- *Jeremy Kemper*
677
665
 
678
- Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activesupport/CHANGELOG.md) for previous changes.
666
+ Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activesupport/CHANGELOG.md) for previous changes.