activesupport 5.1.7 → 5.2.0.beta1

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 (238) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +303 -617
  3. data/README.rdoc +1 -1
  4. data/lib/active_support.rb +3 -12
  5. data/lib/active_support/all.rb +2 -0
  6. data/lib/active_support/array_inquirer.rb +2 -0
  7. data/lib/active_support/backtrace_cleaner.rb +2 -0
  8. data/lib/active_support/benchmarkable.rb +2 -0
  9. data/lib/active_support/builder.rb +2 -0
  10. data/lib/active_support/cache.rb +127 -58
  11. data/lib/active_support/cache/file_store.rb +4 -3
  12. data/lib/active_support/cache/mem_cache_store.rb +12 -4
  13. data/lib/active_support/cache/memory_store.rb +2 -0
  14. data/lib/active_support/cache/null_store.rb +2 -0
  15. data/lib/active_support/cache/redis_cache_store.rb +404 -0
  16. data/lib/active_support/cache/strategy/local_cache.rb +9 -2
  17. data/lib/active_support/cache/strategy/local_cache_middleware.rb +2 -0
  18. data/lib/active_support/callbacks.rb +26 -37
  19. data/lib/active_support/concern.rb +3 -1
  20. data/lib/active_support/concurrency/share_lock.rb +2 -0
  21. data/lib/active_support/configurable.rb +2 -0
  22. data/lib/active_support/core_ext.rb +3 -1
  23. data/lib/active_support/core_ext/array.rb +2 -0
  24. data/lib/active_support/core_ext/array/access.rb +4 -2
  25. data/lib/active_support/core_ext/array/conversions.rb +2 -0
  26. data/lib/active_support/core_ext/array/extract_options.rb +2 -0
  27. data/lib/active_support/core_ext/array/grouping.rb +2 -0
  28. data/lib/active_support/core_ext/array/inquiry.rb +2 -0
  29. data/lib/active_support/core_ext/array/prepend_and_append.rb +4 -2
  30. data/lib/active_support/core_ext/array/wrap.rb +2 -0
  31. data/lib/active_support/core_ext/benchmark.rb +2 -0
  32. data/lib/active_support/core_ext/big_decimal.rb +2 -0
  33. data/lib/active_support/core_ext/big_decimal/conversions.rb +2 -0
  34. data/lib/active_support/core_ext/class.rb +2 -0
  35. data/lib/active_support/core_ext/class/attribute.rb +34 -16
  36. data/lib/active_support/core_ext/class/attribute_accessors.rb +2 -0
  37. data/lib/active_support/core_ext/class/subclasses.rb +1 -2
  38. data/lib/active_support/core_ext/date.rb +2 -0
  39. data/lib/active_support/core_ext/date/acts_like.rb +2 -0
  40. data/lib/active_support/core_ext/date/blank.rb +2 -0
  41. data/lib/active_support/core_ext/date/calculations.rb +2 -0
  42. data/lib/active_support/core_ext/date/conversions.rb +10 -9
  43. data/lib/active_support/core_ext/date/zones.rb +2 -0
  44. data/lib/active_support/core_ext/date_and_time/calculations.rb +42 -16
  45. data/lib/active_support/core_ext/date_and_time/compatibility.rb +3 -1
  46. data/lib/active_support/core_ext/date_and_time/zones.rb +2 -0
  47. data/lib/active_support/core_ext/date_time.rb +2 -0
  48. data/lib/active_support/core_ext/date_time/acts_like.rb +2 -0
  49. data/lib/active_support/core_ext/date_time/blank.rb +2 -0
  50. data/lib/active_support/core_ext/date_time/calculations.rb +2 -0
  51. data/lib/active_support/core_ext/date_time/compatibility.rb +6 -4
  52. data/lib/active_support/core_ext/date_time/conversions.rb +2 -0
  53. data/lib/active_support/core_ext/digest/uuid.rb +3 -1
  54. data/lib/active_support/core_ext/enumerable.rb +3 -1
  55. data/lib/active_support/core_ext/file.rb +2 -0
  56. data/lib/active_support/core_ext/file/atomic.rb +2 -0
  57. data/lib/active_support/core_ext/hash.rb +2 -0
  58. data/lib/active_support/core_ext/hash/compact.rb +2 -0
  59. data/lib/active_support/core_ext/hash/conversions.rb +2 -0
  60. data/lib/active_support/core_ext/hash/deep_merge.rb +8 -12
  61. data/lib/active_support/core_ext/hash/except.rb +2 -0
  62. data/lib/active_support/core_ext/hash/indifferent_access.rb +2 -0
  63. data/lib/active_support/core_ext/hash/keys.rb +2 -0
  64. data/lib/active_support/core_ext/hash/reverse_merge.rb +5 -2
  65. data/lib/active_support/core_ext/hash/slice.rb +4 -4
  66. data/lib/active_support/core_ext/hash/transform_values.rb +2 -0
  67. data/lib/active_support/core_ext/integer.rb +2 -0
  68. data/lib/active_support/core_ext/integer/inflections.rb +2 -0
  69. data/lib/active_support/core_ext/integer/multiple.rb +2 -0
  70. data/lib/active_support/core_ext/integer/time.rb +7 -14
  71. data/lib/active_support/core_ext/kernel.rb +2 -0
  72. data/lib/active_support/core_ext/kernel/agnostics.rb +2 -0
  73. data/lib/active_support/core_ext/kernel/concern.rb +2 -0
  74. data/lib/active_support/core_ext/kernel/reporting.rb +2 -0
  75. data/lib/active_support/core_ext/kernel/singleton_class.rb +2 -0
  76. data/lib/active_support/core_ext/load_error.rb +2 -7
  77. data/lib/active_support/core_ext/marshal.rb +2 -0
  78. data/lib/active_support/core_ext/module.rb +3 -0
  79. data/lib/active_support/core_ext/module/aliasing.rb +2 -0
  80. data/lib/active_support/core_ext/module/anonymous.rb +2 -0
  81. data/lib/active_support/core_ext/module/attr_internal.rb +2 -0
  82. data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -24
  83. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +2 -0
  84. data/lib/active_support/core_ext/module/concerning.rb +2 -0
  85. data/lib/active_support/core_ext/module/delegation.rb +29 -24
  86. data/lib/active_support/core_ext/module/deprecation.rb +2 -0
  87. data/lib/active_support/core_ext/module/introspection.rb +2 -0
  88. data/lib/active_support/core_ext/module/reachable.rb +3 -0
  89. data/lib/active_support/core_ext/module/redefine_method.rb +49 -0
  90. data/lib/active_support/core_ext/module/remove_method.rb +5 -23
  91. data/lib/active_support/core_ext/name_error.rb +2 -0
  92. data/lib/active_support/core_ext/numeric.rb +2 -0
  93. data/lib/active_support/core_ext/numeric/bytes.rb +2 -0
  94. data/lib/active_support/core_ext/numeric/conversions.rb +9 -7
  95. data/lib/active_support/core_ext/numeric/inquiry.rb +2 -0
  96. data/lib/active_support/core_ext/numeric/time.rb +7 -15
  97. data/lib/active_support/core_ext/object.rb +2 -0
  98. data/lib/active_support/core_ext/object/acts_like.rb +12 -1
  99. data/lib/active_support/core_ext/object/blank.rb +2 -0
  100. data/lib/active_support/core_ext/object/conversions.rb +2 -0
  101. data/lib/active_support/core_ext/object/deep_dup.rb +2 -0
  102. data/lib/active_support/core_ext/object/duplicable.rb +10 -8
  103. data/lib/active_support/core_ext/object/inclusion.rb +2 -0
  104. data/lib/active_support/core_ext/object/instance_variables.rb +2 -0
  105. data/lib/active_support/core_ext/object/json.rb +8 -0
  106. data/lib/active_support/core_ext/object/to_param.rb +2 -0
  107. data/lib/active_support/core_ext/object/to_query.rb +4 -5
  108. data/lib/active_support/core_ext/object/try.rb +2 -0
  109. data/lib/active_support/core_ext/object/with_options.rb +3 -1
  110. data/lib/active_support/core_ext/range.rb +3 -0
  111. data/lib/active_support/core_ext/range/conversions.rb +9 -1
  112. data/lib/active_support/core_ext/range/each.rb +5 -1
  113. data/lib/active_support/core_ext/range/include_range.rb +2 -0
  114. data/lib/active_support/core_ext/range/include_time_with_zone.rb +23 -0
  115. data/lib/active_support/core_ext/range/overlaps.rb +2 -0
  116. data/lib/active_support/core_ext/regexp.rb +2 -0
  117. data/lib/active_support/core_ext/securerandom.rb +2 -0
  118. data/lib/active_support/core_ext/string.rb +2 -0
  119. data/lib/active_support/core_ext/string/access.rb +2 -0
  120. data/lib/active_support/core_ext/string/behavior.rb +2 -0
  121. data/lib/active_support/core_ext/string/conversions.rb +2 -0
  122. data/lib/active_support/core_ext/string/exclude.rb +2 -0
  123. data/lib/active_support/core_ext/string/filters.rb +2 -0
  124. data/lib/active_support/core_ext/string/indent.rb +2 -0
  125. data/lib/active_support/core_ext/string/inflections.rb +26 -12
  126. data/lib/active_support/core_ext/string/inquiry.rb +2 -0
  127. data/lib/active_support/core_ext/string/multibyte.rb +2 -0
  128. data/lib/active_support/core_ext/string/output_safety.rb +6 -7
  129. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -0
  130. data/lib/active_support/core_ext/string/strip.rb +2 -0
  131. data/lib/active_support/core_ext/string/zones.rb +2 -0
  132. data/lib/active_support/core_ext/time.rb +2 -0
  133. data/lib/active_support/core_ext/time/acts_like.rb +2 -0
  134. data/lib/active_support/core_ext/time/calculations.rb +23 -15
  135. data/lib/active_support/core_ext/time/compatibility.rb +4 -2
  136. data/lib/active_support/core_ext/time/conversions.rb +2 -0
  137. data/lib/active_support/core_ext/time/zones.rb +6 -4
  138. data/lib/active_support/core_ext/uri.rb +4 -1
  139. data/lib/active_support/current_attributes.rb +195 -0
  140. data/lib/active_support/dependencies.rb +15 -25
  141. data/lib/active_support/dependencies/autoload.rb +2 -0
  142. data/lib/active_support/dependencies/interlock.rb +2 -0
  143. data/lib/active_support/deprecation.rb +4 -2
  144. data/lib/active_support/deprecation/behaviors.rb +23 -8
  145. data/lib/active_support/deprecation/constant_accessor.rb +3 -1
  146. data/lib/active_support/deprecation/instance_delegator.rb +2 -0
  147. data/lib/active_support/deprecation/method_wrappers.rb +2 -7
  148. data/lib/active_support/deprecation/proxy_wrappers.rb +4 -1
  149. data/lib/active_support/deprecation/reporting.rb +4 -2
  150. data/lib/active_support/descendants_tracker.rb +2 -0
  151. data/lib/active_support/duration.rb +8 -14
  152. data/lib/active_support/duration/iso8601_parser.rb +4 -2
  153. data/lib/active_support/duration/iso8601_serializer.rb +4 -2
  154. data/lib/active_support/encrypted_configuration.rb +48 -0
  155. data/lib/active_support/encrypted_file.rb +99 -0
  156. data/lib/active_support/evented_file_update_checker.rb +2 -0
  157. data/lib/active_support/execution_wrapper.rb +2 -0
  158. data/lib/active_support/executor.rb +2 -0
  159. data/lib/active_support/file_update_checker.rb +2 -0
  160. data/lib/active_support/gem_version.rb +5 -3
  161. data/lib/active_support/gzip.rb +2 -0
  162. data/lib/active_support/hash_with_indifferent_access.rb +33 -1
  163. data/lib/active_support/i18n.rb +3 -1
  164. data/lib/active_support/i18n_railtie.rb +5 -11
  165. data/lib/active_support/inflections.rb +2 -0
  166. data/lib/active_support/inflector.rb +2 -0
  167. data/lib/active_support/inflector/inflections.rb +19 -3
  168. data/lib/active_support/inflector/methods.rb +40 -23
  169. data/lib/active_support/inflector/transliterate.rb +17 -8
  170. data/lib/active_support/json.rb +2 -0
  171. data/lib/active_support/json/decoding.rb +2 -0
  172. data/lib/active_support/json/encoding.rb +2 -0
  173. data/lib/active_support/key_generator.rb +3 -1
  174. data/lib/active_support/lazy_load_hooks.rb +2 -0
  175. data/lib/active_support/log_subscriber.rb +3 -2
  176. data/lib/active_support/log_subscriber/test_helper.rb +2 -0
  177. data/lib/active_support/logger.rb +2 -0
  178. data/lib/active_support/logger_silence.rb +3 -2
  179. data/lib/active_support/logger_thread_safe_level.rb +2 -0
  180. data/lib/active_support/message_encryptor.rb +94 -22
  181. data/lib/active_support/message_verifier.rb +78 -7
  182. data/lib/active_support/messages/metadata.rb +71 -0
  183. data/lib/active_support/messages/rotation_configuration.rb +22 -0
  184. data/lib/active_support/messages/rotator.rb +56 -0
  185. data/lib/active_support/multibyte.rb +2 -0
  186. data/lib/active_support/multibyte/chars.rb +2 -0
  187. data/lib/active_support/multibyte/unicode.rb +3 -1
  188. data/lib/active_support/notifications.rb +2 -0
  189. data/lib/active_support/notifications/fanout.rb +2 -0
  190. data/lib/active_support/notifications/instrumenter.rb +2 -0
  191. data/lib/active_support/number_helper.rb +2 -0
  192. data/lib/active_support/number_helper/number_converter.rb +2 -0
  193. data/lib/active_support/number_helper/number_to_currency_converter.rb +2 -0
  194. data/lib/active_support/number_helper/number_to_delimited_converter.rb +2 -0
  195. data/lib/active_support/number_helper/number_to_human_converter.rb +2 -0
  196. data/lib/active_support/number_helper/number_to_human_size_converter.rb +2 -0
  197. data/lib/active_support/number_helper/number_to_percentage_converter.rb +2 -0
  198. data/lib/active_support/number_helper/number_to_phone_converter.rb +3 -1
  199. data/lib/active_support/number_helper/number_to_rounded_converter.rb +2 -20
  200. data/lib/active_support/number_helper/rounding_helper.rb +5 -3
  201. data/lib/active_support/option_merger.rb +2 -0
  202. data/lib/active_support/ordered_hash.rb +2 -0
  203. data/lib/active_support/ordered_options.rb +4 -2
  204. data/lib/active_support/per_thread_registry.rb +2 -0
  205. data/lib/active_support/proxy_object.rb +2 -0
  206. data/lib/active_support/rails.rb +2 -0
  207. data/lib/active_support/railtie.rb +27 -8
  208. data/lib/active_support/reloader.rb +7 -5
  209. data/lib/active_support/rescuable.rb +3 -2
  210. data/lib/active_support/security_utils.rb +15 -11
  211. data/lib/active_support/string_inquirer.rb +2 -0
  212. data/lib/active_support/subscriber.rb +2 -0
  213. data/lib/active_support/tagged_logging.rb +2 -0
  214. data/lib/active_support/test_case.rb +2 -1
  215. data/lib/active_support/testing/assertions.rb +6 -4
  216. data/lib/active_support/testing/autorun.rb +2 -0
  217. data/lib/active_support/testing/constant_lookup.rb +2 -0
  218. data/lib/active_support/testing/declarative.rb +2 -0
  219. data/lib/active_support/testing/deprecation.rb +2 -0
  220. data/lib/active_support/testing/file_fixtures.rb +2 -0
  221. data/lib/active_support/testing/isolation.rb +5 -5
  222. data/lib/active_support/testing/method_call_assertions.rb +2 -0
  223. data/lib/active_support/testing/setup_and_teardown.rb +2 -0
  224. data/lib/active_support/testing/stream.rb +2 -0
  225. data/lib/active_support/testing/tagged_logging.rb +2 -0
  226. data/lib/active_support/testing/time_helpers.rb +31 -2
  227. data/lib/active_support/time.rb +2 -0
  228. data/lib/active_support/time_with_zone.rb +38 -0
  229. data/lib/active_support/values/time_zone.rb +20 -12
  230. data/lib/active_support/version.rb +2 -0
  231. data/lib/active_support/xml_mini.rb +2 -0
  232. data/lib/active_support/xml_mini/jdom.rb +4 -2
  233. data/lib/active_support/xml_mini/libxml.rb +3 -1
  234. data/lib/active_support/xml_mini/libxmlsax.rb +4 -2
  235. data/lib/active_support/xml_mini/nokogiri.rb +3 -1
  236. data/lib/active_support/xml_mini/nokogirisax.rb +3 -1
  237. data/lib/active_support/xml_mini/rexml.rb +3 -1
  238. metadata +19 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 0ece0ba787f6df68f2378c0e387d18f2a56a00359a4885e0d155ba9e57811caa
