activesupport 4.2.11.3 → 5.2.8.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 (256) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +435 -403
  3. data/MIT-LICENSE +2 -2
  4. data/README.rdoc +4 -5
  5. data/lib/active_support/all.rb +5 -3
  6. data/lib/active_support/array_inquirer.rb +48 -0
  7. data/lib/active_support/backtrace_cleaner.rb +7 -5
  8. data/lib/active_support/benchmarkable.rb +6 -4
  9. data/lib/active_support/builder.rb +3 -1
  10. data/lib/active_support/cache/file_store.rb +41 -35
  11. data/lib/active_support/cache/mem_cache_store.rb +91 -91
  12. data/lib/active_support/cache/memory_store.rb +27 -30
  13. data/lib/active_support/cache/null_store.rb +7 -8
  14. data/lib/active_support/cache/redis_cache_store.rb +466 -0
  15. data/lib/active_support/cache/strategy/local_cache.rb +67 -34
  16. data/lib/active_support/cache/strategy/local_cache_middleware.rb +10 -9
  17. data/lib/active_support/cache.rb +287 -196
  18. data/lib/active_support/callbacks.rb +640 -590
  19. data/lib/active_support/concern.rb +11 -5
  20. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +35 -0
  21. data/lib/active_support/concurrency/share_lock.rb +227 -0
  22. data/lib/active_support/configurable.rb +8 -5
  23. data/lib/active_support/core_ext/array/access.rb +29 -1
  24. data/lib/active_support/core_ext/array/conversions.rb +22 -18
  25. data/lib/active_support/core_ext/array/extract_options.rb +2 -0
  26. data/lib/active_support/core_ext/array/grouping.rb +11 -18
  27. data/lib/active_support/core_ext/array/inquiry.rb +19 -0
  28. data/lib/active_support/core_ext/array/prepend_and_append.rb +5 -3
  29. data/lib/active_support/core_ext/array/wrap.rb +7 -4
  30. data/lib/active_support/core_ext/array.rb +9 -6
  31. data/lib/active_support/core_ext/benchmark.rb +3 -1
  32. data/lib/active_support/core_ext/big_decimal/conversions.rb +10 -12
  33. data/lib/active_support/core_ext/big_decimal.rb +3 -1
  34. data/lib/active_support/core_ext/class/attribute.rb +41 -22
  35. data/lib/active_support/core_ext/class/attribute_accessors.rb +3 -1
  36. data/lib/active_support/core_ext/class/subclasses.rb +20 -6
  37. data/lib/active_support/core_ext/class.rb +4 -3
  38. data/lib/active_support/core_ext/date/acts_like.rb +3 -1
  39. data/lib/active_support/core_ext/date/blank.rb +14 -0
  40. data/lib/active_support/core_ext/date/calculations.rb +11 -9
  41. data/lib/active_support/core_ext/date/conversions.rb +25 -23
  42. data/lib/active_support/core_ext/date/zones.rb +4 -2
  43. data/lib/active_support/core_ext/date.rb +6 -4
  44. data/lib/active_support/core_ext/date_and_time/calculations.rb +170 -58
  45. data/lib/active_support/core_ext/date_and_time/compatibility.rb +4 -3
  46. data/lib/active_support/core_ext/date_and_time/zones.rb +12 -12
  47. data/lib/active_support/core_ext/date_time/acts_like.rb +4 -2
  48. data/lib/active_support/core_ext/date_time/blank.rb +14 -0
  49. data/lib/active_support/core_ext/date_time/calculations.rb +36 -18
  50. data/lib/active_support/core_ext/date_time/compatibility.rb +8 -6
  51. data/lib/active_support/core_ext/date_time/conversions.rb +16 -12
  52. data/lib/active_support/core_ext/date_time.rb +7 -5
  53. data/lib/active_support/core_ext/digest/uuid.rb +7 -5
  54. data/lib/active_support/core_ext/digest.rb +3 -0
  55. data/lib/active_support/core_ext/enumerable.rb +101 -33
  56. data/lib/active_support/core_ext/file/atomic.rb +38 -31
  57. data/lib/active_support/core_ext/file.rb +3 -1
  58. data/lib/active_support/core_ext/hash/compact.rb +14 -9
  59. data/lib/active_support/core_ext/hash/conversions.rb +62 -41
  60. data/lib/active_support/core_ext/hash/deep_merge.rb +9 -13
  61. data/lib/active_support/core_ext/hash/except.rb +11 -8
  62. data/lib/active_support/core_ext/hash/indifferent_access.rb +4 -3
  63. data/lib/active_support/core_ext/hash/keys.rb +33 -27
  64. data/lib/active_support/core_ext/hash/reverse_merge.rb +5 -2
  65. data/lib/active_support/core_ext/hash/slice.rb +8 -8
  66. data/lib/active_support/core_ext/hash/transform_values.rb +14 -5
  67. data/lib/active_support/core_ext/hash.rb +11 -9
  68. data/lib/active_support/core_ext/integer/inflections.rb +3 -1
  69. data/lib/active_support/core_ext/integer/multiple.rb +2 -0
  70. data/lib/active_support/core_ext/integer/time.rb +11 -18
  71. data/lib/active_support/core_ext/integer.rb +5 -3
  72. data/lib/active_support/core_ext/kernel/agnostics.rb +2 -0
  73. data/lib/active_support/core_ext/kernel/concern.rb +5 -1
  74. data/lib/active_support/core_ext/kernel/reporting.rb +4 -84
  75. data/lib/active_support/core_ext/kernel/singleton_class.rb +2 -0
  76. data/lib/active_support/core_ext/kernel.rb +6 -5
  77. data/lib/active_support/core_ext/load_error.rb +3 -22
  78. data/lib/active_support/core_ext/marshal.rb +8 -8
  79. data/lib/active_support/core_ext/module/aliasing.rb +6 -44
  80. data/lib/active_support/core_ext/module/anonymous.rb +12 -1
  81. data/lib/active_support/core_ext/module/attr_internal.rb +8 -9
  82. data/lib/active_support/core_ext/module/attribute_accessors.rb +43 -40
  83. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +150 -0
  84. data/lib/active_support/core_ext/module/concerning.rb +11 -12
  85. data/lib/active_support/core_ext/module/delegation.rb +98 -36
  86. data/lib/active_support/core_ext/module/deprecation.rb +4 -2
  87. data/lib/active_support/core_ext/module/introspection.rb +9 -9
  88. data/lib/active_support/core_ext/module/reachable.rb +5 -2
  89. data/lib/active_support/core_ext/module/redefine_method.rb +49 -0
  90. data/lib/active_support/core_ext/module/remove_method.rb +8 -3
  91. data/lib/active_support/core_ext/module.rb +14 -11
  92. data/lib/active_support/core_ext/name_error.rb +22 -2
  93. data/lib/active_support/core_ext/numeric/bytes.rb +22 -0
  94. data/lib/active_support/core_ext/numeric/conversions.rb +78 -81
  95. data/lib/active_support/core_ext/numeric/inquiry.rb +28 -0
  96. data/lib/active_support/core_ext/numeric/time.rb +35 -23
  97. data/lib/active_support/core_ext/numeric.rb +6 -3
  98. data/lib/active_support/core_ext/object/acts_like.rb +12 -1
  99. data/lib/active_support/core_ext/object/blank.rb +27 -2
  100. data/lib/active_support/core_ext/object/conversions.rb +6 -4
  101. data/lib/active_support/core_ext/object/deep_dup.rb +13 -4
  102. data/lib/active_support/core_ext/object/duplicable.rb +41 -14
  103. data/lib/active_support/core_ext/object/inclusion.rb +5 -3
  104. data/lib/active_support/core_ext/object/instance_variables.rb +3 -1
  105. data/lib/active_support/core_ext/object/json.rb +49 -19
  106. data/lib/active_support/core_ext/object/to_param.rb +3 -1
  107. data/lib/active_support/core_ext/object/to_query.rb +10 -5
  108. data/lib/active_support/core_ext/object/try.rb +69 -21
  109. data/lib/active_support/core_ext/object/with_options.rb +16 -3
  110. data/lib/active_support/core_ext/object.rb +14 -13
  111. data/lib/active_support/core_ext/range/compare_range.rb +61 -0
  112. data/lib/active_support/core_ext/range/conversions.rb +27 -7
  113. data/lib/active_support/core_ext/range/each.rb +19 -17
  114. data/lib/active_support/core_ext/range/include_range.rb +2 -22
  115. data/lib/active_support/core_ext/range/include_time_with_zone.rb +23 -0
  116. data/lib/active_support/core_ext/range/overlaps.rb +2 -0
  117. data/lib/active_support/core_ext/range.rb +7 -4
  118. data/lib/active_support/core_ext/regexp.rb +6 -0
  119. data/lib/active_support/core_ext/securerandom.rb +25 -0
  120. data/lib/active_support/core_ext/string/access.rb +8 -6
  121. data/lib/active_support/core_ext/string/behavior.rb +3 -1
  122. data/lib/active_support/core_ext/string/conversions.rb +7 -4
  123. data/lib/active_support/core_ext/string/exclude.rb +2 -0
  124. data/lib/active_support/core_ext/string/filters.rb +6 -5
  125. data/lib/active_support/core_ext/string/indent.rb +6 -4
  126. data/lib/active_support/core_ext/string/inflections.rb +61 -24
  127. data/lib/active_support/core_ext/string/inquiry.rb +3 -1
  128. data/lib/active_support/core_ext/string/multibyte.rb +15 -7
  129. data/lib/active_support/core_ext/string/output_safety.rb +62 -38
  130. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -0
  131. data/lib/active_support/core_ext/string/strip.rb +4 -5
  132. data/lib/active_support/core_ext/string/zones.rb +4 -2
  133. data/lib/active_support/core_ext/string.rb +15 -13
  134. data/lib/active_support/core_ext/time/acts_like.rb +3 -1
  135. data/lib/active_support/core_ext/time/calculations.rb +85 -51
  136. data/lib/active_support/core_ext/time/compatibility.rb +4 -2
  137. data/lib/active_support/core_ext/time/conversions.rb +20 -13
  138. data/lib/active_support/core_ext/time/zones.rb +41 -7
  139. data/lib/active_support/core_ext/time.rb +7 -6
  140. data/lib/active_support/core_ext/uri.rb +6 -8
  141. data/lib/active_support/core_ext.rb +3 -1
  142. data/lib/active_support/current_attributes.rb +195 -0
  143. data/lib/active_support/dependencies/autoload.rb +2 -0
  144. data/lib/active_support/dependencies/interlock.rb +57 -0
  145. data/lib/active_support/dependencies.rb +152 -161
  146. data/lib/active_support/deprecation/behaviors.rb +44 -11
  147. data/lib/active_support/deprecation/constant_accessor.rb +52 -0
  148. data/lib/active_support/deprecation/instance_delegator.rb +17 -2
  149. data/lib/active_support/deprecation/method_wrappers.rb +66 -20
  150. data/lib/active_support/deprecation/proxy_wrappers.rb +56 -28
  151. data/lib/active_support/deprecation/reporting.rb +32 -12
  152. data/lib/active_support/deprecation.rb +12 -9
  153. data/lib/active_support/descendants_tracker.rb +2 -0
  154. data/lib/active_support/digest.rb +20 -0
  155. data/lib/active_support/duration/iso8601_parser.rb +125 -0
  156. data/lib/active_support/duration/iso8601_serializer.rb +55 -0
  157. data/lib/active_support/duration.rb +314 -38
  158. data/lib/active_support/encrypted_configuration.rb +49 -0
  159. data/lib/active_support/encrypted_file.rb +99 -0
  160. data/lib/active_support/evented_file_update_checker.rb +205 -0
  161. data/lib/active_support/execution_wrapper.rb +131 -0
  162. data/lib/active_support/executor.rb +8 -0
  163. data/lib/active_support/file_update_checker.rb +63 -37
  164. data/lib/active_support/gem_version.rb +6 -4
  165. data/lib/active_support/gzip.rb +7 -5
  166. data/lib/active_support/hash_with_indifferent_access.rb +123 -28
  167. data/lib/active_support/i18n.rb +8 -6
  168. data/lib/active_support/i18n_railtie.rb +37 -13
  169. data/lib/active_support/inflections.rb +13 -11
  170. data/lib/active_support/inflector/inflections.rb +61 -12
  171. data/lib/active_support/inflector/methods.rb +163 -136
  172. data/lib/active_support/inflector/transliterate.rb +48 -27
  173. data/lib/active_support/inflector.rb +7 -5
  174. data/lib/active_support/json/decoding.rb +16 -13
  175. data/lib/active_support/json/encoding.rb +11 -58
  176. data/lib/active_support/json.rb +4 -2
  177. data/lib/active_support/key_generator.rb +25 -25
  178. data/lib/active_support/lazy_load_hooks.rb +50 -20
  179. data/lib/active_support/locale/en.yml +2 -0
  180. data/lib/active_support/log_subscriber/test_helper.rb +14 -12
  181. data/lib/active_support/log_subscriber.rb +13 -10
  182. data/lib/active_support/logger.rb +8 -7
  183. data/lib/active_support/logger_silence.rb +6 -4
  184. data/lib/active_support/logger_thread_safe_level.rb +7 -5
  185. data/lib/active_support/message_encryptor.rb +168 -53
  186. data/lib/active_support/message_verifier.rb +150 -17
  187. data/lib/active_support/messages/metadata.rb +71 -0
  188. data/lib/active_support/messages/rotation_configuration.rb +22 -0
  189. data/lib/active_support/messages/rotator.rb +56 -0
  190. data/lib/active_support/multibyte/chars.rb +36 -23
  191. data/lib/active_support/multibyte/unicode.rb +100 -96
  192. data/lib/active_support/multibyte.rb +4 -2
  193. data/lib/active_support/notifications/fanout.rb +11 -9
  194. data/lib/active_support/notifications/instrumenter.rb +27 -7
  195. data/lib/active_support/notifications.rb +11 -7
  196. data/lib/active_support/number_helper/number_converter.rb +13 -11
  197. data/lib/active_support/number_helper/number_to_currency_converter.rb +9 -9
  198. data/lib/active_support/number_helper/number_to_delimited_converter.rb +9 -3
  199. data/lib/active_support/number_helper/number_to_human_converter.rb +11 -9
  200. data/lib/active_support/number_helper/number_to_human_size_converter.rb +9 -8
  201. data/lib/active_support/number_helper/number_to_percentage_converter.rb +3 -1
  202. data/lib/active_support/number_helper/number_to_phone_converter.rb +13 -4
  203. data/lib/active_support/number_helper/number_to_rounded_converter.rb +23 -56
  204. data/lib/active_support/number_helper/rounding_helper.rb +66 -0
  205. data/lib/active_support/number_helper.rb +94 -68
  206. data/lib/active_support/option_merger.rb +3 -1
  207. data/lib/active_support/ordered_hash.rb +6 -4
  208. data/lib/active_support/ordered_options.rb +23 -5
  209. data/lib/active_support/per_thread_registry.rb +9 -4
  210. data/lib/active_support/proxy_object.rb +2 -0
  211. data/lib/active_support/rails.rb +16 -8
  212. data/lib/active_support/railtie.rb +43 -9
  213. data/lib/active_support/reloader.rb +131 -0
  214. data/lib/active_support/rescuable.rb +108 -53
  215. data/lib/active_support/security_utils.rb +15 -11
  216. data/lib/active_support/string_inquirer.rb +11 -3
  217. data/lib/active_support/subscriber.rb +21 -16
  218. data/lib/active_support/tagged_logging.rb +14 -11
  219. data/lib/active_support/test_case.rb +19 -47
  220. data/lib/active_support/testing/assertions.rb +137 -20
  221. data/lib/active_support/testing/autorun.rb +4 -2
  222. data/lib/active_support/testing/constant_lookup.rb +2 -1
  223. data/lib/active_support/testing/declarative.rb +3 -1
  224. data/lib/active_support/testing/deprecation.rb +14 -10
  225. data/lib/active_support/testing/file_fixtures.rb +36 -0
  226. data/lib/active_support/testing/isolation.rb +34 -25
  227. data/lib/active_support/testing/method_call_assertions.rb +43 -0
  228. data/lib/active_support/testing/setup_and_teardown.rb +13 -8
  229. data/lib/active_support/testing/stream.rb +44 -0
  230. data/lib/active_support/testing/tagged_logging.rb +3 -1
  231. data/lib/active_support/testing/time_helpers.rb +81 -15
  232. data/lib/active_support/time.rb +14 -12
  233. data/lib/active_support/time_with_zone.rb +169 -39
  234. data/lib/active_support/values/time_zone.rb +196 -61
  235. data/lib/active_support/values/unicode_tables.dat +0 -0
  236. data/lib/active_support/version.rb +3 -1
  237. data/lib/active_support/xml_mini/jdom.rb +116 -114
  238. data/lib/active_support/xml_mini/libxml.rb +16 -13
  239. data/lib/active_support/xml_mini/libxmlsax.rb +15 -14
  240. data/lib/active_support/xml_mini/nokogiri.rb +14 -12
  241. data/lib/active_support/xml_mini/nokogirisax.rb +14 -13
  242. data/lib/active_support/xml_mini/rexml.rb +11 -9
  243. data/lib/active_support/xml_mini.rb +37 -37
  244. data/lib/active_support.rb +12 -11
  245. metadata +57 -27
  246. data/lib/active_support/concurrency/latch.rb +0 -27
  247. data/lib/active_support/core_ext/big_decimal/yaml_conversions.rb +0 -16
  248. data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -45
  249. data/lib/active_support/core_ext/date_time/zones.rb +0 -6
  250. data/lib/active_support/core_ext/kernel/debugger.rb +0 -10
  251. data/lib/active_support/core_ext/module/method_transplanting.rb +0 -13
  252. data/lib/active_support/core_ext/module/qualified_const.rb +0 -52
  253. data/lib/active_support/core_ext/object/itself.rb +0 -15
  254. data/lib/active_support/core_ext/struct.rb +0 -6
  255. data/lib/active_support/core_ext/thread.rb +0 -86
  256. data/lib/active_support/core_ext/time/marshal.rb +0 -30
