activesupport 5.2.0 → 6.1.0

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

Potentially problematic release.


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

Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +362 -333
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -3
  5. data/lib/active_support/actionable_error.rb +48 -0
  6. data/lib/active_support/array_inquirer.rb +4 -2
  7. data/lib/active_support/backtrace_cleaner.rb +29 -3
  8. data/lib/active_support/benchmarkable.rb +1 -1
  9. data/lib/active_support/cache/file_store.rb +33 -33
  10. data/lib/active_support/cache/mem_cache_store.rb +31 -29
  11. data/lib/active_support/cache/memory_store.rb +59 -33
  12. data/lib/active_support/cache/null_store.rb +8 -3
  13. data/lib/active_support/cache/redis_cache_store.rb +84 -45
  14. data/lib/active_support/cache/strategy/local_cache.rb +41 -26
  15. data/lib/active_support/cache.rb +174 -113
  16. data/lib/active_support/callbacks.rb +81 -64
  17. data/lib/active_support/concern.rb +76 -5
  18. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
  19. data/lib/active_support/concurrency/share_lock.rb +0 -1
  20. data/lib/active_support/configurable.rb +10 -14
  21. data/lib/active_support/configuration_file.rb +46 -0
  22. data/lib/active_support/core_ext/array/access.rb +18 -6
  23. data/lib/active_support/core_ext/array/conversions.rb +5 -5
  24. data/lib/active_support/core_ext/array/extract.rb +21 -0
  25. data/lib/active_support/core_ext/array.rb +1 -1
  26. data/lib/active_support/core_ext/benchmark.rb +2 -2
  27. data/lib/active_support/core_ext/class/attribute.rb +32 -47
  28. data/lib/active_support/core_ext/class/subclasses.rb +17 -38
  29. data/lib/active_support/core_ext/date/calculations.rb +6 -5
  30. data/lib/active_support/core_ext/date/conversions.rb +2 -1
  31. data/lib/active_support/core_ext/date_and_time/calculations.rb +37 -47
  32. data/lib/active_support/core_ext/date_and_time/compatibility.rb +15 -0
  33. data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
  34. data/lib/active_support/core_ext/date_time/calculations.rb +1 -1
  35. data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
  36. data/lib/active_support/core_ext/digest.rb +3 -0
  37. data/lib/active_support/core_ext/enumerable.rb +171 -70
  38. data/lib/active_support/core_ext/file/atomic.rb +1 -1
  39. data/lib/active_support/core_ext/hash/conversions.rb +3 -3
  40. data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
  41. data/lib/active_support/core_ext/hash/except.rb +2 -2
  42. data/lib/active_support/core_ext/hash/keys.rb +1 -30
  43. data/lib/active_support/core_ext/hash/slice.rb +6 -27
  44. data/lib/active_support/core_ext/hash.rb +1 -2
  45. data/lib/active_support/core_ext/integer/multiple.rb +1 -1
  46. data/lib/active_support/core_ext/kernel.rb +0 -1
  47. data/lib/active_support/core_ext/load_error.rb +1 -1
  48. data/lib/active_support/core_ext/marshal.rb +2 -0
  49. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  50. data/lib/active_support/core_ext/module/attribute_accessors.rb +30 -39
  51. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +17 -19
  52. data/lib/active_support/core_ext/module/concerning.rb +8 -2
  53. data/lib/active_support/core_ext/module/delegation.rb +76 -33
  54. data/lib/active_support/core_ext/module/introspection.rb +16 -15
  55. data/lib/active_support/core_ext/module/redefine_method.rb +8 -17
  56. data/lib/active_support/core_ext/module.rb +0 -1
  57. data/lib/active_support/core_ext/name_error.rb +29 -2
  58. data/lib/active_support/core_ext/numeric/conversions.rb +129 -129
  59. data/lib/active_support/core_ext/numeric.rb +0 -1
  60. data/lib/active_support/core_ext/object/blank.rb +1 -2
  61. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  62. data/lib/active_support/core_ext/object/duplicable.rb +7 -114
  63. data/lib/active_support/core_ext/object/json.rb +7 -2
  64. data/lib/active_support/core_ext/object/to_query.rb +5 -2
  65. data/lib/active_support/core_ext/object/try.rb +17 -7
  66. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  67. data/lib/active_support/core_ext/range/compare_range.rb +82 -0
  68. data/lib/active_support/core_ext/range/conversions.rb +31 -29
  69. data/lib/active_support/core_ext/range/each.rb +0 -1
  70. data/lib/active_support/core_ext/range/include_time_with_zone.rb +8 -3
  71. data/lib/active_support/core_ext/range.rb +1 -1
  72. data/lib/active_support/core_ext/regexp.rb +8 -5
  73. data/lib/active_support/core_ext/securerandom.rb +23 -3
  74. data/lib/active_support/core_ext/string/access.rb +5 -16
  75. data/lib/active_support/core_ext/string/conversions.rb +1 -0
  76. data/lib/active_support/core_ext/string/filters.rb +42 -1
  77. data/lib/active_support/core_ext/string/inflections.rb +45 -6
  78. data/lib/active_support/core_ext/string/inquiry.rb +1 -0
  79. data/lib/active_support/core_ext/string/multibyte.rb +6 -5
  80. data/lib/active_support/core_ext/string/output_safety.rb +69 -12
  81. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -2
  82. data/lib/active_support/core_ext/string/strip.rb +3 -1
  83. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +14 -0
  84. data/lib/active_support/core_ext/symbol.rb +3 -0
  85. data/lib/active_support/core_ext/time/calculations.rb +50 -3
  86. data/lib/active_support/core_ext/time/conversions.rb +1 -0
  87. data/lib/active_support/core_ext/uri.rb +7 -5
  88. data/lib/active_support/current_attributes/test_helper.rb +13 -0
  89. data/lib/active_support/current_attributes.rb +15 -2
  90. data/lib/active_support/dependencies/zeitwerk_integration.rb +117 -0
  91. data/lib/active_support/dependencies.rb +118 -35
  92. data/lib/active_support/deprecation/behaviors.rb +20 -3
  93. data/lib/active_support/deprecation/disallowed.rb +56 -0
  94. data/lib/active_support/deprecation/instance_delegator.rb +0 -1
  95. data/lib/active_support/deprecation/method_wrappers.rb +21 -13
  96. data/lib/active_support/deprecation/proxy_wrappers.rb +29 -6
  97. data/lib/active_support/deprecation/reporting.rb +51 -8
  98. data/lib/active_support/deprecation.rb +6 -1
  99. data/lib/active_support/descendants_tracker.rb +59 -9
  100. data/lib/active_support/duration/iso8601_parser.rb +2 -4
  101. data/lib/active_support/duration/iso8601_serializer.rb +18 -14
  102. data/lib/active_support/duration.rb +90 -38
  103. data/lib/active_support/encrypted_configuration.rb +1 -5
  104. data/lib/active_support/encrypted_file.rb +23 -5
  105. data/lib/active_support/environment_inquirer.rb +20 -0
  106. data/lib/active_support/evented_file_update_checker.rb +82 -117
  107. data/lib/active_support/execution_wrapper.rb +1 -0
  108. data/lib/active_support/file_update_checker.rb +0 -1
  109. data/lib/active_support/fork_tracker.rb +62 -0
  110. data/lib/active_support/gem_version.rb +2 -2
  111. data/lib/active_support/hash_with_indifferent_access.rb +78 -41
  112. data/lib/active_support/i18n.rb +1 -0
  113. data/lib/active_support/i18n_railtie.rb +16 -5
  114. data/lib/active_support/inflector/inflections.rb +2 -7
  115. data/lib/active_support/inflector/methods.rb +50 -57
  116. data/lib/active_support/inflector/transliterate.rb +47 -18
  117. data/lib/active_support/json/decoding.rb +25 -26
  118. data/lib/active_support/json/encoding.rb +11 -3
  119. data/lib/active_support/key_generator.rb +1 -33
  120. data/lib/active_support/lazy_load_hooks.rb +5 -2
  121. data/lib/active_support/locale/en.rb +33 -0
  122. data/lib/active_support/locale/en.yml +7 -3
  123. data/lib/active_support/log_subscriber.rb +39 -9
  124. data/lib/active_support/logger.rb +2 -17
  125. data/lib/active_support/logger_silence.rb +11 -19
  126. data/lib/active_support/logger_thread_safe_level.rb +52 -7
  127. data/lib/active_support/message_encryptor.rb +8 -13
  128. data/lib/active_support/message_verifier.rb +10 -10
  129. data/lib/active_support/messages/metadata.rb +11 -2
  130. data/lib/active_support/messages/rotation_configuration.rb +2 -1
  131. data/lib/active_support/messages/rotator.rb +10 -9
  132. data/lib/active_support/multibyte/chars.rb +10 -68
  133. data/lib/active_support/multibyte/unicode.rb +15 -327
  134. data/lib/active_support/notifications/fanout.rb +116 -16
  135. data/lib/active_support/notifications/instrumenter.rb +71 -9
  136. data/lib/active_support/notifications.rb +72 -8
  137. data/lib/active_support/number_helper/number_converter.rb +5 -6
  138. data/lib/active_support/number_helper/number_to_currency_converter.rb +4 -9
  139. data/lib/active_support/number_helper/number_to_delimited_converter.rb +3 -2
  140. data/lib/active_support/number_helper/number_to_human_converter.rb +4 -3
  141. data/lib/active_support/number_helper/number_to_human_size_converter.rb +4 -3
  142. data/lib/active_support/number_helper/number_to_percentage_converter.rb +3 -1
  143. data/lib/active_support/number_helper/number_to_phone_converter.rb +2 -1
  144. data/lib/active_support/number_helper/number_to_rounded_converter.rb +8 -7
  145. data/lib/active_support/number_helper/rounding_helper.rb +12 -28
  146. data/lib/active_support/number_helper.rb +38 -12
  147. data/lib/active_support/option_merger.rb +22 -3
  148. data/lib/active_support/ordered_hash.rb +1 -1
  149. data/lib/active_support/ordered_options.rb +13 -3
  150. data/lib/active_support/parameter_filter.rb +133 -0
  151. data/lib/active_support/per_thread_registry.rb +1 -1
  152. data/lib/active_support/rails.rb +1 -10
  153. data/lib/active_support/railtie.rb +23 -1
  154. data/lib/active_support/reloader.rb +4 -5
  155. data/lib/active_support/secure_compare_rotator.rb +51 -0
  156. data/lib/active_support/security_utils.rb +19 -12
  157. data/lib/active_support/string_inquirer.rb +4 -3
  158. data/lib/active_support/subscriber.rb +72 -24
  159. data/lib/active_support/tagged_logging.rb +42 -8
  160. data/lib/active_support/test_case.rb +92 -1
  161. data/lib/active_support/testing/assertions.rb +30 -9
  162. data/lib/active_support/testing/deprecation.rb +0 -1
  163. data/lib/active_support/testing/file_fixtures.rb +2 -0
  164. data/lib/active_support/testing/isolation.rb +2 -2
  165. data/lib/active_support/testing/method_call_assertions.rb +28 -1
  166. data/lib/active_support/testing/parallelization/server.rb +78 -0
  167. data/lib/active_support/testing/parallelization/worker.rb +100 -0
  168. data/lib/active_support/testing/parallelization.rb +51 -0
  169. data/lib/active_support/testing/setup_and_teardown.rb +5 -9
  170. data/lib/active_support/testing/stream.rb +1 -2
  171. data/lib/active_support/testing/time_helpers.rb +47 -12
  172. data/lib/active_support/time_with_zone.rb +81 -47
  173. data/lib/active_support/values/time_zone.rb +34 -18
  174. data/lib/active_support/xml_mini/jdom.rb +2 -3
  175. data/lib/active_support/xml_mini/libxml.rb +2 -2
  176. data/lib/active_support/xml_mini/libxmlsax.rb +4 -4
  177. data/lib/active_support/xml_mini/nokogiri.rb +2 -2
  178. data/lib/active_support/xml_mini/nokogirisax.rb +3 -3
  179. data/lib/active_support/xml_mini/rexml.rb +10 -3
  180. data/lib/active_support/xml_mini.rb +2 -10
  181. data/lib/active_support.rb +14 -1
  182. metadata +57 -30
  183. data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -9
  184. data/lib/active_support/core_ext/hash/compact.rb +0 -29
  185. data/lib/active_support/core_ext/hash/transform_values.rb +0 -32
  186. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -13
  187. data/lib/active_support/core_ext/module/reachable.rb +0 -11
  188. data/lib/active_support/core_ext/numeric/inquiry.rb +0 -28
  189. data/lib/active_support/core_ext/range/include_range.rb +0 -25
  190. data/lib/active_support/values/unicode_tables.dat +0 -0
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "tzinfo"
4
4
  require "concurrent/map"