4
- data.tar.gz: 4fc1a1e4b58d382f0fd49539f28707234d7828c46a79c9bca397c1d327ca25b4
2
+ SHA1:
3
+ metadata.gz: 9ccf7f1ec0dc16623eaf84fb1595a07acb086d97
4
+ data.tar.gz: '029fd2771ba6faedc31e0e96896b3f239bbf1ab8'
5
5
  SHA512:
6
- metadata.gz: 78703452ca309f7344f0e8d544bbe093147dba9cbd09917ed4aa72f2e1121ff3cf1835cd062a169d680dd2d7457d892a771d2947f7ce9b1729199a48dd745947
7
- data.tar.gz: ac4bdb64bfd7815044ec53ccd8008f6c62733c525437069d466a33f1af0d0566ded8017daa872269d4921bf777f67662edb0043d68dee271e0defe25b3c42ec7
6
+ metadata.gz: 73c602cc59de91cb268f5c268dec922097c6e7d01e1dd5dc042d0c444a2f0f271f404adde00d48bdf687300317770d4e4f7f9a66f461812ad14e765510eab02c
7
+ data.tar.gz: 90f32b7344f7392810fd39237d697ee776fda3c191436bf8acbe80d595e520a42a2441cb199849d86ea6317c09d94e178f63fd6dbb5c4a9a4e8ed349c863c8fd
@@ -1,788 +1,474 @@
1
- ## Rails 5.1.7 (March 27, 2019) ##
1
+ ## Rails 5.2.0.beta1 (November 27, 2017) ##
2
2
 