data/CHANGELOG.md CHANGED
@@ -1,688 +1,720 @@
1
- ## Rails 4.2.11.3 (May 15, 2020) ##
1
+ ## Rails 5.2.8.1 (July 12, 2022) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 4.2.11.2 (May 15, 2020) ##
6
+ ## Rails 5.2.8 (May 09, 2022) ##
7
7
 
8
8
  * No changes.
9
9
 
10
10
 
11
- ## Rails 4.2.11.1 (March 11, 2019) ##
11
+ ## Rails 5.2.7.1 (April 26, 2022) ##
12
12
 
13
- * No changes.
13
+ * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
14
14
 
15
+ Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
16
+ in names of tags and names of attributes, following the specification of XML.
15
17
 
16
- ## Rails 4.2.11 (November 27, 2018) ##
18
+ *Álvaro Martín Fraguas*
17
19
 
18
- * No changes.
19
20
 
21
+ ## Rails 5.2.7 (March 10, 2022) ##
20
22
 
21
- ## Rails 4.2.10 (September 27, 2017) ##
23
+ * Restore support to Ruby 2.2.
22
24
 
23
- * No changes.
25
+ *ojab*
24
26
 
25
27
 
26
- ## Rails 4.2.9 (June 26, 2017) ##
28
+ ## Rails 5.2.6.3 (March 08, 2022) ##
27
29
 