5
- require "active_support/core_ext/object/blank"
6
5
 
7
6
  module ActiveSupport
8
7
  # The TimeZone class serves as a wrapper around TZInfo::Timezone instances.
@@ -183,8 +182,9 @@ module ActiveSupport
183
182
  "Samoa" => "Pacific/Apia"
184
183
  }
185
184
 
186
- UTC_OFFSET_WITH_COLON = "%s%02d:%02d"
187
- UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.tr(":", "")
185
+ UTC_OFFSET_WITH_COLON = "%s%02d:%02d" # :nodoc:
186
+ UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.tr(":", "") # :nodoc:
187
+ private_constant :UTC_OFFSET_WITH_COLON, :UTC_OFFSET_WITHOUT_COLON
188
188
 
189
189
  @lazy_zones_map = Concurrent::Map.new
190
190
  @country_zones = Concurrent::Map.new
@@ -203,7 +203,7 @@ module ActiveSupport
203
203
  end
204
204
 
205
205
  def find_tzinfo(name)
206
- TZInfo::Timezone.new(MAPPING[name] || name)
206
+ TZInfo::Timezone.get(MAPPING[name] || name)
207
207
  end
208
208
 
209
209
  alias_method :create, :new
@@ -266,21 +266,22 @@ module ActiveSupport
266
266
  private