3
- * No changes.
3
+ * Changed default behaviour of `ActiveSupport::SecurityUtils.secure_compare`,
4
+ to make it not leak length information even for variable length string.
4
5
 
6
+ Renamed old `ActiveSupport::SecurityUtils.secure_compare` to `fixed_length_secure_compare`,
7
+ and started raising `ArgumentError` in case of length mismatch of passed strings.
5
8
 
6
- ## Rails 5.1.6.2 (March 11, 2019) ##
7
-
8
- * No changes.
9
-
10
-
11
- ## Rails 5.1.6.1 (November 27, 2018) ##
12
-
13
- * No changes.
14
-
15
-
16
- ## Rails 5.1.6 (March 29, 2018) ##
17
-
18
- * Return all mappings for a timezone identifier in `country_zones`
19
-
20
- Some timezones like `Europe/London` have multiple mappings in
21
- `ActiveSupport::TimeZone::MAPPING` so return all of them instead
22
- of the first one found by using `Hash#value`. e.g:
23
-
24
- # Before
25
- ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"]
26
-
27
- # After
28
- ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"]
29
-
30
- Fixes #31668.
31
-
32
- *Andrew White*
33
-
34
-
35
- ## Rails 5.1.5 (February 14, 2018) ##
36
-
37
- * No changes.
38
-
39
-
40
- ## Rails 5.1.4 (September 07, 2017) ##
41
-
42
- * No changes.
9
+ *Vipul A M*
43
10
 
11
+ * Make `ActiveSupport::TimeZone.all` return only time zones that are in
12
+ `ActiveSupport::TimeZone::MAPPING`.
44
13
 
45
- ## Rails 5.1.4.rc1 (August 24, 2017) ##
14
+ Fixes #7245.
46
15
 
47
- * No changes.
16
+ *Chris LaRose*
48
17
 
18
+ * MemCacheStore: Support expiring counters.
49
19
 
50
- ## Rails 5.1.3 (August 03, 2017) ##
20
+ Pass `expires_in: [seconds]` to `#increment` and `#decrement` options
21
+ to set the Memcached TTL (time-to-live) if the counter doesn't exist.
22
+ If the counter exists, Memcached doesn't extend its expiry when it's
23
+ incremented or decremented.
51
24
 
52
- * No changes.
25
+ ```
26
+ Rails.cache.increment("my_counter", 1, expires_in: 2.minutes)
27
+ ```
53
28
 
29
+ *Takumasa Ochi*
54
30
 
55
- ## Rails 5.1.3.rc3 (July 31, 2017) ##
31
+ * Handle `TZInfo::AmbiguousTime` errors
56
32
 
57
- * Fix modulo operations involving durations
33
+ Make `ActiveSupport::TimeWithZone` match Ruby's handling of ambiguous
34
+ times by choosing the later period, e.g.
58
35
 
59
- Rails 5.1 introduce an `ActiveSupport::Duration::Scalar` class as a wrapper
60
- around a numeric value as a way of ensuring a duration was the outcome of
61
- an expression. However the implementation was missing support for modulo
62
- operations. This support has now been added and should result in a duration
63
- being returned from expressions involving modulo operations.
36
+ Ruby:
37
+ ```
38
+ ENV["TZ"] = "Europe/Moscow"
39
+ Time.local(2014, 10, 26, 1, 0, 0) # => 2014-10-26 01:00:00 +0300
40
+ ```
64
41
 
65
- Prior to Rails 5.1:
66
-
67
- 5.minutes % 2.minutes
68
- => 60
69
-
70
- Now:
71
-
72
- 5.minutes % 2.minutes
73
- => 1 minute
74
-
75
- Fixes #29603 and #29743.
76
-
77
- *Sayan Chakraborty*, *Andrew White*
78
-
79
- * Fix division where a duration is the denominator
42
+ Before:
43
+ ```
44
+ >> "2014-10-26 01:00:00".in_time_zone("Moscow")
45
+ TZInfo::AmbiguousTime: 26/10/2014 01:00 is an ambiguous local time.
46
+ ```
80
47
 
81
- PR #29163 introduced a change in behavior when a duration was the denominator
82
- in a calculation - this was incorrect as dividing by a duration should always
83
- return a `Numeric`. The behavior of previous versions of Rails has been restored.
48
+ After:
49
+ ```
50
+ >> "2014-10-26 01:00:00".in_time_zone("Moscow")
51
+ => Sun, 26 Oct 2014 01:00:00 MSK +03:00
52
+ ```
84
53
 
85
- Fixes #29592.
54
+ Fixes #17395.
86
55
 
87
56
  *Andrew White*
88
57
 