28
- * Fixed bug in `DateAndTime::Compatibility#to_time` that caused it to
29
- raise `RuntimeError: can't modify frozen Time` when called on any frozen `Time`.
30
- Properly pass through the frozen `Time` or `ActiveSupport::TimeWithZone` object
31
- when calling `#to_time`.
30
+ * No changes.
32
31
 
33
- *Kevin McPhillips* & *Andrew White*
34
32
 
35
- * Restore the return type of `DateTime#utc`
33
+ ## Rails 5.2.6.2 (February 11, 2022) ##
36
34
 
37
- In Rails 5.0 the return type of `DateTime#utc` was changed to `Time` to be
38
- consistent with the new `DateTime#localtime` method. When these changes were
39
- backported in #27553 this inadvertently changed the return type in a patcn
40
- release. Since `DateTime#localtime` was new in Rails 4.2.8 it's okay to
41
- restore the return type of `DateTime#utc` but keep `DateTime#localtime` as
42
- returning `Time` without breaking backwards compatibility.
35
+ * Fix Reloader method signature to work with the new Executor signature
43
36
 
44
- *Andrew White*
45
37
 
46
- * In Core Extensions, make `MarshalWithAutoloading#load` pass through the second, optional
47
- argument for `Marshal#load( source [, proc] )`. This way we don't have to do
48
- `Marshal.method(:load).super_method.call(sourse, proc)` just to be able to pass a proc.
38
+ ## Rails 5.2.6.1 (February 11, 2022) ##
49
39
 
50
- *Jeff Latz*
40
+ * No changes.
51
41
 
52
- * Cache `ActiveSupport::TimeWithZone#to_datetime` before freezing.
53
42
 
54
- *Adam Rice*
43
+ ## Rails 5.2.6 (May 05, 2021) ##
55
44
 
56
- * `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as
57
- `Time.now` and `Date.today`.
45
+ * No changes.
58
46
 
59
- *Yuki Nishijima*
60
47
 
48
+ ## Rails 5.2.5 (March 26, 2021) ##
61
49
 
62
- ## Rails 4.2.8 (February 21, 2017) ##
50
+ * No changes.
63
51
 
64
- * Make `getlocal` and `getutc` always return instances of `Time` for
65
- `ActiveSupport::TimeWithZone` and `DateTime`. This eliminates a possible
66
- stack level too deep error in `to_time` where `ActiveSupport::TimeWithZone`
67
- was wrapping a `DateTime` instance. As a consequence of this the internal
68
- time value in `ActiveSupport::TimeWithZone` is now always an instance of
69
- `Time` in the UTC timezone, whether that's as the UTC time directly or
70
- a representation of the local time in the timezone. There should be no
71
- consequences of this internal change and if there are it's a bug due to
72
- leaky abstractions.
73
52
 
74
- *Andrew White*
53
+ ## Rails 5.2.4.6 (May 05, 2021) ##
75
54
 
76
- * Add `DateTime#subsec` to return the fraction of a second as a `Rational`.
55
+ * No changes.
77
56
 
78
- *Andrew White*
79
57
 
80
- * Add additional aliases for `DateTime#utc` to mirror the ones on
81
- `ActiveSupport::TimeWithZone` and `Time`.
58
+ ## Rails 5.2.4.5 (February 10, 2021) ##
82
59
 
83
- *Andrew White*
60
+ * No changes.
84
61
 
85
- * Add `DateTime#localtime` to return an instance of `Time` in the system's
86
- local timezone. Also aliased to `getlocal`.
87
62
 
88
- *Andrew White*, *Yuichiro Kaneko*
63
+ ## Rails 5.2.4.4 (September 09, 2020) ##
89
64
 
90
- * Add `Time#sec_fraction` to return the fraction of a second as a `Rational`.
65
+ * No changes.
91
66
 
92
- *Andrew White*
93
67
 
94
- * Add `ActiveSupport.to_time_preserves_timezone` config option to control
95
- how `to_time` handles timezones. In Ruby 2.4+ the behavior will change
96
- from converting to the local system timezone, to preserving the timezone
97
- of the receiver. This config option defaults to false so that apps made
98
- with earlier versions of Rails are not affected when upgrading, e.g:
68
+ ## Rails 5.2.4.3 (May 18, 2020) ##
99
69
 
100
- >> ENV['TZ'] = 'US/Eastern'
70
+ * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
101
71
 
102
- >> "2016-04-23T10:23:12.000Z".to_time
103
- => "2016-04-23T06:23:12.000-04:00"
72
+ * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
104
73
 
105
- >> ActiveSupport.to_time_preserves_timezone = true
74
+ ## Rails 5.2.4.2 (March 19, 2020) ##
106
75
 
107
- >> "2016-04-23T10:23:12.000Z".to_time
108
- => "2016-04-23T10:23:12.000Z"
76
+ * No changes.
109
77
 
110
- Fixes #24617.
111
78
 
112
- *Andrew White*
79
+ ## Rails 5.2.4.1 (December 18, 2019) ##
113
80
 