267
267
  def load_country_zones(code)
268
268
  country = TZInfo::Country.get(code)
269
- country.zone_identifiers.map do |tz_id|
269
+ country.zone_identifiers.flat_map do |tz_id|
270
270
  if MAPPING.value?(tz_id)
271
271
  MAPPING.inject([]) do |memo, (key, value)|
272
272
  memo << self[key] if value == tz_id
273
273
  memo
274
274
  end
275
275
  else
276
- create(tz_id, nil, TZInfo::Timezone.new(tz_id))
276
+ create(tz_id, nil, TZInfo::Timezone.get(tz_id))
277
277
  end
278
- end.flatten(1).sort!
278
+ end.sort!
279
279
  end
280
280
 
281
281
  def zones_map
282
282
  @zones_map ||= MAPPING.each_with_object({}) do |(name, _), zones|
283
- zones[name] = self[name]
283
+ timezone = self[name]
284
+ zones[name] = timezone if timezone
284
285
  end
285
286
  end
286
287
  end
@@ -301,11 +302,7 @@ module ActiveSupport
301
302
 
302
303
  # Returns the offset of this time zone from UTC in seconds.
303
304
  def utc_offset
304
- if @utc_offset
305
- @utc_offset
306
- else
307
- tzinfo.current_period.utc_offset if tzinfo && tzinfo.current_period
308
- end
305
+ @utc_offset || tzinfo&.current_period&.base_utc_offset
309
306
  end