89
-
90
- ## Rails 5.1.3.rc2 (July 25, 2017) ##
91
-
92
- * No changes.
93
-
94
-
95
- ## Rails 5.1.3.rc1 (July 19, 2017) ##
96
-
97
- * No changes.
98
-
99
-
100
- ## Rails 5.1.2 (June 26, 2017) ##
101
-
102
- * Cache: Restore the `options = nil` argument for `LocalStore#clear`
103
- that was removed in 5.1.0. Restores compatibility with backends that
104
- take an options argument and use the local cache strategy.
58
+ * Redis cache store.
59
+
60
+ ```
61
+ # Defaults to `redis://localhost:6379/0`. Only use for dev/test.
62
+ config.cache_store = :redis_cache_store
63
+
64
+ # Supports all common cache store options (:namespace, :compress,
65
+ # :compress_threshold, :expires_in, :race_condition_tool) and all
66
+ # Redis options.
67
+ cache_password = Rails.application.secrets.redis_cache_password
68
+ config.cache_store = :redis_cache_store, driver: :hiredis,
69
+ namespace: 'myapp-cache', compress: true, timeout: 1,
70
+ url: "redis://:#{cache_password}@myapp-cache-1:6379/0"
71
+
72
+ # Supports Redis::Distributed with multiple hosts
73
+ config.cache_store = :redis_cache_store, driver: :hiredis
74
+ namespace: 'myapp-cache', compress: true,
75
+ url: %w[
76
+ redis://myapp-cache-1:6379/0
77
+ redis://myapp-cache-1:6380/0
78
+ redis://myapp-cache-2:6379/0
79
+ redis://myapp-cache-2:6380/0
80
+ redis://myapp-cache-3:6379/0
81
+ redis://myapp-cache-3:6380/0
82
+ ]
83
+
84
+ # Or pass a builder block
85
+ config.cache_store = :redis_cache_store,
86
+ namespace: 'myapp-cache', compress: true,
87
+ redis: -> { Redis.new … }
88
+ ```
89
+
90
+ Deployment note: Take care to use a *dedicated Redis cache* rather
91
+ than pointing this at your existing Redis server. It won't cope well
92
+ with mixed usage patterns and it won't expire cache entries by default.
93
+
94
+ Redis cache server setup guide: https://redis.io/topics/lru-cache
105
95
 
106
96
  *Jeremy Daer*
107
97
 
108
- * Fix implicit coercion calculations with scalars and durations
109
-
110
- Previously calculations where the scalar is first would be converted to a duration
111
- of seconds but this causes issues with dates being converted to times, e.g:
98
+ * Cache: Enable compression by default for values > 1kB.
112
99
 
113
- Time.zone = "Beijing" # => Asia/Shanghai
114
- date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
115
- 2 * 1.day # => 172800 seconds
116
- date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00
100
+ Compression has long been available, but opt-in and at a 16kB threshold.
101
+ It wasn't enabled by default due to CPU cost. Today it's cheap and typical
102
+ cache data is eminently compressible, such as HTML or JSON fragments.
103
+ Compression dramatically reduces Memcached/Redis mem usage, which means
104
+ the same cache servers can store more data, which means higher hit rates.
117
105
 
118
- Now the `ActiveSupport::Duration::Scalar` calculation methods will try to maintain
119
- the part structure of the duration where possible, e.g:
106
+ To disable compression, pass `compress: false` to the initializer.
120
107
 
121
- Time.zone = "Beijing" # => Asia/Shanghai
122
- date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
123
- 2 * 1.day # => 2 days
124
- date + 2 * 1.day # => Mon, 22 May 2017
125
-
126
- Fixes #29160, #28970.
127
-
128
- *Andrew White*
129
-
130
-
131
- ## Rails 5.1.1 (May 12, 2017) ##
132
-
133
- * No changes.
134
-
135
-
136
- ## Rails 5.1.0 (April 27, 2017) ##
137
-
138
- * `ActiveSupport::EventedFileUpdateChecker` no longer listens to
139
- directories outside of the application directory.
140
-
141
- *radiospiel*
142
-
143
- * Return unmapped timezones from `country_zones`
144
-
145
- If a country doesn't exist in the MAPPINGS hash then create a new
146
- `ActiveSupport::Timezone` instance using the supplied timezone id.
147
-
148
- Fixes #28431.
149
-
150
- *Andrew White*
151
-
152
- * Add ActiveSupport::Deprecation::DeprecatedConstantAccessor
153
-
154
- Provides transparent deprecation of constants, compatible with exceptions.
155
- Example usage:
156
-
157
- module Example
158
- include ActiveSupport::Deprecation::DeprecatedConstantAccessor
159
- deprecate_constant 'OldException', 'Elsewhere::NewException'
160
- end
161
-
162
- *Dominic Cleal*
163
-
164
- * Fixed bug in `DateAndTime::Compatibility#to_time` that caused it to
165
- raise `RuntimeError: can't modify frozen Time` when called on any frozen `Time`.
166
- Properly pass through the frozen `Time` or `ActiveSupport::TimeWithZone` object
167
- when calling `#to_time`.
168
-
169
- *Kevin McPhillips* & *Andrew White*
170
-
171
- * Remove implicit coercion deprecation of durations
172
-
173
- In #28204 we deprecated implicit conversion of durations to a numeric which
174
- represented the number of seconds in the duration because of unwanted side
175
- effects with calculations on durations and dates. This unfortunately had
176
- the side effect of forcing a explicit cast when configuring third-party
177
- libraries like expiration in Redis, e.g:
178
-
179
- redis.expire("foo", 5.minutes)
180
-
181
- To work around this we've removed the deprecation and added a private class
182
- that wraps the numeric and can perform calculation involving durations and
183
- ensure that they remain a duration irrespective of the order of operations.
184
-
185
- *Andrew White*
186
-
187
- * Update `titleize` regex to allow apostrophes
188
-
189
- In 4b685aa the regex in `titleize` was updated to not match apostrophes to
190
- better reflect the nature of the transformation. Unfortunately, this had the
191
- side effect of breaking capitalization on the first word of a sub-string, e.g:
192
-
193
- >> "This was 'fake news'".titleize
194
- => "This Was 'fake News'"
195
-
196
- This is fixed by extending the look-behind to also check for a word
197
- character on the other side of the apostrophe.
198
-
199
- Fixes #28312.
200
-
201
- *Andrew White*
202
-
203
- * Add `rfc3339` aliases to `xmlschema` for `Time` and `ActiveSupport::TimeWithZone`
204
-
205
- For naming consistency when using the RFC 3339 profile of ISO 8601 in applications.
206
-
207
- *Andrew White*
208
-
209
- * Add `Time.rfc3339` parsing method
210
-
211
- `Time.xmlschema` and consequently its alias `iso8601` accepts timestamps
212
- without a offset in contravention of the RFC 3339 standard. This method
213
- enforces that constraint and raises an `ArgumentError` if it doesn't.
214
-
215
- *Andrew White*
216
-
217
- * Add `ActiveSupport::TimeZone.rfc3339` parsing method
218
-
219
- Previously, there was no way to get a RFC 3339 timestamp into a specific
220
- timezone without either using `parse` or chaining methods. The new method
221
- allows parsing directly into the timezone, e.g:
222
-
223
- >> Time.zone = "Hawaii"
224
- => "Hawaii"
225
- >> Time.zone.rfc3339("1999-12-31T14:00:00Z")
226
- => Fri, 31 Dec 1999 14:00:00 HST -10:00
227
-
228
- This new method has stricter semantics than the current `parse` method,
229
- and will raise an `ArgumentError` instead of returning nil, e.g:
108
+ *Jeremy Daer*
230
109
 
231
- >> Time.zone = "Hawaii"
232
- => "Hawaii"
233
- >> Time.zone.rfc3339("foobar")
234
- ArgumentError: invalid date
235
- >> Time.zone.parse("foobar")
236
- => nil
110
+ * Allow `Range#include?` on TWZ ranges
237
111
 
238
- It will also raise an `ArgumentError` when either the time or offset
239
- components are missing, e.g:
112
+ In #11474 we prevented TWZ ranges being iterated over which matched
113
+ Ruby's handling of Time ranges and as a consequence `include?`
114
+ stopped working with both Time ranges and TWZ ranges. However in
115
+ ruby/ruby@b061634 support was added for `include?` to use `cover?`
116
+ for 'linear' objects. Since we have no way of making Ruby consider
117
+ TWZ instances as 'linear' we have to override `Range#include?`.
240
118
 
241
- >> Time.zone = "Hawaii"
242
- => "Hawaii"
243
- >> Time.zone.rfc3339("1999-12-31")
244
- ArgumentError: invalid date
245
- >> Time.zone.rfc3339("1999-12-31T14:00:00")
246
- ArgumentError: invalid date
119
+ Fixes #30799.
247
120
 
248
121
  *Andrew White*
249
122
 