114
- * Add `init_with` to `ActiveSupport::TimeWithZone` and `ActiveSupport::TimeZone`
81
+ * No changes.
115
82
 
116
- It is helpful to be able to run apps concurrently written in successive
117
- versions of Rails to aid migration, e.g. run Rails 4.2 and 5.0 variants
118
- of your application at the same time to carry out A/B testing.
119
83
 
120
- To do this serialization formats need to be cross compatible and the
121
- change in 3aa26cf didn't meet this criteria because the Psych loader
122
- checks for the existence of `init_with` before setting the instance
123
- variables and the wrapping behavior of `ActiveSupport::TimeWithZone`
124
- tries to see if the `Time` instance responds to `init_with` before the
125
- `@time` variable is set.
84
+ ## Rails 5.2.4 (November 27, 2019) ##
126
85
 
127
- To fix this we backported just the `init_with` behavior from the change
128
- in 3aa26cf. If the revived instance is then written out to YAML again
129
- it will revert to the default Rails 4.2 behavior of converting it to
130
- a UTC timestamp string.
86
+ * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
131
87
 
132
- Fixes #26296.
88
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
89
+ to make log level local to Ruby Fibers in addition to Threads.
133
90
 
134
- *Andrew White*
91
+ Example:
135
92
 
136
- * Fix `ActiveSupport::TimeWithZone#in` across DST boundaries.
93
+ logger = ActiveSupport::Logger.new(STDOUT)
94
+ logger.level = 1
95
+ p "Main is debug? #{logger.debug?}"
137
96
 
138
- Previously calls to `in` were being sent to the non-DST aware
139
- method `Time#since` via `method_missing`. It is now aliased to
140
- the DST aware `ActiveSupport::TimeWithZone#since` which handles
141
- transitions across DST boundaries, e.g:
97
+ Fiber.new {
98
+ logger.local_level = 0
99
+ p "Thread is debug? #{logger.debug?}"
100
+ }.resume
142
101
 
143
- Time.zone = "US/Eastern"
102
+ p "Main is debug? #{logger.debug?}"
103
+
104
+ Before:
144
105
 
145
- t = Time.zone.local(2016,11,6,1)
146
- # => Sun, 06 Nov 2016 01:00:00 EDT -05:00
106
+ Main is debug? false
107
+ Thread is debug? true
108
+ Main is debug? true
147
109
 
148
- t.in(1.hour)
149
- # => Sun, 06 Nov 2016 01:00:00 EST -05:00
110
+ After:
150
111
 
151
- Fixes #26580.
112
+ Main is debug? false
113
+ Thread is debug? true
114
+ Main is debug? false
152
115
 
153
- *Thomas Balthazar*
116
+ *Alexander Varnin*
154
117
 
155
118
 
156
- ## Rails 4.2.7 (July 12, 2016) ##
119
+ ## Rails 5.2.3 (March 27, 2019) ##
157
120
 
158
- * Fixed `ActiveSupport::Logger.broadcast` so that calls to `#silence` now
159
- properly delegate to all loggers. Silencing now properly suppresses logging
160
- to both the log and the console.
121
+ * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
161
122
 
162
- *Kevin McPhillips*
123
+ `assoc` can now be called with either a string or a symbol.
163
124
 
164
- * Backported `ActiveSupport::LoggerThreadSafeLevel`. Assigning the
165
- `Rails.logger.level` is now thread safe.
125
+ *Stefan Schüßler*
166
126
 
167
- *Kevin McPhillips*
127
+ * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
168
128
 
169
- * Fixed a problem with ActiveSupport::SafeBuffer.titleize calling capitalize
170
- on nil.
129
+ *Keenan Brock*
171
130
 
172
- *Brian McManus*
131
+ * Allow Range#=== and Range#cover? on Range
173
132
 
174
- * Time zones: Ensure that the UTC offset reflects DST changes that occurred
175
- since the app started. Removes UTC offset caching, reducing performance,
176
- but this is still relatively quick and isn't in any hot paths.
133
+ `Range#cover?` can now accept a range argument like `Range#include?` and
134
+ `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
135
+ into a new file, with these two methods.
177
136
 
178
- *Alexey Shein*
137
+ *utilum*
179
138
 
180
- * Prevent `Marshal.load` from looping infinitely when trying to autoload a constant
181
- which resolves to a different name.
139
+ * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
182
140
 
183
- *Olek Janiszewski*
141
+ *Mark J. Titorenko*, *Vlad Bokov*
184
142
 
185
143
 
186
- ## Rails 4.2.6 (March 07, 2016) ##
144
+ ## Rails 5.2.2.1 (March 11, 2019) ##
187
145
 
188
146
  * No changes.
189
147
 
190
148
 
191
- ## Rails 4.2.5.2 (February 26, 2016) ##
149
+ ## Rails 5.2.2 (December 04, 2018) ##
192
150
 
193
- * No changes.
151
+ * Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
152
+ would not act as alias for `#symbolize_keys`.
194
153
 
154
+ *Nick Weiland*
195
155
 
196
- ## Rails 4.2.5.1 (January 25, 2015) ##
156
+ * Improve the logic that detects non-autoloaded constants.
197
157
 
198
- * No changes.
158
+ *Jan Habermann*, *Xavier Noria*
199
159
 
160
+ * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
200
161
 
201
- ## Rails 4.2.5 (November 12, 2015) ##
162
+ URI.unescape("\xe3\x83\x90") # => "バ"
163
+ URI.unescape("%E3%83%90") # => "バ"
164
+ URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
202
165
 
203
- * Fix `TimeWithZone#eql?` to properly handle `TimeWithZone` created from `DateTime`:
204
- twz = DateTime.now.in_time_zone
205
- twz.eql?(twz.dup) => true
166
+ *Ashe Connor*, *Aaron Patterson*
206
167
 
207
- Fixes #14178.
208
168
 
209
- *Roque Pinel*
169
+ ## Rails 5.2.1.1 (November 27, 2018) ##
210
170
 
211
- * Handle invalid UTF-8 characters in `MessageVerifier.verify`.
171
+ * No changes.
212
172
 
213
- *Roque Pinel*, *Grey Baker*
214
173
 
174
+ ## Rails 5.2.1 (August 07, 2018) ##
215
175
 
216
- ## Rails 4.2.4 (August 24, 2015) ##
176
+ * Redis cache store: `delete_matched` no longer blocks the Redis server.
177
+ (Switches from evaled Lua to a batched SCAN + DEL loop.)
217
178
 
218
- * Fix a `SystemStackError` when encoding an `Enumerable` with `json` gem and
219
- with the Active Support JSON encoder loaded.
179
+ *Gleb Mazovetskiy*
220
180
 
221
- Fixes #20775.
181
+ * Fix bug where `ActiveSupport::Timezone.all` would fail when tzinfo data for
182
+ any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
222
183
 
223
- *Sammy Larbi*, *Prathamesh Sonpatki*
184
+ *Dominik Sander*
224
185
 
225
- * Fix not calling `#default` on `HashWithIndifferentAcess#to_hash` when only
226
- `default_proc` is set, which could raise.
186
+ * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
187
+ size when compression is enabled (which is true by default). This patch
188
+ does not attempt to repair existing data: please manually flush the cache
189
+ to clear out the problematic entries.
227
190
 
228
- *Simon Eskildsen*
191
+ *Godfrey Chan*
229
192
 
230
- * Fix setting `default_proc` on `HashWithIndifferentAccess#dup`
193
+ * Fix `ActiveSupport::Cache#read_multi` bug with local cache enabled that was
194
+ returning instances of `ActiveSupport::Cache::Entry` instead of the raw values.
231
195
 
232
- *Simon Eskildsen*
196
+ *Jason Lee*
233
197
 
234
198
 
235
- ## Rails 4.2.3 (June 25, 2015) ##
199
+ ## Rails 5.2.0 (April 09, 2018) ##
236
200
 
237
- * Fix a range of values for parameters of the Time#change
201
+ * Caching: MemCache and Redis `read_multi` and `fetch_multi` speedup.
202
+ Read from the local in-memory cache before consulting the backend.
238
203
 
239
- *Nikolay Kondratyev*
204
+ *Gabriel Sobrinho*
240
205
 
241
- * Add some missing `require 'active_support/deprecation'`
206
+ * Return all mappings for a timezone identifier in `country_zones`.
242
207
 