310
307
 
311
308
  # Returns a formatted string of the offset from UTC, or an alternative
@@ -333,6 +330,13 @@ module ActiveSupport
333
330
  re === name || re === MAPPING[name]
334
331
  end
335
332
 
333
+ # Compare #name and TZInfo identifier to a supplied regexp, returning +true+
334
+ # if a match is found.
335
+ def match?(re)
336
+ (re == name) || (re == MAPPING[name]) ||
337
+ ((Regexp === re) && (re.match?(name) || re.match?(MAPPING[name])))
338
+ end
339
+
336
340
  # Returns a textual representation of this time zone.
337
341
  def to_s
338
342
  "(GMT#{formatted_offset}) #{name}"
@@ -354,8 +358,13 @@ module ActiveSupport
354
358
  # Time.zone = 'Hawaii' # => "Hawaii"
355
359
  # Time.utc(2000).to_f # => 946684800.0
356
360
  # Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00
357
- def at(secs)
358
- Time.at(secs).utc.in_time_zone(self)
361
+ #
362
+ # A second argument can be supplied to specify sub-second precision.
363
+ #
364
+ # Time.zone = 'Hawaii' # => "Hawaii"
365
+ # Time.at(946684800, 123456.789).nsec # => 123456789
366
+ def at(*args)
367
+ Time.at(*args).utc.in_time_zone(self)
359
368
  end
360
369
 
361
370
  # Method for creating new ActiveSupport::TimeWithZone instance in time zone
@@ -494,10 +503,17 @@ module ActiveSupport
494
503
  end
495
504
 
496
505
  # Adjust the given time to the simultaneous time in the time zone
497
- # represented by +self+. Returns a Time.utc() instance -- if you want an
498
- # ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead.
506
+ # represented by +self+. Returns a local time with the appropriate offset
507
+ # -- if you want an ActiveSupport::TimeWithZone instance, use
508
+ # Time#in_time_zone() instead.
509
+ #
510
+ # As of tzinfo 2, utc_to_local returns a Time with a non-zero utc_offset.
511
+ # See the `utc_to_local_returns_utc_offset_times` config for more info.
499
512
  def utc_to_local(time)
500
- tzinfo.utc_to_local(time)
513
+ tzinfo.utc_to_local(time).yield_self do |t|
514
+ ActiveSupport.utc_to_local_returns_utc_offset_times ?
515
+ t : Time.utc(t.year, t.month, t.day, t.hour, t.min, t.sec, t.sec_fraction)
516
+ end
501
517
  end
502
518
 
503
519
  # Adjust the given time to the simultaneous time in UTC. Returns a
@@ -18,7 +18,7 @@ module ActiveSupport
18
18
  module XmlMini_JDOM #:nodoc:
19
19
  extend self
20
20
 
21
- CONTENT_KEY = "__content__".freeze
21
+ CONTENT_KEY = "__content__"
22
22
 