250
- * Add `ActiveSupport::TimeZone.iso8601` parsing method
251
-
252
- Previously, there was no way to get a ISO 8601 timestamp into a specific
253
- timezone without either using `parse` or chaining methods. The new method
254
- allows parsing directly into the timezone, e.g:
123
+ * Fix acronym support in `humanize`
255
124
 
256
- >> Time.zone = "Hawaii"
257
- => "Hawaii"
258
- >> Time.zone.iso8601("1999-12-31T14:00:00Z")
259
- => Fri, 31 Dec 1999 14:00:00 HST -10:00
125
+ Acronym inflections are stored with lowercase keys in the hash but
126
+ the match wasn't being lowercased before being looked up in the hash.
127
+ This shouldn't have any performance impact because before it would
128
+ fail to find the acronym and perform the `downcase` operation anyway.
260
129
 
261
- If the timestamp is a ISO 8601 date (YYYY-MM-DD), then the time is set
262
- to midnight, e.g:
263
-
264
- >> Time.zone = "Hawaii"
265
- => "Hawaii"
266
- >> Time.zone.iso8601("1999-12-31")
267
- => Fri, 31 Dec 1999 00:00:00 HST -10:00
268
-
269
- This new method has stricter semantics than the current `parse` method,
270
- and will raise an `ArgumentError` instead of returning nil, e.g:
271
-
272
- >> Time.zone = "Hawaii"
273
- => "Hawaii"
274
- >> Time.zone.iso8601("foobar")
275
- ArgumentError: invalid date
276
- >> Time.zone.parse("foobar")
277
- => nil
130
+ Fixes #31052.
278
131
 
279
132
  *Andrew White*
280
133
 
281
- * Deprecate implicit coercion of `ActiveSupport::Duration`
282
-
283
- Currently `ActiveSupport::Duration` implicitly converts to a seconds
284
- value when used in a calculation except for the explicit examples of
285
- addition and subtraction where the duration is the receiver, e.g:
286
-
287
- >> 2 * 1.day
288
- => 172800
289
-
290
- This results in lots of confusion especially when using durations
291
- with dates because adding/subtracting a value from a date treats
292
- integers as a day and not a second, e.g:
293
-
294
- >> Date.today
295
- => Wed, 01 Mar 2017
296
- >> Date.today + 2 * 1.day
297
- => Mon, 10 Apr 2490
134
+ * Add same method signature for `Time#prev_year` and `Time#next_year`
135
+ in accordance with `Date#prev_year`, `Date#next_year`.
298
136
 
299
- To fix this we're implementing `coerce` so that we can provide a
300
- deprecation warning with the intent of removing the implicit coercion
301
- in Rails 5.2, e.g:
137
+ Allows pass argument for `Time#prev_year` and `Time#next_year`.
302
138
 
303
- >> 2 * 1.day
304
- DEPRECATION WARNING: Implicit coercion of ActiveSupport::Duration
305
- to a Numeric is deprecated and will raise a TypeError in Rails 5.2.
306
- => 172800
307
-
308
- In Rails 5.2 it will raise `TypeError`, e.g:
309
-
310
- >> 2 * 1.day
311
- TypeError: ActiveSupport::Duration can't be coerced into Integer
139
+ Before:
140
+ ```
141
+ Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
142
+ Time.new(2017, 9, 16, 17, 0).prev_year(1)
143
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
312
144
 
313
- This is the same behavior as with other types in Ruby, e.g:
145
+ Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
146
+ Time.new(2017, 9, 16, 17, 0).next_year(1)
147
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
148
+ ```
314
149
 
315
- >> 2 * "foo"
316
- TypeError: String can't be coerced into Integer
317
- >> "foo" * 2
318
- => "foofoo"
150
+ After:
151
+ ```
152
+ Time.new(2017, 9, 16, 17, 0).prev_year # => 2016-09-16 17:00:00 +0300
153
+ Time.new(2017, 9, 16, 17, 0).prev_year(1) # => 2016-09-16 17:00:00 +0300
319
154
 
320
- As part of this deprecation add `*` and `/` methods to `AS::Duration`
321
- so that calculations that keep the duration as the receiver work
322
- correctly whether the final receiver is a `Date` or `Time`, e.g:
155
+ Time.new(2017, 9, 16, 17, 0).next_year # => 2018-09-16 17:00:00 +0300
156
+ Time.new(2017, 9, 16, 17, 0).next_year(1) # => 2018-09-16 17:00:00 +0300
157
+ ```
323
158
 
324
- >> Date.today
325
- => Wed, 01 Mar 2017
326
- >> Date.today + 1.day * 2
327
- => Fri, 03 Mar 2017
159
+ *bogdanvlviv*
328
160
 
329
- Fixes #27457.
161
+ * Add same method signature for `Time#prev_month` and `Time#next_month`
162
+ in accordance with `Date#prev_month`, `Date#next_month`.
330
163
 
331
- *Andrew White*
164
+ Allows pass argument for `Time#prev_month` and `Time#next_month`.
332
165
 
333
- * Update `DateTime#change` to support `:usec` and `:nsec` options.
166
+ Before:
167
+ ```
168
+ Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
169
+ Time.new(2017, 9, 16, 17, 0).prev_month(1)
170
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
334
171
 
335
- Adding support for these options now allows us to update the `DateTime#end_of`
336
- methods to match the equivalent `Time#end_of` methods, e.g:
172
+ Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
173
+ Time.new(2017, 9, 16, 17, 0).next_month(1)
174
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
175
+ ```
337
176
 
338
- datetime = DateTime.now.end_of_day
339
- datetime.nsec == 999999999 # => true
177
+ After:
178
+ ```
179
+ Time.new(2017, 9, 16, 17, 0).prev_month # => 2017-08-16 17:00:00 +0300
180
+ Time.new(2017, 9, 16, 17, 0).prev_month(1) # => 2017-08-16 17:00:00 +0300
340
181
 
341
- Fixes #21424.
182
+ Time.new(2017, 9, 16, 17, 0).next_month # => 2017-10-16 17:00:00 +0300
183
+ Time.new(2017, 9, 16, 17, 0).next_month(1) # => 2017-10-16 17:00:00 +0300
184
+ ```
342
185
 
343
- *Dan Moore*, *Andrew White*
186
+ *bogdanvlviv*
344
187
 
345
- * Add `ActiveSupport::Duration#before` and `#after` as aliases for `#until` and `#since`
188
+ * Add same method signature for `Time#prev_day` and `Time#next_day`
189
+ in accordance with `Date#prev_day`, `Date#next_day`.
346
190
 
347
- These read more like English and require less mental gymnastics to read and write.
191
+ Allows pass argument for `Time#prev_day` and `Time#next_day`.
348
192
 
349
193
  Before:
194
+ ```
195
+ Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
196
+ Time.new(2017, 9, 16, 17, 0).prev_day(1)
197
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
350
198
 
351
- 2.weeks.since(customer_start_date)
352
- 5.days.until(today)
199
+ Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
200
+ Time.new(2017, 9, 16, 17, 0).next_day(1)
201
+ # => ArgumentError: wrong number of arguments (given 1, expected 0)
202
+ ```
353
203
 
354
204
  After:
205
+ ```
206
+ Time.new(2017, 9, 16, 17, 0).prev_day # => 2017-09-15 17:00:00 +0300
207
+ Time.new(2017, 9, 16, 17, 0).prev_day(1) # => 2017-09-15 17:00:00 +0300
355
208
 
356
- 2.weeks.after(customer_start_date)
357
- 5.days.before(today)
358
-
359
- *Nick Johnstone*
209
+ Time.new(2017, 9, 16, 17, 0).next_day # => 2017-09-17 17:00:00 +0300
210
+ Time.new(2017, 9, 16, 17, 0).next_day(1) # => 2017-09-17 17:00:00 +0300
211
+ ```
360
212
 
361
- * Soft-deprecated the top-level `HashWithIndifferentAccess` constant.
362
- `ActiveSupport::HashWithIndifferentAccess` should be used instead.
213
+ *bogdanvlviv*
363
214
 