243
- *Akira Matsuda*
208
+ Some timezones like `Europe/London` have multiple mappings in
209
+ `ActiveSupport::TimeZone::MAPPING` so return all of them instead
210
+ of the first one found by using `Hash#value`. e.g:
244
211
 
212
+ # Before
213
+ ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"]
245
214
 
246
- ## Rails 4.2.2 (June 16, 2015) ##
215
+ # After
216
+ ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"]
247
217
 
248
- * Fix XSS vulnerability in `ActiveSupport::JSON.encode` method.
218
+ Fixes #31668.
249
219
 
250
- CVE-2015-3226.
220
+ *Andrew White*
251
221
 
252
- *Rafael Mendonça França*
222
+ * Add support for connection pooling on RedisCacheStore.
253
223
 
254
- * Fix denial of service vulnerability in the XML processing.
224
+ *fatkodima*
255
225
 
256
- CVE-2015-3227.
226
+ * Support hash as first argument in `assert_difference`. This allows to specify multiple
227
+ numeric differences in the same assertion.
257
228
 
258
- *Aaron Patterson*
229
+ assert_difference ->{ Article.count } => 1, ->{ Post.count } => 2
259
230
 
231
+ *Julien Meichelbeck*
260
232
 
261
- ## Rails 4.2.1 (March 19, 2015) ##
233
+ * Add missing instrumentation for `read_multi` in `ActiveSupport::Cache::Store`.
262
234
 
263
- * Fixed a problem where String#truncate_words would get stuck with a complex
264
- string.
235
+ *Ignatius Reza Lesmana*
265
236
 
266
- *Henrik Nygren*
237
+ * `assert_changes` will always assert that the expression changes,
238
+ regardless of `from:` and `to:` argument combinations.
267
239
 
268
- * Fixed a roundtrip problem with AS::SafeBuffer where primitive-like strings
269
- will be dumped as primitives:
240
+ *Daniel Ma*
270
241
 
271
- Before:
242
+ * Use SHA-1 to generate non-sensitive digests, such as the ETag header.
272
243
 
273
- YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
274
- YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
275
- YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
276
- YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
277
- YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
244
+ Enabled by default for new apps; upgrading apps can opt in by setting
245
+ `config.active_support.use_sha1_digests = true`.
278
246
 
279
- After:
247
+ *Dmitri Dolguikh*, *Eugene Kenny*
280
248
 
281
- YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
282
- YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
283
- YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
284
- YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
285
- YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
249
+ * Changed default behaviour of `ActiveSupport::SecurityUtils.secure_compare`,
250
+ to make it not leak length information even for variable length string.
286
251
 
287
- *Godfrey Chan*
252
+ Renamed old `ActiveSupport::SecurityUtils.secure_compare` to `fixed_length_secure_compare`,
253
+ and started raising `ArgumentError` in case of length mismatch of passed strings.
288
254
 
289
- * Replace fixed `:en` with `I18n.default_locale` in `Duration#inspect`.
255
+ *Vipul A M*
290
256
 
291
- *Dominik Masur*
257
+ * Make `ActiveSupport::TimeZone.all` return only time zones that are in
258
+ `ActiveSupport::TimeZone::MAPPING`.
292
259
 
293
- * Add missing time zone definitions for Russian Federation and sync them
294
- with `zone.tab` file from tzdata version 2014j (latest).
260
+ Fixes #7245.
295
261
 
296
- *Andrey Novikov*
262
+ *Chris LaRose*
297
263
 
264
+ * MemCacheStore: Support expiring counters.
298
265
 
299
- ## Rails 4.2.0 (December 20, 2014) ##
266
+ Pass `expires_in: [seconds]` to `#increment` and `#decrement` options
267
+ to set the Memcached TTL (time-to-live) if the counter doesn't exist.
268
+ If the counter exists, Memcached doesn't extend its expiry when it's
269
+ incremented or decremented.
300
270
 
301
- * The decorated `load` and `require` methods are now kept private.
271
+ ```
272
+ Rails.cache.increment("my_counter", 1, expires_in: 2.minutes)
273
+ ```
302
274
 
303
- Fixes #17553.
275
+ *Takumasa Ochi*
304
276
 
305
- *Xavier Noria*
277
+ * Handle `TZInfo::AmbiguousTime` errors.
306
278
 
307
- * `String#remove` and `String#remove!` accept multiple arguments.
279
+ Make `ActiveSupport::TimeWithZone` match Ruby's handling of ambiguous
280
+ times by choosing the later period, e.g.
308
281
 
309
- *Pavel Pravosud*
282
+ Ruby:
283
+ ```
284
+ ENV["TZ"] = "Europe/Moscow"
285
+ Time.local(2014, 10, 26, 1, 0, 0) # => 2014-10-26 01:00:00 +0300
286
+ ```
310
287
 
311
- * `TimeWithZone#strftime` now delegates every directive to `Time#strftime` except for '%Z',
312
- it also now correctly handles escaped '%' characters placed just before time zone related directives.
288
+ Before:
289
+ ```
290
+ >> "2014-10-26 01:00:00".in_time_zone("Moscow")
291
+ TZInfo::AmbiguousTime: 26/10/2014 01:00 is an ambiguous local time.
292
+ ```
313
293
 
314
- *Pablo Herrero*
294
+ After:
295
+ ```
296
+ >> "2014-10-26 01:00:00".in_time_zone("Moscow")
297
+ => Sun, 26 Oct 2014 01:00:00 MSK +03:00
298
+ ```
315
299
 
316
- * Corrected `Inflector#underscore` handling of multiple successive acroynms.
300
+ Fixes #17395.
317
301
 
318
- *James Le Cuirot*
302
+ *Andrew White*
319
303
 
320
- * Delegation now works with ruby reserved words passed to `:to` option.
304
+ * Redis cache store.
321
305
 
322
- Fixes #16956.
306
+ ```
307
+ # Defaults to `redis://localhost:6379/0`. Only use for dev/test.
308
+ config.cache_store = :redis_cache_store
323
309
 
324
- *Agis Anastasopoulos*
310
+ # Supports all common cache store options (:namespace, :compress,
311
+ # :compress_threshold, :expires_in, :race_condition_ttl) and all
312
+ # Redis options.
313
+ cache_password = Rails.application.secrets.redis_cache_password
314
+ config.cache_store = :redis_cache_store, driver: :hiredis,
315
+ namespace: 'myapp-cache', compress: true, timeout: 1,
316
+ url: "redis://:#{cache_password}@myapp-cache-1:6379/0"
325
317
 
326
- * Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`.
318
+ # Supports Redis::Distributed with multiple hosts
319
+ config.cache_store = :redis_cache_store, driver: :hiredis
320
+ namespace: 'myapp-cache', compress: true,
321
+ url: %w[
322
+ redis://myapp-cache-1:6379/0
323
+ redis://myapp-cache-1:6380/0
324
+ redis://myapp-cache-2:6379/0
325
+ redis://myapp-cache-2:6380/0
326
+ redis://myapp-cache-3:6379/0
327
+ redis://myapp-cache-3:6380/0
328
+ ]
327
329
 
328
- Currently, the following returns `false`, contrary to expectation:
330
+ # Or pass a builder block
331
+ config.cache_store = :redis_cache_store,
332
+ namespace: 'myapp-cache', compress: true,
333
+ redis: -> { Redis.new … }
334
+ ```
329
335
 
330
- 1.minute.eql?(1.minute)
336
+ Deployment note: Take care to use a *dedicated Redis cache* rather
337
+ than pointing this at your existing Redis server. It won't cope well
338
+ with mixed usage patterns and it won't expire cache entries by default.
331
339
 
332
- Adding method `#eql?` will make this behave like expected. Method `#eql?` is
333
- just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their
334
- parts may be different though.
340
+ Redis cache server setup guide: https://redis.io/topics/lru-cache
335
341
 
336
- 1.minute.eql?(60.seconds) # => true
337
- 1.minute.eql?(60) # => false
342
+ *Jeremy Daer*
338
343
 
339
- *Joost Lubach*
344
+ * Cache: Enable compression by default for values > 1kB.
340
345
 