23
23
  NODE_TYPE_NAMES = %w{ATTRIBUTE_NODE CDATA_SECTION_NODE COMMENT_NODE DOCUMENT_FRAGMENT_NODE
24
24
  DOCUMENT_NODE DOCUMENT_TYPE_NODE ELEMENT_NODE ENTITY_NODE ENTITY_REFERENCE_NODE NOTATION_NODE
@@ -53,7 +53,6 @@ module ActiveSupport
53
53
  end
54
54
 
55
55
  private
56
-
57
56
  # Convert an XML element and merge into the hash
58
57
  #
59
58
  # hash::
@@ -169,7 +168,7 @@ module ActiveSupport
169
168
  # element::
170
169
  # XML element to be checked.
171
170
  def empty_content?(element)
172
- text = "".dup
171
+ text = +""
173
172
  child_nodes = element.child_nodes
174
173
  (0...child_nodes.length).each do |i|
175
174
  item = child_nodes.item(i)
@@ -34,7 +34,7 @@ module LibXML #:nodoc:
34
34
  end
35
35
 
36
36
  module Node #:nodoc:
37
- CONTENT_ROOT = "__content__".freeze
37
+ CONTENT_ROOT = "__content__"
38
38
 
39
39
  # Convert XML document to hash.
40
40
  #
@@ -55,7 +55,7 @@ module LibXML #:nodoc:
55
55
  if c.element?
56
56
  c.to_hash(node_hash)
57
57
  elsif c.text? || c.cdata?
58
- node_hash[CONTENT_ROOT] ||= "".dup
58
+ node_hash[CONTENT_ROOT] ||= +""
59
59
  node_hash[CONTENT_ROOT] << c.content
60
60
  end
61
61
  end
@@ -13,8 +13,8 @@ module ActiveSupport
13
13
  class HashBuilder
14
14
  include LibXML::XML::SaxParser::Callbacks
15
15
 
16
- CONTENT_KEY = "__content__".freeze
17
- HASH_SIZE_KEY = "__hash_size__".freeze
16
+ CONTENT_KEY = "__content__"
17
+ HASH_SIZE_KEY = "__hash_size__"
18
18
 
19
19
  attr_reader :hash
20
20
 
@@ -23,7 +23,7 @@ module ActiveSupport
23
23
  end
24
24
 
25
25
  def on_start_document
26
- @hash = { CONTENT_KEY => "".dup }
26
+ @hash = { CONTENT_KEY => +"" }
27
27
  @hash_stack = [@hash]
28
28
  end
29
29
 
@@ -33,7 +33,7 @@ module ActiveSupport
33
33
  end
34
34
 
35
35
  def on_start_element(name, attrs = {})
36
- new_hash = { CONTENT_KEY => "".dup }.merge!(attrs)
36
+ new_hash = { CONTENT_KEY => +"" }.merge!(attrs)
37
37
  new_hash[HASH_SIZE_KEY] = new_hash.size + 1
38
38
 
39
39
  case current_hash[name]
@@ -38,7 +38,7 @@ module ActiveSupport
38
38
  end
39
39
 
40
40
  module Node #:nodoc:
41
- CONTENT_ROOT = "__content__".freeze
41
+ CONTENT_ROOT = "__content__"
42
42
 
43
43
  # Convert XML document to hash.
44
44
  #
@@ -59,7 +59,7 @@ module ActiveSupport
59
59
  if c.element?
60
60
  c.to_hash(node_hash)
61
61
  elsif c.text? || c.cdata?
62
- node_hash[CONTENT_ROOT] ||= "".dup
62
+ node_hash[CONTENT_ROOT] ||= +""
63
63
  node_hash[CONTENT_ROOT] << c.content
64
64
  end
65
65
  end
@@ -16,8 +16,8 @@ module ActiveSupport
16
16
  # Class that will build the hash while the XML document
17
17
  # is being parsed using SAX events.
18
18
  class HashBuilder < Nokogiri::XML::SAX::Document
19
- CONTENT_KEY = "__content__".freeze
20
- HASH_SIZE_KEY = "__hash_size__".freeze
19
+ CONTENT_KEY = "__content__"
20
+ HASH_SIZE_KEY = "__hash_size__"
21
21
 
22
22
  attr_reader :hash
23
23
 
@@ -39,7 +39,7 @@ module ActiveSupport
39
39
  end
40
40
 
41
41
  def start_element(name, attrs = [])
42
- new_hash = { CONTENT_KEY => "".dup }.merge!(Hash[attrs])
42
+ new_hash = { CONTENT_KEY => +"" }.merge!(Hash[attrs])
43
43
  new_hash[HASH_SIZE_KEY] = new_hash.size + 1
44
44
 
45
45
  case current_hash[name]
@@ -8,7 +8,7 @@ module ActiveSupport
8
8
  module XmlMini_REXML #:nodoc:
9
9
  extend self
10
10
 
11
- CONTENT_KEY = "__content__".freeze
11
+ CONTENT_KEY = "__content__"
12
12
 
13
13
  # Parse an XML Document string or IO into a simple hash.
14
14
  #
@@ -25,7 +25,7 @@ module ActiveSupport
25
25
  if data.eof?
26
26
  {}
27
27
  else
28
- silence_warnings { require "rexml/document" } unless defined?(REXML::Document)
28
+ require_rexml unless defined?(REXML::Document)
29
29
  doc = REXML::Document.new(data)
30
30
 
31
31
  if doc.root
@@ -38,6 +38,13 @@ module ActiveSupport
38
38
  end
39
39
 
40
40
  private
41
+ def require_rexml
42
+ silence_warnings { require "rexml/document" }
43
+ rescue LoadError => e
44
+ $stderr.puts "You don't have rexml installed in your application. Please add it to your Gemfile and run bundle install"
45
+ raise e
46
+ end
47
+
41
48
  # Convert an XML element and merge into the hash
42
49
  #
43
50
  # hash::
@@ -76,7 +83,7 @@ module ActiveSupport
76
83
  hash
77
84
  else
78
85
  # must use value to prevent double-escaping
79
- texts = "".dup
86
+ texts = +""
80
87
  element.texts.each { |t| texts << t.value }
81
88
  merge!(hash, CONTENT_KEY, texts)
82
89
  end
@@ -3,6 +3,7 @@
3
3
  require "time"
4
4
  require "base64"
5
5
  require "bigdecimal"
6
+ require "bigdecimal/util"
6
7
  require "active_support/core_ext/module/delegation"
7
8
  require "active_support/core_ext/string/inflections"
8
9
  require "active_support/core_ext/date_time/calculations"
@@ -48,10 +49,6 @@ module ActiveSupport
48
49
  "Array" => "array",
49
50
  "Hash" => "hash"
50
51
  }
51
-
52
- # No need to map these on Ruby 2.4+
53
- TYPE_NAMES["Fixnum"] = "integer" unless 0.class == Integer
54
- TYPE_NAMES["Bignum"] = "integer" unless 0.class == Integer
55
52
  end
56
53
 