364
- Fixes #28157.
215
+ * `IO#to_json` now returns the `to_s` representation, rather than
216
+ attempting to convert to an array. This fixes a bug where `IO#to_json`
217
+ would raise an `IOError` when called on an unreadable object.
365
218
 
366
- *Robin Dupret*
219
+ Fixes #26132.
367
220
 
368
- * In Core Extensions, make `MarshalWithAutoloading#load` pass through the second, optional
369
- argument for `Marshal#load( source [, proc] )`. This way we don't have to do
370
- `Marshal.method(:load).super_method.call(source, proc)` just to be able to pass a proc.
221
+ *Paul Kuruvilla*
371
222
 
372
- *Jeff Latz*
373
-
374
- * `ActiveSupport::Gzip.decompress` now checks checksum and length in footer.
375
-
376
- *Dylan Thacker-Smith*
377
-
378
- * Cache `ActiveSupport::TimeWithZone#to_datetime` before freezing.
379
-
380
- *Adam Rice*
381
-
382
- * Deprecate `ActiveSupport.halt_callback_chains_on_return_false`.
223
+ * Remove deprecated `halt_callback_chains_on_return_false` option.
383
224
 
384
225
  *Rafael Mendonça França*
385
226
 
386
- * Remove deprecated behavior that halts callbacks when the return is false.
227
+ * Remove deprecated `:if` and `:unless` string filter for callbacks.
387
228
 
388
229
  *Rafael Mendonça França*
389
230
 
390
- * Deprecate passing string to `:if` and `:unless` conditional options
391
- on `set_callback` and `skip_callback`.
392
-
393
- *Ryuta Kamizono*
394
-
395
- * Raise `ArgumentError` when passing string to define callback.
396
-
397
- *Ryuta Kamizono*
398
-
399
- * Updated Unicode version to 9.0.0
400
-
401
- Now we can handle new emojis such like "👩‍👩‍👧‍👦" ("\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}").
402
-
403
- version 8.0.0
404
-
405
- "👩‍👩‍👧‍👦".mb_chars.grapheme_length # => 4
406
- "👩‍👩‍👧‍👦".mb_chars.reverse # => "👦👧‍👩‍👩‍"
407
-
408
- version 9.0.0
409
-
410
- "👩‍👩‍👧‍👦".mb_chars.grapheme_length # => 1
411
- "👩‍👩‍👧‍👦".mb_chars.reverse # => "👩‍👩‍👧‍👦"
412
-
413
- *Fumiaki MATSUSHIMA*
414
-
415
- * Changed `ActiveSupport::Inflector#transliterate` to raise `ArgumentError` when it receives
416
- anything except a string.
417
-
418
- *Kevin McPhillips*
419
-
420
- * Fixed bugs that `StringInquirer#respond_to_missing?` and
421
- `ArrayInquirer#respond_to_missing?` do not fallback to `super`.
231
+ * `Hash#slice` now falls back to Ruby 2.5+'s built-in definition if defined.
422
232
 
423
233
  *Akira Matsuda*
424
234
 
425
- * Fix inconsistent results when parsing large durations and constructing durations from code
426
-
427
- ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true
428
-
429
- Duration parsing made independent from any moment of time:
430
- Fixed length in seconds is assigned to each duration part during parsing.
431
-
432
- Changed duration of months and years in seconds to more accurate and logical:
235
+ * Deprecate `secrets.secret_token`.
433
236
 
434
- 1. The value of 365.2425 days in Gregorian year is more accurate
435
- as it accounts for every 400th non-leap year.
237
+ The architecture for secrets had a big upgrade between Rails 3 and Rails 4,
238
+ when the default changed from using `secret_token` to `secret_key_base`.
436
239
 
437
- 2. Month's length is bound to year's duration, which makes
438
- sensible comparisons like `12.months == 1.year` to be `true`
439
- and nonsensical ones like `30.days == 1.month` to be `false`.
240
+ `secret_token` has been soft deprecated in documentation for four years
241
+ but is still in place to support apps created before Rails 4.
242
+ Deprecation warnings have been added to help developers upgrade their
243
+ applications to `secret_key_base`.
440
244
 
441
- Calculations on times and dates with durations shouldn't be affected as
442
- duration's numeric value isn't used in calculations, only parts are used.
245
+ *claudiob*, *Kasper Timm Hansen*
443
246
 
444
- Methods on `Numeric` like `2.days` now use these predefined durations
445
- to avoid duplication of duration constants through the codebase and
446
- eliminate creation of intermediate durations.
447
-
448
- *Andrey Novikov*, *Andrew White*
449
-
450
- * Change return value of `Rational#duplicable?`, `ComplexClass#duplicable?`
451
- to false.
452
-
453
- *utilum*
454
-
455
- * Change return value of `NilClass#duplicable?`, `FalseClass#duplicable?`,
456
- `TrueClass#duplicable?`, `Symbol#duplicable?` and `Numeric#duplicable?`
457
- to true with Ruby 2.4+. These classes can dup with Ruby 2.4+.
247
+ * Return an instance of `HashWithIndifferentAccess` from `HashWithIndifferentAccess#transform_keys`.
458
248
 
459
249
  *Yuji Yaginuma*
460
250
 
461
- * Remove deprecated class `ActiveSupport::Concurrency::Latch`.
251
+ * Add key rotation support to `MessageEncryptor` and `MessageVerifier`
462
252
 
463
- *Andrew White*
253
+ This change introduces a `rotate` method to both the `MessageEncryptor` and
254
+ `MessageVerifier` classes. This method accepts the same arguments and
255
+ options as the given classes' constructor. The `encrypt_and_verify` method
256
+ for `MessageEncryptor` and the `verified` method for `MessageVerifier` also
257
+ accept an optional keyword argument `:on_rotation` block which is called
258
+ when a rotated instance is used to decrypt or verify the message.
464
259
 
465
- * Remove deprecated separator argument from `parameterize`.
260
+ *Michael J Coyne*
466
261
 
467
- *Andrew White*
262
+ * Deprecate `Module#reachable?` method.
468
263
 
469
- * Remove deprecated method `Numeric#to_formatted_s`.
264
+ *bogdanvlviv*
470
265
 
471
- *Andrew White*
266
+ * Add `config/credentials.yml.enc` to store production app secrets.
472
267
 
473
- * Remove deprecated method `alias_method_chain`.
268
+ Allows saving any authentication credentials for third party services
269
+ directly in repo encrypted with `config/master.key` or `ENV["RAILS_MASTER_KEY"]`.
474
270
 
475
- *Andrew White*
271
+ This will eventually replace `Rails.application.secrets` and the encrypted
272
+ secrets introduced in Rails 5.1.
476
273
 
477
- * Remove deprecated constant `MissingSourceFile`.
274
+ *DHH*, *Kasper Timm Hansen*
478
275
 
479
- *Andrew White*
276
+ * Add `ActiveSupport::EncryptedFile` and `ActiveSupport::EncryptedConfiguration`.
480
277
 
481
- * Remove deprecated methods `Module.qualified_const_defined?`,
482
- `Module.qualified_const_get` and `Module.qualified_const_set`.
278
+ Allows for stashing encrypted files or configuration directly in repo by
279
+ encrypting it with a key.
483
280
 
484
- *Andrew White*
281
+ Backs the new credentials setup above, but can also be used independently.
485
282
 
486
- * Remove deprecated `:prefix` option from `number_to_human_size`.
283
+ *DHH*, *Kasper Timm Hansen*
487
284
 
488
- *Andrew White*
285
+ * `Module#delegate_missing_to` now raises `DelegationError` if target is nil,
286
+ similar to `Module#delegate`.
489
287
 
490
- * Remove deprecated method `ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default`.
288
+ *Anton Khamets*
491
289
 
492
- *Andrew White*
290
+ * Update `String#camelize` to provide feedback when wrong option is passed
493
291
 
494
- * Remove deprecated file `active_support/core_ext/time/marshal.rb`.
292
+ `String#camelize` was returning nil without any feedback when an
293
+ invalid option was passed as a parameter.
495
294
 