341
- * `Time#change` can now change nanoseconds (`:nsec`) as a higher-precision
342
- alternative to microseconds (`:usec`).
346
+ Compression has long been available, but opt-in and at a 16kB threshold.
347
+ It wasn't enabled by default due to CPU cost. Today it's cheap and typical
348
+ cache data is eminently compressible, such as HTML or JSON fragments.
349
+ Compression dramatically reduces Memcached/Redis mem usage, which means
350
+ the same cache servers can store more data, which means higher hit rates.
343
351
 
344
- *Agis Anastasooulos*
352
+ To disable compression, pass `compress: false` to the initializer.
345
353
 
346
- * `MessageVerifier.new` raises an appropriate exception if the secret is `nil`.
347
- This prevents `MessageVerifier#generate` from raising a cryptic error later on.
354
+ *Jeremy Daer*
348
355
 
349
- *Kostiantyn Kahanskyi*
356
+ * Allow `Range#include?` on TWZ ranges.
350
357
 
351
- * Introduced new configuration option `active_support.test_order` for
352
- specifying the order in which test cases are executed. This option currently defaults
353
- to `:sorted` but will be changed to `:random` in Rails 5.0.
358
+ In #11474 we prevented TWZ ranges being iterated over which matched
359
+ Ruby's handling of Time ranges and as a consequence `include?`
360
+ stopped working with both Time ranges and TWZ ranges. However in
361
+ ruby/ruby@b061634 support was added for `include?` to use `cover?`
362
+ for 'linear' objects. Since we have no way of making Ruby consider
363
+ TWZ instances as 'linear' we have to override `Range#include?`.
354
364
 
355
- *Akira Matsuda*, *Godfrey Chan*
365
+ Fixes #30799.
356
366
 
357
- * Fixed a bug in `Inflector#underscore` where acroynms in nested constant names
358
- are incorrectly parsed as camelCase.
367
+ *Andrew White*
359
368
 
360
- Fixes #8015.
369
+ * Fix acronym support in `humanize`.
361
370
 
362
- *Fred Wu*, *Matthew Draper*
371
+ Acronym inflections are stored with lowercase keys in the hash but
372
+ the match wasn't being lowercased before being looked up in the hash.
373
+ This shouldn't have any performance impact because before it would
374
+ fail to find the acronym and perform the `downcase` operation anyway.
363
375
 
364
- * Make `Time#change` throw an exception if the `:usec` option is out of range and
365
- the time has an offset other than UTC or local.
376
+ Fixes #31052.
366
377
 
367
- *Agis Anastasopoulos*
378
+ *Andrew White*
368
379
 
369
- * `Method` objects now report themselves as not `duplicable?`. This allows
370
- hashes and arrays containing `Method` objects to be `deep_dup`ed.
380
+ * Add same method signature for `Time#prev_year` and `Time#next_year`
381
+ in accordance with `Date#prev_year`, `Date#next_year`.
371
382
 
372
- *Peter Jaros*
383
+ Allows pass argument for `Time#prev_year` and `Time#next_year`.
373
384
 
374
- * `determine_constant_from_test_name` does no longer shadow `NameError`s
375
- which happens during constant autoloading.
385
+ Before:
386
+ ```
387
+ Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
388
+ Time.new(2017, 9, 16, 17, 0).prev_year(1)
389
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
376
390
 
377
- Fixes #9933.
391
+ Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
392
+ Time.new(2017, 9, 16, 17, 0).next_year(1)
393
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
394
+ ```
378
395
 
379
- *Guo Xiang Tan*
396
+ After:
397
+ ```
398
+ Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
399
+ Time.new(2017, 9, 16, 17, 0).prev_year(1) # => 2016-09-16 17:00:00 +0300
380
400
 
381
- * Added instance_eval version to Object#try and Object#try!, so you can do this:
401
+ Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
402
+ Time.new(2017, 9, 16, 17, 0).next_year(1) # => 2018-09-16 17:00:00 +0300
403
+ ```
382
404
 
383
- person.try { name.first }
405
+ *bogdanvlviv*
384
406
 
385
- instead of:
407
+ * Add same method signature for `Time#prev_month` and `Time#next_month`
408
+ in accordance with `Date#prev_month`, `Date#next_month`.
386
409
 
387
- person.try { |person| person.name.first }
410
+ Allows pass argument for `Time#prev_month` and `Time#next_month`.
388
411
 
389
- *DHH*, *Ari Pollak*
412
+ Before:
413
+ ```
414
+ Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
415
+ Time.new(2017, 9, 16, 17, 0).prev_month(1)
416
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
390
417
 
391
- * Fix the `ActiveSupport::Duration#instance_of?` method to return the right
392
- value with the class itself since it was previously delegated to the
393
- internal value.
418
+ Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
419
+ Time.new(2017, 9, 16, 17, 0).next_month(1)
420
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
421
+ ```
394
422
 
395
- *Robin Dupret*
423
+ After:
424
+ ```
425
+ Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
426
+ Time.new(2017, 9, 16, 17, 0).prev_month(1) # => 2017-08-16 17:00:00 +0300
396
427
 
397
- * Fix rounding errors with `#travel_to` by resetting the usec on any passed time to zero, so we only travel
398
- with per-second precision, not anything deeper than that.
428
+ Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
429
+ Time.new(2017, 9, 16, 17, 0).next_month(1) # => 2017-10-16 17:00:00 +0300
430
+ ```
399
431
 
400
- *DHH*
432
+ *bogdanvlviv*
401
433
 
402
- * Fix DateTime comparison with `DateTime::Infinity` object.
434
+ * Add same method signature for `Time#prev_day` and `Time#next_day`
435
+ in accordance with `Date#prev_day`, `Date#next_day`.
403
436
 
404
- *Rafael Mendonça França*
437
+ Allows pass argument for `Time#prev_day` and `Time#next_day`.
405
438
 
406
- * Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
439
+ Before:
440
+ ```
441
+ Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
442
+ Time.new(2017, 9, 16, 17, 0).prev_day(1)
443
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
407
444
 
408
- Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at)
445
+ Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
446
+ Time.new(2017, 9, 16, 17, 0).next_day(1)
447
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
448
+ ```
409
449
 
410
- *DHH*
450
+ After:
451
+ ```
452
+ Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
453
+ Time.new(2017, 9, 16, 17, 0).prev_day(1) # => 2017-09-15 17:00:00 +0300
411
454
 
412
- * `Object#with_options` executes block in merging option context when
413
- explicit receiver in not passed.
455
+ Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
456
+ Time.new(2017, 9, 16, 17, 0).next_day(1) # => 2017-09-17 17:00:00 +0300
457
+ ```
414
458
 
415
- *Pavel Pravosud*
459
+ *bogdanvlviv*
416
460
 
417
- * Fixed a compatibility issue with the `Oj` gem when cherry-picking the file
418
- `active_support/core_ext/object/json` without requiring `active_support/json`.
461
+ * `IO#to_json` now returns the `to_s` representation, rather than
462
+ attempting to convert to an array. This fixes a bug where `IO#to_json`
463
+ would raise an `IOError` when called on an unreadable object.
419
464
 
420
- Fixes #16131.
465
+ Fixes #26132.
421
466
 
422
- *Godfrey Chan*
467
+ *Paul Kuruvilla*
423
468
 
424
- * Make `Hash#with_indifferent_access` copy the default proc too.
469
+ * Remove deprecated `halt_callback_chains_on_return_false` option.
425
470
 
426
- *arthurnn*, *Xanders*
471
+ *Rafael Mendonça França*
427
472
 
428
- * Add `String#truncate_words` to truncate a string by a number of words.
473
+ * Remove deprecated `:if` and `:unless` string filter for callbacks.
429
474
 
430
- *Mohamed Osama*
475
+ *Rafael Mendonça França*
431
476
 
432
- * Deprecate `capture` and `quietly`.
477
+ * `Hash#slice` now falls back to Ruby 2.5+'s built-in definition if defined.
433
478
 
434
- These methods are not thread safe and may cause issues when used in threaded environments.
435
- To avoid problems we are deprecating them.
479
+ *Akira Matsuda*
436
480
 
437
- *Tom Meier*
481
+ * Deprecate `secrets.secret_token`.
438
482
 
439
- * `DateTime#to_f` now preserves the fractional seconds instead of always
440
- rounding to `.0`.
483
+ The architecture for secrets had a big upgrade between Rails 3 and Rails 4,
484
+ when the default changed from using `secret_token` to `secret_key_base`.
441
485
 