57
54
  FORMATTING = {
@@ -72,11 +69,7 @@ module ActiveSupport
72
69
  "float" => Proc.new { |float| float.to_f },
73
70
  "decimal" => Proc.new do |number|
74
71
  if String === number
75
- begin
76
- BigDecimal(number)
77
- rescue ArgumentError
78
- BigDecimal("0")
79
- end
72
+ number.to_d
80
73
  else
81
74
  BigDecimal(number)
82
75
  end
@@ -162,7 +155,6 @@ module ActiveSupport
162
155
  end
163
156
 
164
157
  private
165
-
166
158
  def _dasherize(key)
167
159
  # $2 must be a non-greedy regex for this to work
168
160
  left, middle, right = /\A(_*)(.*?)(_*)\Z/.match(key.strip)[1, 3]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2005-2018 David Heinemeier Hansson
4
+ # Copyright (c) 2005-2020 David Heinemeier Hansson
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
@@ -34,6 +34,8 @@ module ActiveSupport
34
34
  extend ActiveSupport::Autoload
35
35
 
36
36
  autoload :Concern
37
+ autoload :ActionableError
38
+ autoload :ConfigurationFile
37
39
  autoload :CurrentAttributes
38
40
  autoload :Dependencies
39
41
  autoload :DescendantsTracker
@@ -41,9 +43,11 @@ module ActiveSupport
41
43
  autoload :Executor
42
44
  autoload :FileUpdateChecker
43
45
  autoload :EventedFileUpdateChecker
46
+ autoload :ForkTracker
44
47
  autoload :LogSubscriber
45
48
  autoload :Notifications
46
49
  autoload :Reloader
50
+ autoload :SecureCompareRotator
47
51
 
48
52
  eager_autoload do
49
53
  autoload :BacktraceCleaner
@@ -66,6 +70,7 @@ module ActiveSupport
66
70
  autoload :OrderedHash
67
71
  autoload :OrderedOptions
68
72
  autoload :StringInquirer
73
+ autoload :EnvironmentInquirer
69
74
  autoload :TaggedLogging
70
75
  autoload :XmlMini
71
76
  autoload :ArrayInquirer
@@ -90,6 +95,14 @@ module ActiveSupport
90
95
  def self.to_time_preserves_timezone=(value)
91
96
  DateAndTime::Compatibility.preserve_timezone = value
92
97
  end
98
+
99
+ def self.utc_to_local_returns_utc_offset_times
100
+ DateAndTime::Compatibility.utc_to_local_returns_utc_offset_times
101
+ end
102
+
103
+ def self.utc_to_local_returns_utc_offset_times=(value)
104
+ DateAndTime::Compatibility.utc_to_local_returns_utc_offset_times = value
105
+ end
93
106
  end
94
107
 
95
108
  autoload :I18n, "active_support/i18n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.7'
19
+ version: '1.6'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '0.7'
29
+ version: '1.6'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2'
@@ -36,48 +36,62 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.1'
39
+ version: '2.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.1'
46
+ version: '2.0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: minitest
48
+ name: concurrent-ruby
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '5.1'
53
+ version: '1.0'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.0.2
54
57
  type: :runtime
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  requirements:
58
61
  - - "~>"
59
62
  - !ruby/object:Gem::Version
60
- version: '5.1'
63
+ version: '1.0'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.0.2
61
67
  - !ruby/object:Gem::Dependency
62
- name: concurrent-ruby
68
+ name: zeitwerk
63
69
  requirement: !ruby/object:Gem::Requirement
64
70
  requirements:
65
71
  - - "~>"
66
72
  - !ruby/object:Gem::Version
67
- version: '1.0'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 1.0.2
73
+ version: '2.3'
71
74
  type: :runtime
72
75
  prerelease: false
73
76
  version_requirements: !ruby/object:Gem::Requirement
74
77
  requirements:
75
78
  - - "~>"
76
79
  - !ruby/object:Gem::Version
77
- version: '1.0'
80
+ version: '2.3'
81
+ - !ruby/object:Gem::Dependency
82
+ name: minitest
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
78
85
  - - ">="
79
86
  - !ruby/object:Gem::Version
80
- version: 1.0.2
87
+ version: '5.1'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '5.1'
81
95
  description: A toolkit of support libraries and Ruby core extensions extracted from
82
96
  the Rails framework. Rich support for multibyte strings, internationalization, time
83
97
  zones, and testing.
@@ -90,6 +104,7 @@ files:
90
104
  - MIT-LICENSE
91
105
  - README.rdoc
92
106
  - lib/active_support.rb
107
+ - lib/active_support/actionable_error.rb
93
108
  - lib/active_support/all.rb
94
109
  - lib/active_support/array_inquirer.rb
95
110
  - lib/active_support/backtrace_cleaner.rb
@@ -108,14 +123,15 @@ files:
108
123
  - lib/active_support/concurrency/load_interlock_aware_monitor.rb
109
124
  - lib/active_support/concurrency/share_lock.rb
110
125
  - lib/active_support/configurable.rb
126
+ - lib/active_support/configuration_file.rb
111
127
  - lib/active_support/core_ext.rb
112
128
  - lib/active_support/core_ext/array.rb
113
129
  - lib/active_support/core_ext/array/access.rb
114
130
  - lib/active_support/core_ext/array/conversions.rb
131
+ - lib/active_support/core_ext/array/extract.rb
115
132
  - lib/active_support/core_ext/array/extract_options.rb
116
133
  - lib/active_support/core_ext/array/grouping.rb
117
134
  - lib/active_support/core_ext/array/inquiry.rb
118
- - lib/active_support/core_ext/array/prepend_and_append.rb
119
135
  - lib/active_support/core_ext/array/wrap.rb
120
136
  - lib/active_support/core_ext/benchmark.rb
121
137
  - lib/active_support/core_ext/big_decimal.rb
@@ -139,26 +155,25 @@ files:
139
155
  - lib/active_support/core_ext/date_time/calculations.rb
140
156
  - lib/active_support/core_ext/date_time/compatibility.rb
141
157
  - lib/active_support/core_ext/date_time/conversions.rb
158
+ - lib/active_support/core_ext/digest.rb
142
159
  - lib/active_support/core_ext/digest/uuid.rb
143
160
  - lib/active_support/core_ext/enumerable.rb
144
161
  - lib/active_support/core_ext/file.rb
145
162
  - lib/active_support/core_ext/file/atomic.rb
146
163
  - lib/active_support/core_ext/hash.rb
147
- - lib/active_support/core_ext/hash/compact.rb
148
164
  - lib/active_support/core_ext/hash/conversions.rb
149
165
  - lib/active_support/core_ext/hash/deep_merge.rb
166
+ - lib/active_support/core_ext/hash/deep_transform_values.rb
150
167
  - lib/active_support/core_ext/hash/except.rb
151
168
  - lib/active_support/core_ext/hash/indifferent_access.rb
152
169
  - lib/active_support/core_ext/hash/keys.rb
153
170
  - lib/active_support/core_ext/hash/reverse_merge.rb
154
171
  - lib/active_support/core_ext/hash/slice.rb
155
- - lib/active_support/core_ext/hash/transform_values.rb
156
172
  - lib/active_support/core_ext/integer.rb
157
173
  - lib/active_support/core_ext/integer/inflections.rb
158
174
  - lib/active_support/core_ext/integer/multiple.rb
159
175
  - lib/active_support/core_ext/integer/time.rb
160
176
  - lib/active_support/core_ext/kernel.rb
161
- - lib/active_support/core_ext/kernel/agnostics.rb
162
177
  - lib/active_support/core_ext/kernel/concern.rb
163
178
  - lib/active_support/core_ext/kernel/reporting.rb
164
179
  - lib/active_support/core_ext/kernel/singleton_class.rb
@@ -174,14 +189,12 @@ files:
174
189
  - lib/active_support/core_ext/module/delegation.rb
175
190
  - lib/active_support/core_ext/module/deprecation.rb
176
191
  - lib/active_support/core_ext/module/introspection.rb
177
- - lib/active_support/core_ext/module/reachable.rb
178
192
  - lib/active_support/core_ext/module/redefine_method.rb
179
193
  - lib/active_support/core_ext/module/remove_method.rb
180
194
  - lib/active_support/core_ext/name_error.rb
181
195
  - lib/active_support/core_ext/numeric.rb
182
196
  - lib/active_support/core_ext/numeric/bytes.rb
183
197
  - lib/active_support/core_ext/numeric/conversions.rb
184
- - lib/active_support/core_ext/numeric/inquiry.rb
185
198
  - lib/active_support/core_ext/numeric/time.rb
186
199
  - lib/active_support/core_ext/object.rb
187
200
  - lib/active_support/core_ext/object/acts_like.rb
@@ -197,9 +210,9 @@ files:
197
210
  - lib/active_support/core_ext/object/try.rb
198
211
  - lib/active_support/core_ext/object/with_options.rb
199
212
  - lib/active_support/core_ext/range.rb
213
+ - lib/active_support/core_ext/range/compare_range.rb
200
214
  - lib/active_support/core_ext/range/conversions.rb
201
215
  - lib/active_support/core_ext/range/each.rb
202
- - lib/active_support/core_ext/range/include_range.rb
203
216
  - lib/active_support/core_ext/range/include_time_with_zone.rb
204
217
  - lib/active_support/core_ext/range/overlaps.rb
205
218
  - lib/active_support/core_ext/regexp.rb
@@ -218,6 +231,8 @@ files:
218
231
  - lib/active_support/core_ext/string/starts_ends_with.rb
219
232
  - lib/active_support/core_ext/string/strip.rb
220
233
  - lib/active_support/core_ext/string/zones.rb
234
+ - lib/active_support/core_ext/symbol.rb
235
+ - lib/active_support/core_ext/symbol/starts_ends_with.rb
221
236
  - lib/active_support/core_ext/time.rb
222
237
  - lib/active_support/core_ext/time/acts_like.rb
223
238
  - lib/active_support/core_ext/time/calculations.rb
@@ -226,12 +241,15 @@ files:
226
241
  - lib/active_support/core_ext/time/zones.rb
227
242
  - lib/active_support/core_ext/uri.rb
228
243
  - lib/active_support/current_attributes.rb
244
+ - lib/active_support/current_attributes/test_helper.rb
229
245
  - lib/active_support/dependencies.rb
230
246
  - lib/active_support/dependencies/autoload.rb
231
247
  - lib/active_support/dependencies/interlock.rb
248
+ - lib/active_support/dependencies/zeitwerk_integration.rb
232
249
  - lib/active_support/deprecation.rb
233
250
  - lib/active_support/deprecation/behaviors.rb
234
251
  - lib/active_support/deprecation/constant_accessor.rb
252
+ - lib/active_support/deprecation/disallowed.rb
235
253
  - lib/active_support/deprecation/instance_delegator.rb
236
254
  - lib/active_support/deprecation/method_wrappers.rb
237
255
  - lib/active_support/deprecation/proxy_wrappers.rb
@@ -243,10 +261,12 @@ files:
243
261
  - lib/active_support/duration/iso8601_serializer.rb
244
262
  - lib/active_support/encrypted_configuration.rb
245
263
  - lib/active_support/encrypted_file.rb
264
+ - lib/active_support/environment_inquirer.rb
246
265
  - lib/active_support/evented_file_update_checker.rb
247
266
  - lib/active_support/execution_wrapper.rb
248
267
  - lib/active_support/executor.rb
249
268
  - lib/active_support/file_update_checker.rb
269
+ - lib/active_support/fork_tracker.rb
250
270
  - lib/active_support/gem_version.rb
251
271
  - lib/active_support/gzip.rb
252
272
  - lib/active_support/hash_with_indifferent_access.rb
@@ -262,6 +282,7 @@ files:
262
282
  - lib/active_support/json/encoding.rb
263
283
  - lib/active_support/key_generator.rb
264
284
  - lib/active_support/lazy_load_hooks.rb
285
+ - lib/active_support/locale/en.rb
265
286
  - lib/active_support/locale/en.yml
266
287
  - lib/active_support/log_subscriber.rb
267
288
  - lib/active_support/log_subscriber/test_helper.rb
@@ -292,12 +313,14 @@ files:
292
313
  - lib/active_support/option_merger.rb
293
314
  - lib/active_support/ordered_hash.rb
294
315
  - lib/active_support/ordered_options.rb
316
+ - lib/active_support/parameter_filter.rb
295
317
  - lib/active_support/per_thread_registry.rb
296
318
  - lib/active_support/proxy_object.rb
297
319
  - lib/active_support/rails.rb
298
320
  - lib/active_support/railtie.rb
299
321
  - lib/active_support/reloader.rb
300
322
  - lib/active_support/rescuable.rb
323
+ - lib/active_support/secure_compare_rotator.rb
301
324
  - lib/active_support/security_utils.rb
302
325
  - lib/active_support/string_inquirer.rb
303
326
  - lib/active_support/subscriber.rb
@@ -311,6 +334,9 @@ files:
311
334
  - lib/active_support/testing/file_fixtures.rb
312
335
  - lib/active_support/testing/isolation.rb
313
336
  - lib/active_support/testing/method_call_assertions.rb
337
+ - lib/active_support/testing/parallelization.rb
338
+ - lib/active_support/testing/parallelization/server.rb
339
+ - lib/active_support/testing/parallelization/worker.rb
314
340
  - lib/active_support/testing/setup_and_teardown.rb
315
341
  - lib/active_support/testing/stream.rb
316
342
  - lib/active_support/testing/tagged_logging.rb
@@ -318,7 +344,6 @@ files:
318
344
  - lib/active_support/time.rb
319
345
  - lib/active_support/time_with_zone.rb
320
346
  - lib/active_support/values/time_zone.rb
321
- - lib/active_support/values/unicode_tables.dat
322
347
  - lib/active_support/version.rb
323
348
  - lib/active_support/xml_mini.rb
324
349
  - lib/active_support/xml_mini/jdom.rb
@@ -327,12 +352,15 @@ files:
327
352
  - lib/active_support/xml_mini/nokogiri.rb
328
353
  - lib/active_support/xml_mini/nokogirisax.rb
329
354
  - lib/active_support/xml_mini/rexml.rb
330
- homepage: http://rubyonrails.org
355
+ homepage: https://rubyonrails.org
331
356
  licenses:
332
357
  - MIT
333
358
  metadata:
334
- source_code_uri: https://github.com/rails/rails/tree/v5.2.0/activesupport
335
- changelog_uri: https://github.com/rails/rails/blob/v5.2.0/activesupport/CHANGELOG.md
359
+ bug_tracker_uri: https://github.com/rails/rails/issues
360
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.0/activesupport/CHANGELOG.md
361
+ documentation_uri: https://api.rubyonrails.org/v6.1.0/
362
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
363
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.0/activesupport
336
364
  post_install_message:
337
365
  rdoc_options:
338
366
  - "--encoding"
@@ -343,15 +371,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
343
371
  requirements:
344
372
  - - ">="
345
373
  - !ruby/object:Gem::Version
346
- version: 2.2.2
374
+ version: 2.5.0
347
375
  required_rubygems_version: !ruby/object:Gem::Requirement
348
376
  requirements:
349
377
  - - ">="
350
378
  - !ruby/object:Gem::Version
351
379
  version: '0'
352
380
  requirements: []
353
- rubyforge_project:
354
- rubygems_version: 2.7.6
381
+ rubygems_version: 3.1.4
355
382
  signing_key:
356
383
  specification_version: 4
357
384
  summary: A toolkit of support libraries and Ruby core extensions extracted from the
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Array
4
- # The human way of thinking about adding stuff to the end of a list is with append.
5
- alias_method :append, :push unless [].respond_to?(:append)
6
-
7
- # The human way of thinking about adding stuff to the beginning of a list is with prepend.
8
- alias_method :prepend, :unshift unless [].respond_to?(:prepend)
9
- end