496
- *Andrew White*
497
-
498
- * Remove deprecated file `active_support/core_ext/struct.rb`.
295
+ Previously:
499
296
 
500
- *Andrew White*
297
+ 'one_two'.camelize(true)
298
+ # => nil
501
299
 
502
- * Remove deprecated file `active_support/core_ext/module/method_transplanting.rb`.
503
-
504
- *Andrew White*
505
-
506
- * Remove deprecated method `Module.local_constants`.
507
-
508
- *Andrew White*
509
-
510
- * Remove deprecated file `active_support/core_ext/kernel/debugger.rb`.
511
-
512
- *Andrew White*
300
+ Now:
513
301
 
514
- * Remove deprecated method `ActiveSupport::Cache::Store#namespaced_key`.
302
+ 'one_two'.camelize(true)
303
+ # => ArgumentError: Invalid option, use either :upper or :lower.
515
304
 
516
- *Andrew White*
305
+ *Ricardo Díaz*
517
306
 
518
- * Remove deprecated method `ActiveSupport::Cache::Strategy::LocalCache::LocalStore#set_cache_value`.
307
+ * Fix modulo operations involving durations
519
308
 
520
- *Andrew White*
309
+ Rails 5.1 introduced `ActiveSupport::Duration::Scalar` as a wrapper
310
+ around numeric values as a way of ensuring a duration was the outcome of
311
+ an expression. However, the implementation was missing support for modulo
312
+ operations. This support has now been added and should result in a duration
313
+ being returned from expressions involving modulo operations.
521
314
 
522
- * Remove deprecated method `ActiveSupport::Cache::MemCacheStore#escape_key`.
315
+ Prior to Rails 5.1:
523
316
 
524
- *Andrew White*
317
+ 5.minutes % 2.minutes
318
+ # => 60
525
319
 
526
- * Remove deprecated method `ActiveSupport::Cache::FileStore#key_file_path`.
320
+ Now:
527
321
 
528
- *Andrew White*
322
+ 5.minutes % 2.minutes
323
+ # => 1 minute
529
324
 
530
- * Ensure duration parsing is consistent across DST changes.
325
+ Fixes #29603 and #29743.
531
326
 
532
- Previously `ActiveSupport::Duration.parse` used `Time.current` and
533
- `Time#advance` to calculate the number of seconds in the duration
534
- from an arbitrary collection of parts. However as `advance` tries to
535
- be consistent across DST boundaries this meant that either the
536
- duration was shorter or longer depending on the time of year.
327
+ *Sayan Chakraborty*, *Andrew White*
537
328
 
538
- This was fixed by using an absolute reference point in UTC which
539
- isn't subject to DST transitions. An arbitrary date of Jan 1st, 2000
540
- was chosen for no other reason that it seemed appropriate.
329
+ * Fix division where a duration is the denominator
541
330
 
542
- Additionally, duration parsing should now be marginally faster as we
543
- are no longer creating instances of `ActiveSupport::TimeWithZone`
544
- every time we parse a duration string.
331
+ PR #29163 introduced a change in behavior when a duration was the denominator
332
+ in a calculation - this was incorrect as dividing by a duration should always
333
+ return a `Numeric`. The behavior of previous versions of Rails has been restored.
545
334
 
546
- Fixes #26941.
335
+ Fixes #29592.
547
336
 
548
337
  *Andrew White*
549
338
 
550
- * Use `Hash#compact` and `Hash#compact!` from Ruby 2.4. Old Ruby versions
551
- will continue to get these methods from Active Support as before.
552
-
553
- *Prathamesh Sonpatki*
554
-
555
- * Fix `ActiveSupport::TimeZone#strptime`.
556
- Support for timestamps in format of seconds (%s) and milliseconds (%Q).
557
-
558
- Fixes #26840.
559
-
560
- *Lev Denisov*
561
-
562
- * Fix `DateAndTime::Calculations#copy_time_to`. Copy `nsec` instead of `usec`.
563
-
564
- Jumping forward or backward between weeks now preserves nanosecond digits.
565
-
566
- *Josua Schmid*
567
-
568
- * Fix `ActiveSupport::TimeWithZone#in` across DST boundaries.
569
-
570
- Previously calls to `in` were being sent to the non-DST aware
571
- method `Time#since` via `method_missing`. It is now aliased to
572
- the DST aware `ActiveSupport::TimeWithZone#+` which handles
573
- transitions across DST boundaries, e.g:
574
-
575
- Time.zone = "US/Eastern"
576
-
577
- t = Time.zone.local(2016,11,6,1)
578
- # => Sun, 06 Nov 2016 01:00:00 EDT -05:00
579
-
580
- t.in(1.hour)
581
- # => Sun, 06 Nov 2016 01:00:00 EST -05:00
582
-
583
- Fixes #26580.
584
-
585
- *Thomas Balthazar*
586
-
587
- * Remove unused parameter `options = nil` for `#clear` of
588
- `ActiveSupport::Cache::Strategy::LocalCache::LocalStore` and
589
- `ActiveSupport::Cache::Strategy::LocalCache`.
339
+ * Add purpose and expiry support to `ActiveSupport::MessageVerifier` &
340
+ `ActiveSupport::MessageEncryptor`.
590
341
 
591
- *Yosuke Kabuto*
342
+ For instance, to ensure a message is only usable for one intended purpose:
592
343
 
593
- * Fix `thread_mattr_accessor` subclass no longer overwrites parent.
344
+ token = @verifier.generate("x", purpose: :shipping)
594
345
 
595
- Assigning a value to a subclass using `thread_mattr_accessor` no
596
- longer changes the value of the parent class. This brings the
597
- behavior inline with the documentation.
346
+ @verifier.verified(token, purpose: :shipping) # => "x"
347
+ @verifier.verified(token) # => nil
598
348
 
599
- Given:
349
+ Or make it expire after a set time:
600
350
 
601
- class Account
602
- thread_mattr_accessor :user
603
- end
351
+ @verifier.generate("x", expires_in: 1.month)
352
+ @verifier.generate("y", expires_at: Time.now.end_of_year)
604
353
 
605
- class Customer < Account
606
- end
354
+ Showcased with `ActiveSupport::MessageVerifier`, but works the same for
355
+ `ActiveSupport::MessageEncryptor`'s `encrypt_and_sign` and `decrypt_and_verify`.
607
356
 
608
- Account.user = "DHH"
609
- Customer.user = "Rafael"
357
+ Pull requests: #29599, #29854
610
358
 
611
- Before:
612
-
613
- Account.user # => "Rafael"
614
-
615
- After:
359
+ *Assain Jaleel*
616
360
 
617
- Account.user # => "DHH"
361
+ * Make the order of `Hash#reverse_merge!` consistent with `HashWithIndifferentAccess`.
618
362
 
619
- *Shinichi Maeshima*
620
-
621
- * Since weeks are no longer converted to days, add `:weeks` to the list of
622
- parts that `ActiveSupport::TimeWithZone` will recognize as possibly being
623
- of variable duration to take account of DST transitions.
624
-
625
- Fixes #26039.
626
-
627
- *Andrew White*
363
+ *Erol Fornoles*
628
364
 
629
- * Defines `Regexp.match?` for Ruby versions prior to 2.4. The predicate
630
- has the same interface, but it does not have the performance boost. Its
631
- purpose is to be able to write 2.4 compatible code.
365
+ * Add `freeze_time` helper which freezes time to `Time.now` in tests.
632
366
 
633
- *Xavier Noria*
634
-
635
- * Allow `MessageEncryptor` to take advantage of authenticated encryption modes.
367
+ *Prathamesh Sonpatki*
636
368
 
637
- AEAD modes like `aes-256-gcm` provide both confidentiality and data
638
- authenticity, eliminating the need to use `MessageVerifier` to check if the
639
- encrypted data has been tampered with. This speeds up encryption/decryption
640
- and results in shorter cipher text.
369
+ * Default `ActiveSupport::MessageEncryptor` to use AES 256 GCM encryption.
641
370
 
642
- *Bart de Water*
371
+ On for new Rails 5.2 apps. Upgrading apps can find the config as a new
372
+ framework default.
643
373
 