442
- Fixes #15994.
486
+ `secret_token` has been soft deprecated in documentation for four years
487
+ but is still in place to support apps created before Rails 4.
488
+ Deprecation warnings have been added to help developers upgrade their
489
+ applications to `secret_key_base`.
443
490
 
444
- *John Paul Ashenfelter*
491
+ *claudiob*, *Kasper Timm Hansen*
445
492
 
446
- * Add `Hash#transform_values` to simplify a common pattern where the values of a
447
- hash must change, but the keys are left the same.
493
+ * Return an instance of `HashWithIndifferentAccess` from `HashWithIndifferentAccess#transform_keys`.
448
494
 
449
- *Sean Griffin*
495
+ *Yuji Yaginuma*
450
496
 
451
- * Always instrument `ActiveSupport::Cache`.
497
+ * Add key rotation support to `MessageEncryptor` and `MessageVerifier`.
452
498
 
453
- Since `ActiveSupport::Notifications` only instruments items when there
454
- are attached subscribers, we don't need to disable instrumentation.
499
+ This change introduces a `rotate` method to both the `MessageEncryptor` and
500
+ `MessageVerifier` classes. This method accepts the same arguments and
501
+ options as the given classes' constructor. The `encrypt_and_verify` method
502
+ for `MessageEncryptor` and the `verified` method for `MessageVerifier` also
503
+ accept an optional keyword argument `:on_rotation` block which is called
504
+ when a rotated instance is used to decrypt or verify the message.
455
505
 
456
- *Peter Wagenet*
506
+ *Michael J Coyne*
457
507
 
458
- * Make the `apply_inflections` method case-insensitive when checking
459
- whether a word is uncountable or not.
508
+ * Deprecate `Module#reachable?` method.
460
509
 
461
- *Robin Dupret*
510
+ *bogdanvlviv*
462
511
 
463
- * Make Dependencies pass a name to NameError error.
512
+ * Add `config/credentials.yml.enc` to store production app secrets.
464
513
 
465
- *arthurnn*
514
+ Allows saving any authentication credentials for third party services
515
+ directly in repo encrypted with `config/master.key` or `ENV["RAILS_MASTER_KEY"]`.
466
516
 
467
- * Fixed `ActiveSupport::Cache::FileStore` exploding with long paths.
517
+ This will eventually replace `Rails.application.secrets` and the encrypted
518
+ secrets introduced in Rails 5.1.
468
519
 
469
- *Adam Panzer*, *Michael Grosser*
520
+ *DHH*, *Kasper Timm Hansen*
470
521
 
471
- * Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
472
- when working with objects with a nanosecond component.
522
+ * Add `ActiveSupport::EncryptedFile` and `ActiveSupport::EncryptedConfiguration`.
473
523
 
474
- `ActiveSupport::TimeWithZone#-` should return the same result as if we were
475
- using `Time#-`:
524
+ Allows for stashing encrypted files or configuration directly in repo by
525
+ encrypting it with a key.
476
526
 
477
- Time.now.end_of_day - Time.now.beginning_of_day # => 86399.999999999
527
+ Backs the new credentials setup above, but can also be used independently.
478
528
 
479
- Before:
529
+ *DHH*, *Kasper Timm Hansen*
480
530
 
481
- Time.zone.now.end_of_day.nsec # => 999999999
482
- Time.zone.now.end_of_day - Time.zone.now.beginning_of_day # => 86400.0
531
+ * `Module#delegate_missing_to` now raises `DelegationError` if target is nil,
532
+ similar to `Module#delegate`.
483
533
 
484
- After:
534
+ *Anton Khamets*
485
535
 
486
- Time.zone.now.end_of_day - Time.zone.now.beginning_of_day
487
- # => 86399.999999999
536
+ * Update `String#camelize` to provide feedback when wrong option is passed.
488
537
 
489
- *Gordon Chan*
538
+ `String#camelize` was returning nil without any feedback when an
539
+ invalid option was passed as a parameter.
490
540
 
491
- * Fixed precision error in NumberHelper when using Rationals.
541
+ Previously:
492
542
 
493
- Before:
543
+ 'one_two'.camelize(true)
544
+ # => nil
494
545
 
495
- ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
496
- # => "330.00"
546
+ Now:
497
547
 
498
- After:
548
+ 'one_two'.camelize(true)
549
+ # => ArgumentError: Invalid option, use either :upper or :lower.
499
550
 
500
- ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
501
- # => "333.33"
551
+ *Ricardo Díaz*
502
552
 
503
- See #15379.
553
+ * Fix modulo operations involving durations.
504
554
 
505
- *Juanjo Bazán*
555
+ Rails 5.1 introduced `ActiveSupport::Duration::Scalar` as a wrapper
556
+ around numeric values as a way of ensuring a duration was the outcome of
557
+ an expression. However, the implementation was missing support for modulo
558
+ operations. This support has now been added and should result in a duration
559
+ being returned from expressions involving modulo operations.
506
560
 
507
- * Removed deprecated `Numeric#ago` and friends
561
+ Prior to Rails 5.1:
508
562
 
509
- Replacements:
563
+ 5.minutes % 2.minutes
564
+ # => 60
510
565
 
511
- 5.ago => 5.seconds.ago
512
- 5.until => 5.seconds.until
513
- 5.since => 5.seconds.since
514
- 5.from_now => 5.seconds.from_now
566
+ Now:
515
567
 
516
- See #12389 for the history and rationale behind this.
568
+ 5.minutes % 2.minutes
569
+ # => 1 minute
517
570
 
518
- *Godfrey Chan*
571
+ Fixes #29603 and #29743.
519
572
 
520
- * DateTime `advance` now supports partial days.
573
+ *Sayan Chakraborty*, *Andrew White*
521
574
 
522
- Before:
575
+ * Fix division where a duration is the denominator.
523
576
 
524
- DateTime.now.advance(days: 1, hours: 12)
577
+ PR #29163 introduced a change in behavior when a duration was the denominator
578
+ in a calculation - this was incorrect as dividing by a duration should always
579
+ return a `Numeric`. The behavior of previous versions of Rails has been restored.
525
580
 
526
- After:
581
+ Fixes #29592.
527
582
 
528
- DateTime.now.advance(days: 1.5)
583
+ *Andrew White*
529
584
 
530
- Fixes #12005.
585
+ * Add purpose and expiry support to `ActiveSupport::MessageVerifier` and
586
+ `ActiveSupport::MessageEncryptor`.
531
587
 
532
- *Shay Davidson*
588
+ For instance, to ensure a message is only usable for one intended purpose:
533
589
 
534
- * `Hash#deep_transform_keys` and `Hash#deep_transform_keys!` now transform hashes
535
- in nested arrays. This change also applies to `Hash#deep_stringify_keys`,
536
- `Hash#deep_stringify_keys!`, `Hash#deep_symbolize_keys` and
537
- `Hash#deep_symbolize_keys!`.
590
+ token = @verifier.generate("x", purpose: :shipping)
538
591
 
539
- *OZAWA Sakuro*
592
+ @verifier.verified(token, purpose: :shipping) # => "x"
593
+ @verifier.verified(token) # => nil
540
594
 
541
- * Fixed confusing `DelegationError` in `Module#delegate`.
595
+ Or make it expire after a set time:
542
596
 
543
- See #15186.
597
+ @verifier.generate("x", expires_in: 1.month)
598
+ @verifier.generate("y", expires_at: Time.now.end_of_year)
544
599
 
545
- *Vladimir Yarotsky*
600
+ Showcased with `ActiveSupport::MessageVerifier`, but works the same for
601
+ `ActiveSupport::MessageEncryptor`'s `encrypt_and_sign` and `decrypt_and_verify`.
546
602
 
547
- * Fixed `ActiveSupport::Subscriber` so that no duplicate subscriber is created
548
- when a subscriber method is redefined.
603
+ Pull requests: #29599, #29854
549
604
 
550
- *Dennis Schön*
605
+ *Assain Jaleel*
551
606
 
552
- * Remove deprecated string based terminators for `ActiveSupport::Callbacks`.
607
+ * Make the order of `Hash#reverse_merge!` consistent with `HashWithIndifferentAccess`.
553
608
 
554
- *Eileen M. Uchitelle*
609
+ *Erol Fornoles*
555
610
 
556
- * Fixed an issue when using
557
- `ActiveSupport::NumberHelper::NumberToDelimitedConverter` to
558
- convert a value that is an `ActiveSupport::SafeBuffer` introduced
559
- in 2da9d67.
611
+ * Add `freeze_time` helper which freezes time to `Time.now` in tests.
560
612
 
561
- See #15064.
613
+ *Prathamesh Sonpatki*
562
614
 
563
- *Mark J. Titorenko*
615
+ * Default `ActiveSupport::MessageEncryptor` to use AES 256 GCM encryption.
564
616
 
565
- * `TimeZone#parse` defaults the day of the month to '1' if any other date
566
- components are specified. This is more consistent with the behavior of
567
- `Time#parse`.
617
+ On for new Rails 5.2 apps. Upgrading apps can find the config as a new
618
+ framework default.
568
619
 
569
- *Ulysse Carion*
620
+ *Assain Jaleel*
570
621
 
571
- * `humanize` strips leading underscores, if any.
622
+ * Cache: `write_multi`.
572
623
 
573
- Before:
624
+ Rails.cache.write_multi foo: 'bar', baz: 'qux'
574
625
 
575
- '_id'.humanize # => ""
626
+ Plus faster fetch_multi with stores that implement `write_multi_entries`.
627
+ Keys that aren't found may be written to the cache store in one shot
628
+ instead of separate writes.
576
629
 
577
- After:
630
+ The default implementation simply calls `write_entry` for each entry.
631
+ Stores may override if they're capable of one-shot bulk writes, like
632
+ Redis `MSET`.
578
633
 
579
- '_id'.humanize # => "Id"
634
+ *Jeremy Daer*
580
635
 
581
- *Xavier Noria*
636
+ * Add default option to module and class attribute accessors.
582
637
 
583
- * Fixed backward compatibility issues introduced in 326e652.
638
+ mattr_accessor :settings, default: {}
584
639
 
585
- Empty Hash or Array should not be present in serialization result.
640
+ Works for `mattr_reader`, `mattr_writer`, `cattr_accessor`, `cattr_reader`,
641
+ and `cattr_writer` as well.
586
642
 
587
- {a: []}.to_query # => ""
588
- {a: {}}.to_query # => ""
643
+ *Genadi Samokovarov*
589
644
 
590
- For more info see #14948.
645
+ * Add `Date#prev_occurring` and `Date#next_occurring` to return specified next/previous occurring day of week.
591
646
 
592
- *Bogdan Gusiev*
647
+ *Shota Iguchi*
593
648
 
594
- * Add `Digest::UUID::uuid_v3` and `Digest::UUID::uuid_v5` to support stable
595
- UUID fixtures on PostgreSQL.
649
+ * Add default option to `class_attribute`.
596
650
 
597
- *Roderick van Domburg*
651
+ Before:
598
652
 
599
- * Fixed `ActiveSupport::Duration#eql?` so that `1.second.eql?(1.second)` is
600
- true.
653
+ class_attribute :settings
654
+ self.settings = {}
601
655
 
602
- This fixes the current situation of:
656
+ Now:
603
657
 
604
- 1.second.eql?(1.second) # => false
658
+ class_attribute :settings, default: {}
605
659
 
606
- `eql?` also requires that the other object is an `ActiveSupport::Duration`.
607
- This requirement makes `ActiveSupport::Duration`'s behavior consistent with
608
- the behavior of Ruby's numeric types:
660
+ *DHH*
609
661
 
610
- 1.eql?(1.0) # => false
611
- 1.0.eql?(1) # => false
662
+ * `#singularize` and `#pluralize` now respect uncountables for the specified locale.
612
663
 
613
- 1.second.eql?(1) # => false (was true)
614
- 1.eql?(1.second) # => false
664
+ *Eilis Hamilton*
615
665
 
616
- { 1 => "foo", 1.0 => "bar" }
617
- # => { 1 => "foo", 1.0 => "bar" }
666
+ * Add `ActiveSupport::CurrentAttributes` to provide a thread-isolated attributes singleton.
667
+ Primary use case is keeping all the per-request attributes easily available to the whole system.
618
668
 
619
- { 1 => "foo", 1.second => "bar" }
620
- # now => { 1 => "foo", 1.second => "bar" }
621
- # was => { 1 => "bar" }
669
+ *DHH*
622
670
 
623
- And though the behavior of these hasn't changed, for reference:
671
+ * Fix implicit coercion calculations with scalars and durations.
624
672
 
625
- 1 == 1.0 # => true
626
- 1.0 == 1 # => true
673
+ Previously, calculations where the scalar is first would be converted to a duration
674
+ of seconds, but this causes issues with dates being converted to times, e.g:
627
675
 
628
- 1 == 1.second # => true
629
- 1.second == 1 # => true
676
+ Time.zone = "Beijing" # => Asia/Shanghai
677
+ date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
678
+ 2 * 1.day # => 172800 seconds
679
+ date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00
630
680
 
631
- *Emily Dobervich*
681
+ Now, the `ActiveSupport::Duration::Scalar` calculation methods will try to maintain
682
+ the part structure of the duration where possible, e.g:
632
683
 
633
- * `ActiveSupport::SafeBuffer#prepend` acts like `String#prepend` and modifies
634
- instance in-place, returning self. `ActiveSupport::SafeBuffer#prepend!` is
635
- deprecated.
684
+ Time.zone = "Beijing" # => Asia/Shanghai
685
+ date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
686
+ 2 * 1.day # => 2 days
687
+ date + 2 * 1.day # => Mon, 22 May 2017
636
688
 
637
- *Pavel Pravosud*
689
+ Fixes #29160, #28970.
638
690
 
639
- * `HashWithIndifferentAccess` better respects `#to_hash` on objects it
640
- receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept
641
- objects which respond to `#to_hash`, even if those objects are not hashes
642
- directly.
691
+ *Andrew White*
643
692
 
644
- *Peter Jaros*
693
+ * Add support for versioned cache entries. This enables the cache stores to recycle cache keys, greatly saving
694
+ on storage in cases with frequent churn. Works together with the separation of `#cache_key` and `#cache_version`
695
+ in Active Record and its use in Action Pack's fragment caching.
645
696
 
646
- * Deprecate `Class#superclass_delegating_accessor`, use `Class#class_attribute` instead.
697
+ *DHH*
647
698
 
648
- *Akshay Vishnoi*
699
+ * Pass gem name and deprecation horizon to deprecation notifications.
649
700
 
650
- * Ensure classes which `include Enumerable` get `#to_json` in addition to
651
- `#as_json`.
701
+ *Willem van Bergen*
652
702
 
653
- *Sammy Larbi*
703
+ * Add support for `:offset` and `:zone` to `ActiveSupport::TimeWithZone#change`.
654
704
 
655
- * Change the signature of `fetch_multi` to return a hash rather than an
656
- array. This makes it consistent with the output of `read_multi`.
705
+ *Andrew White*
657
706
 
658
- *Parker Selbert*
707
+ * Add support for `:offset` to `Time#change`.
659
708
 
660
- * Introduce `Concern#class_methods` as a sleek alternative to clunky
661
- `module ClassMethods`. Add `Kernel#concern` to define at the toplevel
662
- without chunky `module Foo; extend ActiveSupport::Concern` boilerplate.
709
+ Fixes #28723.
663
710
 
664
- # app/models/concerns/authentication.rb
665
- concern :Authentication do
666
- included do
667
- after_create :generate_private_key
668
- end
711
+ *Andrew White*
669
712
 
670
- class_methods do
671
- def authenticate(credentials)
672
- # ...
673
- end
674
- end
713
+ * Add `fetch_values` for `HashWithIndifferentAccess`.
675
714
 
676
- def generate_private_key
677
- # ...
678
- end
679
- end
715
+ The method was originally added to `Hash` in Ruby 2.3.0.
680
716
 
681
- # app/models/user.rb
682
- class User < ActiveRecord::Base
683
- include Authentication
684
- end
717
+ *Josh Pencheon*
685
718
 
686
- *Jeremy Kemper*
687
719
 
688
- Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activesupport/CHANGELOG.md) for previous changes.
720
+ Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activesupport/CHANGELOG.md) for previous changes.