644
- * Introduce `assert_changes` and `assert_no_changes`.
374
+ *Assain Jaleel*
645
375
 
646
- `assert_changes` is a more general `assert_difference` that works with any
647
- value.
376
+ * Cache: `write_multi`
648
377
 
649
- assert_changes 'Error.current', from: nil, to: 'ERR' do
650
- expected_bad_operation
651
- end
378
+ Rails.cache.write_multi foo: 'bar', baz: 'qux'
652
379
 
653
- Can be called with strings, to be evaluated in the binding (context) of
654
- the block given to the assertion, or a lambda.
380
+ Plus faster fetch_multi with stores that implement `write_multi_entries`.
381
+ Keys that aren't found may be written to the cache store in one shot
382
+ instead of separate writes.
655
383
 
656
- assert_changes -> { Error.current }, from: nil, to: 'ERR' do
657
- expected_bad_operation
658
- end
384
+ The default implementation simply calls `write_entry` for each entry.
385
+ Stores may override if they're capable of one-shot bulk writes, like
386
+ Redis `MSET`.
659
387
 
660
- The `from` and `to` arguments are compared with the case operator (`===`).
388
+ *Jeremy Daer*
661
389
 
662
- assert_changes 'Error.current', from: nil, to: Error do
663
- expected_bad_operation
664
- end
390
+ * Add default option to module and class attribute accessors.
665
391
 
666
- This is pretty useful, if you need to loosely compare a value. For example,
667
- you need to test a token has been generated and it has that many random
668
- characters.
392
+ mattr_accessor :settings, default: {}
669
393
 
670
- user = User.start_registration
671
- assert_changes 'user.token', to: /\w{32}/ do
672
- user.finish_registration
673
- end
394
+ Works for `mattr_reader`, `mattr_writer`, `cattr_accessor`, `cattr_reader`,
395
+ and `cattr_writer` as well.
674
396
 
675
397
  *Genadi Samokovarov*
676
398
 
677
- * Fix `ActiveSupport::TimeZone#strptime`. Now raises `ArgumentError` when the
678
- given time doesn't match the format. The error is the same as the one given
679
- by Ruby's `Date.strptime`. Previously it raised
680
- `NoMethodError: undefined method empty? for nil:NilClass.` due to a bug.
399
+ * Add `Date#prev_occurring` and `Date#next_occurring` to return specified next/previous occurring day of week.
681
400
 
682
- Fixes #25701.
401
+ *Shota Iguchi*
683
402
 
684
- *John Gesimondo*
403
+ * Add default option to `class_attribute`.
685
404
 
686
- * `travel/travel_to` travel time helpers, now raise on nested calls,
687
- as this can lead to confusing time stubbing.
405
+ Before:
688
406
 
689
- Instead of:
407
+ class_attribute :settings
408
+ self.settings = {}
690
409
 
691
- travel_to 2.days.from_now do
692
- # 2 days from today
693
- travel_to 3.days.from_now do
694
- # 5 days from today
695
- end
696
- end
410
+ Now:
697
411
 
698
- preferred way to achieve above is:
412
+ class_attribute :settings, default: {}
699
413
 
700
- travel 2.days do
701
- # 2 days from today
702
- end
414
+ *DHH*
703
415
 
704
- travel 5.days do
705
- # 5 days from today
706
- end
416
+ * `#singularize` and `#pluralize` now respect uncountables for the specified locale.
707
417
 
708
- *Vipul A M*
418
+ *Eilis Hamilton*
709
419
 
710
- * Support parsing JSON time in ISO8601 local time strings in
711
- `ActiveSupport::JSON.decode` when `parse_json_times` is enabled.
712
- Strings in the format of `YYYY-MM-DD hh:mm:ss` (without a `Z` at
713
- the end) will be parsed in the local timezone (`Time.zone`). In
714
- addition, date strings (`YYYY-MM-DD`) are now parsed into `Date`
715
- objects.
420
+ * Add `ActiveSupport::CurrentAttributes` to provide a thread-isolated attributes singleton.
421
+ Primary use case is keeping all the per-request attributes easily available to the whole system.
716
422
 
717
- *Grzegorz Witek*
423
+ *DHH*
718
424
 
719
- * Fixed `ActiveSupport::Logger.broadcast` so that calls to `#silence` now
720
- properly delegate to all loggers. Silencing now properly suppresses logging
721
- to both the log and the console.
425
+ * Fix implicit coercion calculations with scalars and durations
722
426
 
723
- *Kevin McPhillips*
427
+ Previously, calculations where the scalar is first would be converted to a duration
428
+ of seconds, but this causes issues with dates being converted to times, e.g:
724
429
 
725
- * Remove deprecated arguments in `assert_nothing_raised`.
430
+ Time.zone = "Beijing" # => Asia/Shanghai
431
+ date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
432
+ 2 * 1.day # => 172800 seconds
433
+ date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00
726
434
 
727
- *Rafel Mendonça França*
435
+ Now, the `ActiveSupport::Duration::Scalar` calculation methods will try to maintain
436
+ the part structure of the duration where possible, e.g:
728
437
 
729
- * `Date.to_s` doesn't produce too many spaces. For example, `to_s(:short)`
730
- will now produce `01 Feb` instead of ` 1 Feb`.
438
+ Time.zone = "Beijing" # => Asia/Shanghai
439
+ date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
440
+ 2 * 1.day # => 2 days
441
+ date + 2 * 1.day # => Mon, 22 May 2017
731
442
 
732
- Fixes #25251.
443
+ Fixes #29160, #28970.
733
444
 
734
- *Sean Griffin*
445
+ *Andrew White*
735
446
 
736
- * Introduce `Module#delegate_missing_to`.
447
+ * Add support for versioned cache entries. This enables the cache stores to recycle cache keys, greatly saving
448
+ on storage in cases with frequent churn. Works together with the separation of `#cache_key` and `#cache_version`
449
+ in Active Record and its use in Action Pack's fragment caching.
737
450
 
738
- When building a decorator, a common pattern emerges:
451
+ *DHH*
739
452
 
740
- class Partition
741
- def initialize(first_event)
742
- @events = [ first_event ]
743
- end
453
+ * Pass gem name and deprecation horizon to deprecation notifications.
744
454
 
745
- def people
746
- if @events.first.detail.people.any?
747
- @events.collect { |e| Array(e.detail.people) }.flatten.uniq
748
- else
749
- @events.collect(&:creator).uniq
750
- end
751
- end
455
+ *Willem van Bergen*
752
456
 
753
- private
754
- def respond_to_missing?(name, include_private = false)
755
- @events.respond_to?(name, include_private)
756
- end
457
+ * Add support for `:offset` and `:zone` to `ActiveSupport::TimeWithZone#change`
757
458
 
758
- def method_missing(method, *args, &block)
759
- @events.send(method, *args, &block)
760
- end
761
- end
459
+ *Andrew White*
762
460
 
763
- With `Module#delegate_missing_to`, the above is condensed to:
461
+ * Add support for `:offset` to `Time#change`
764
462
 
765
- class Partition
766
- delegate_missing_to :@events
463
+ Fixes #28723.
767
464
 
768
- def initialize(first_event)
769
- @events = [ first_event ]
770
- end
465
+ *Andrew White*
771
466
 
772
- def people
773
- if @events.first.detail.people.any?
774
- @events.collect { |e| Array(e.detail.people) }.flatten.uniq
775
- else
776
- @events.collect(&:creator).uniq
777
- end
778
- end
779
- end
467
+ * Add `fetch_values` for `HashWithIndifferentAccess`
780
468
 
781
- *Genadi Samokovarov*, *DHH*
469
+ The method was originally added to `Hash` in Ruby 2.3.0.
782
470
 
783
- * Rescuable: If a handler doesn't match the exception, check for handlers
784
- matching the exception's cause.
471
+ *Josh Pencheon*
785
472
 
786
- *Jeremy Daer*
787
473
 
788
- Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activesupport/CHANGELOG.md) for previous changes.
474
+ Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activesupport/CHANGELOG.md) for previous changes.