activesupport 5.2.8.1 → 6.1.6.1

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

Potentially problematic release.


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

Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +426 -424
  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 +34 -34
  10. data/lib/active_support/cache/mem_cache_store.rb +39 -24
  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 +72 -45
  14. data/lib/active_support/cache/strategy/local_cache.rb +41 -26
  15. data/lib/active_support/cache.rb +148 -78
  16. data/lib/active_support/callbacks.rb +81 -64
  17. data/lib/active_support/concern.rb +70 -3
  18. data/lib/active_support/concurrency/share_lock.rb +0 -1
  19. data/lib/active_support/configurable.rb +10 -14
  20. data/lib/active_support/configuration_file.rb +51 -0
  21. data/lib/active_support/core_ext/array/access.rb +18 -6
  22. data/lib/active_support/core_ext/array/conversions.rb +5 -5
  23. data/lib/active_support/core_ext/array/extract.rb +21 -0
  24. data/lib/active_support/core_ext/array.rb +1 -1
  25. data/lib/active_support/core_ext/benchmark.rb +2 -2
  26. data/lib/active_support/core_ext/class/attribute.rb +32 -47
  27. data/lib/active_support/core_ext/class/subclasses.rb +17 -38
  28. data/lib/active_support/core_ext/date/calculations.rb +6 -5
  29. data/lib/active_support/core_ext/date/conversions.rb +2 -1
  30. data/lib/active_support/core_ext/date_and_time/calculations.rb +37 -47
  31. data/lib/active_support/core_ext/date_and_time/compatibility.rb +15 -0
  32. data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
  33. data/lib/active_support/core_ext/date_time/calculations.rb +1 -1
  34. data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
  35. data/lib/active_support/core_ext/digest/uuid.rb +1 -0
  36. data/lib/active_support/core_ext/enumerable.rb +171 -75
  37. data/lib/active_support/core_ext/hash/conversions.rb +3 -3
  38. data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
  39. data/lib/active_support/core_ext/hash/except.rb +2 -2
  40. data/lib/active_support/core_ext/hash/keys.rb +1 -30
  41. data/lib/active_support/core_ext/hash/slice.rb +6 -27
  42. data/lib/active_support/core_ext/hash.rb +1 -2
  43. data/lib/active_support/core_ext/integer/multiple.rb +1 -1
  44. data/lib/active_support/core_ext/kernel.rb +0 -1
  45. data/lib/active_support/core_ext/load_error.rb +1 -1
  46. data/lib/active_support/core_ext/marshal.rb +2 -0
  47. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  48. data/lib/active_support/core_ext/module/attribute_accessors.rb +30 -39
  49. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +17 -19
  50. data/lib/active_support/core_ext/module/concerning.rb +8 -2
  51. data/lib/active_support/core_ext/module/delegation.rb +76 -33
  52. data/lib/active_support/core_ext/module/introspection.rb +16 -15
  53. data/lib/active_support/core_ext/module/redefine_method.rb +8 -17
  54. data/lib/active_support/core_ext/module.rb +0 -1
  55. data/lib/active_support/core_ext/name_error.rb +29 -2
  56. data/lib/active_support/core_ext/numeric/conversions.rb +129 -129
  57. data/lib/active_support/core_ext/numeric.rb +0 -1
  58. data/lib/active_support/core_ext/object/blank.rb +1 -2
  59. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  60. data/lib/active_support/core_ext/object/duplicable.rb +7 -114
  61. data/lib/active_support/core_ext/object/json.rb +14 -2
  62. data/lib/active_support/core_ext/object/try.rb +17 -7
  63. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  64. data/lib/active_support/core_ext/range/compare_range.rb +34 -13
  65. data/lib/active_support/core_ext/range/conversions.rb +31 -29
  66. data/lib/active_support/core_ext/range/each.rb +0 -1
  67. data/lib/active_support/core_ext/range/include_time_with_zone.rb +8 -3
  68. data/lib/active_support/core_ext/regexp.rb +8 -5
  69. data/lib/active_support/core_ext/securerandom.rb +23 -3
  70. data/lib/active_support/core_ext/string/access.rb +5 -16
  71. data/lib/active_support/core_ext/string/conversions.rb +1 -0
  72. data/lib/active_support/core_ext/string/filters.rb +42 -1
  73. data/lib/active_support/core_ext/string/inflections.rb +45 -6
  74. data/lib/active_support/core_ext/string/inquiry.rb +1 -0
  75. data/lib/active_support/core_ext/string/multibyte.rb +6 -5
  76. data/lib/active_support/core_ext/string/output_safety.rb +70 -13
  77. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -2
  78. data/lib/active_support/core_ext/string/strip.rb +3 -1
  79. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +14 -0
  80. data/lib/active_support/core_ext/symbol.rb +3 -0
  81. data/lib/active_support/core_ext/time/calculations.rb +53 -3
  82. data/lib/active_support/core_ext/time/conversions.rb +2 -0
  83. data/lib/active_support/core_ext/uri.rb +6 -1
  84. data/lib/active_support/core_ext.rb +1 -1
  85. data/lib/active_support/current_attributes/test_helper.rb +13 -0
  86. data/lib/active_support/current_attributes.rb +16 -2
  87. data/lib/active_support/dependencies/zeitwerk_integration.rb +120 -0
  88. data/lib/active_support/dependencies.rb +109 -34
  89. data/lib/active_support/deprecation/behaviors.rb +16 -3
  90. data/lib/active_support/deprecation/disallowed.rb +56 -0
  91. data/lib/active_support/deprecation/instance_delegator.rb +0 -1
  92. data/lib/active_support/deprecation/method_wrappers.rb +18 -23
  93. data/lib/active_support/deprecation/proxy_wrappers.rb +29 -6
  94. data/lib/active_support/deprecation/reporting.rb +50 -7
  95. data/lib/active_support/deprecation.rb +6 -1
  96. data/lib/active_support/descendants_tracker.rb +59 -9
  97. data/lib/active_support/digest.rb +2 -0
  98. data/lib/active_support/duration/iso8601_parser.rb +2 -4
  99. data/lib/active_support/duration/iso8601_serializer.rb +18 -14
  100. data/lib/active_support/duration.rb +82 -33
  101. data/lib/active_support/encrypted_configuration.rb +0 -4
  102. data/lib/active_support/encrypted_file.rb +22 -4
  103. data/lib/active_support/environment_inquirer.rb +20 -0
  104. data/lib/active_support/evented_file_update_checker.rb +82 -117
  105. data/lib/active_support/execution_wrapper.rb +2 -1
  106. data/lib/active_support/file_update_checker.rb +0 -1
  107. data/lib/active_support/fork_tracker.rb +64 -0
  108. data/lib/active_support/gem_version.rb +3 -3
  109. data/lib/active_support/hash_with_indifferent_access.rb +70 -42
  110. data/lib/active_support/i18n.rb +1 -0
  111. data/lib/active_support/i18n_railtie.rb +15 -8
  112. data/lib/active_support/inflector/inflections.rb +2 -7
  113. data/lib/active_support/inflector/methods.rb +49 -58
  114. data/lib/active_support/inflector/transliterate.rb +47 -18
  115. data/lib/active_support/json/decoding.rb +25 -26
  116. data/lib/active_support/json/encoding.rb +11 -3
  117. data/lib/active_support/key_generator.rb +1 -33
  118. data/lib/active_support/lazy_load_hooks.rb +5 -2
  119. data/lib/active_support/locale/en.rb +33 -0
  120. data/lib/active_support/locale/en.yml +7 -3
  121. data/lib/active_support/log_subscriber.rb +39 -9
  122. data/lib/active_support/logger.rb +2 -17
  123. data/lib/active_support/logger_silence.rb +11 -19
  124. data/lib/active_support/logger_thread_safe_level.rb +50 -6
  125. data/lib/active_support/message_encryptor.rb +8 -13
  126. data/lib/active_support/message_verifier.rb +10 -10
  127. data/lib/active_support/messages/metadata.rb +11 -2
  128. data/lib/active_support/messages/rotation_configuration.rb +2 -1
  129. data/lib/active_support/messages/rotator.rb +10 -9
  130. data/lib/active_support/multibyte/chars.rb +10 -68
  131. data/lib/active_support/multibyte/unicode.rb +15 -327
  132. data/lib/active_support/notifications/fanout.rb +116 -16
  133. data/lib/active_support/notifications/instrumenter.rb +71 -9
  134. data/lib/active_support/notifications.rb +72 -8
  135. data/lib/active_support/number_helper/number_converter.rb +5 -6
  136. data/lib/active_support/number_helper/number_to_currency_converter.rb +4 -9
  137. data/lib/active_support/number_helper/number_to_delimited_converter.rb +3 -2
  138. data/lib/active_support/number_helper/number_to_human_converter.rb +4 -3
  139. data/lib/active_support/number_helper/number_to_human_size_converter.rb +4 -3
  140. data/lib/active_support/number_helper/number_to_percentage_converter.rb +3 -1
  141. data/lib/active_support/number_helper/number_to_phone_converter.rb +2 -1
  142. data/lib/active_support/number_helper/number_to_rounded_converter.rb +12 -7
  143. data/lib/active_support/number_helper/rounding_helper.rb +12 -28
  144. data/lib/active_support/number_helper.rb +38 -12
  145. data/lib/active_support/option_merger.rb +22 -3
  146. data/lib/active_support/ordered_hash.rb +1 -1
  147. data/lib/active_support/ordered_options.rb +13 -3
  148. data/lib/active_support/parameter_filter.rb +133 -0
  149. data/lib/active_support/per_thread_registry.rb +2 -1
  150. data/lib/active_support/rails.rb +1 -10
  151. data/lib/active_support/railtie.rb +23 -1
  152. data/lib/active_support/reloader.rb +4 -5
  153. data/lib/active_support/rescuable.rb +4 -4
  154. data/lib/active_support/secure_compare_rotator.rb +51 -0
  155. data/lib/active_support/security_utils.rb +19 -12
  156. data/lib/active_support/string_inquirer.rb +4 -3
  157. data/lib/active_support/subscriber.rb +72 -28
  158. data/lib/active_support/tagged_logging.rb +42 -8
  159. data/lib/active_support/test_case.rb +91 -0
  160. data/lib/active_support/testing/assertions.rb +30 -9
  161. data/lib/active_support/testing/deprecation.rb +0 -1
  162. data/lib/active_support/testing/file_fixtures.rb +2 -0
  163. data/lib/active_support/testing/isolation.rb +2 -2
  164. data/lib/active_support/testing/method_call_assertions.rb +28 -1
  165. data/lib/active_support/testing/parallelization/server.rb +78 -0
  166. data/lib/active_support/testing/parallelization/worker.rb +100 -0
  167. data/lib/active_support/testing/parallelization.rb +51 -0
  168. data/lib/active_support/testing/stream.rb +1 -2
  169. data/lib/active_support/testing/time_helpers.rb +47 -12
  170. data/lib/active_support/time_with_zone.rb +81 -47
  171. data/lib/active_support/values/time_zone.rb +34 -17
  172. data/lib/active_support/xml_mini/jdom.rb +2 -3
  173. data/lib/active_support/xml_mini/libxml.rb +2 -2
  174. data/lib/active_support/xml_mini/libxmlsax.rb +4 -4
  175. data/lib/active_support/xml_mini/nokogiri.rb +2 -2
  176. data/lib/active_support/xml_mini/nokogirisax.rb +3 -3
  177. data/lib/active_support/xml_mini/rexml.rb +10 -3
  178. data/lib/active_support/xml_mini.rb +2 -10
  179. data/lib/active_support.rb +14 -1
  180. metadata +54 -27
  181. data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -9
  182. data/lib/active_support/core_ext/hash/compact.rb +0 -29
  183. data/lib/active_support/core_ext/hash/transform_values.rb +0 -32
  184. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -13
  185. data/lib/active_support/core_ext/module/reachable.rb +0 -11
  186. data/lib/active_support/core_ext/numeric/inquiry.rb +0 -28
  187. data/lib/active_support/core_ext/range/include_range.rb +0 -3
  188. 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,16 +266,16 @@ 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
@@ -302,11 +302,7 @@ module ActiveSupport
302
302
 
303
303
  # Returns the offset of this time zone from UTC in seconds.
304
304
  def utc_offset
305
- if @utc_offset
306
- @utc_offset
307
- else
308
- tzinfo.current_period.utc_offset if tzinfo && tzinfo.current_period
309
- end
305
+ @utc_offset || tzinfo&.current_period&.base_utc_offset
310
306
  end
311
307
 
312
308
  # Returns a formatted string of the offset from UTC, or an alternative
@@ -334,6 +330,13 @@ module ActiveSupport
334
330
  re === name || re === MAPPING[name]
335
331
  end
336
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
+
337
340
  # Returns a textual representation of this time zone.
338
341
  def to_s
339
342
  "(GMT#{formatted_offset}) #{name}"
@@ -355,8 +358,13 @@ module ActiveSupport
355
358
  # Time.zone = 'Hawaii' # => "Hawaii"
356
359
  # Time.utc(2000).to_f # => 946684800.0
357
360
  # Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00
358
- def at(secs)
359
- 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)
360
368
  end
361
369
 
362
370
  # Method for creating new ActiveSupport::TimeWithZone instance in time zone
@@ -373,6 +381,8 @@ module ActiveSupport
373
381
  # If the string is invalid then an +ArgumentError+ will be raised unlike +parse+
374
382
  # which usually returns +nil+ when given an invalid date string.
375
383
  def iso8601(str)
384
+ raise ArgumentError, "invalid date" if str.nil?
385
+
376
386
  parts = Date._iso8601(str)
377
387
 
378
388
  raise ArgumentError, "invalid date" if parts.empty?
@@ -495,10 +505,17 @@ module ActiveSupport
495
505
  end
496
506
 
497
507
  # Adjust the given time to the simultaneous time in the time zone
498
- # represented by +self+. Returns a Time.utc() instance -- if you want an
499
- # ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead.
508
+ # represented by +self+. Returns a local time with the appropriate offset
509
+ # -- if you want an ActiveSupport::TimeWithZone instance, use
510
+ # Time#in_time_zone() instead.
511
+ #
512
+ # As of tzinfo 2, utc_to_local returns a Time with a non-zero utc_offset.
513
+ # See the +utc_to_local_returns_utc_offset_times+ config for more info.
500
514
  def utc_to_local(time)
501
- tzinfo.utc_to_local(time)
515
+ tzinfo.utc_to_local(time).yield_self do |t|
516
+ ActiveSupport.utc_to_local_returns_utc_offset_times ?
517
+ t : Time.utc(t.year, t.month, t.day, t.hour, t.min, t.sec, t.sec_fraction)
518
+ end
502
519
  end
503
520
 
504
521
  # 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(number.to_f.to_s)
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-2022 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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.8.1
4
+ version: 6.1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -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
@@ -145,21 +161,19 @@ files:
145
161
  - lib/active_support/core_ext/file.rb
146
162
  - lib/active_support/core_ext/file/atomic.rb
147
163
  - lib/active_support/core_ext/hash.rb
148
- - lib/active_support/core_ext/hash/compact.rb
149
164
  - lib/active_support/core_ext/hash/conversions.rb
150
165
  - lib/active_support/core_ext/hash/deep_merge.rb
166
+ - lib/active_support/core_ext/hash/deep_transform_values.rb
151
167
  - lib/active_support/core_ext/hash/except.rb
152
168
  - lib/active_support/core_ext/hash/indifferent_access.rb
153
169
  - lib/active_support/core_ext/hash/keys.rb
154
170
  - lib/active_support/core_ext/hash/reverse_merge.rb
155
171
  - lib/active_support/core_ext/hash/slice.rb
156
- - lib/active_support/core_ext/hash/transform_values.rb
157
172
  - lib/active_support/core_ext/integer.rb
158
173
  - lib/active_support/core_ext/integer/inflections.rb
159
174
  - lib/active_support/core_ext/integer/multiple.rb
160
175
  - lib/active_support/core_ext/integer/time.rb
161
176
  - lib/active_support/core_ext/kernel.rb
162
- - lib/active_support/core_ext/kernel/agnostics.rb
163
177
  - lib/active_support/core_ext/kernel/concern.rb
164
178
  - lib/active_support/core_ext/kernel/reporting.rb
165
179
  - lib/active_support/core_ext/kernel/singleton_class.rb
@@ -175,14 +189,12 @@ files:
175
189
  - lib/active_support/core_ext/module/delegation.rb
176
190
  - lib/active_support/core_ext/module/deprecation.rb
177
191
  - lib/active_support/core_ext/module/introspection.rb
178
- - lib/active_support/core_ext/module/reachable.rb
179
192
  - lib/active_support/core_ext/module/redefine_method.rb
180
193
  - lib/active_support/core_ext/module/remove_method.rb
181
194
  - lib/active_support/core_ext/name_error.rb
182
195
  - lib/active_support/core_ext/numeric.rb
183
196
  - lib/active_support/core_ext/numeric/bytes.rb
184
197
  - lib/active_support/core_ext/numeric/conversions.rb
185
- - lib/active_support/core_ext/numeric/inquiry.rb
186
198
  - lib/active_support/core_ext/numeric/time.rb
187
199
  - lib/active_support/core_ext/object.rb
188
200
  - lib/active_support/core_ext/object/acts_like.rb
@@ -201,7 +213,6 @@ files:
201
213
  - lib/active_support/core_ext/range/compare_range.rb
202
214
  - lib/active_support/core_ext/range/conversions.rb
203
215
  - lib/active_support/core_ext/range/each.rb
204
- - lib/active_support/core_ext/range/include_range.rb
205
216
  - lib/active_support/core_ext/range/include_time_with_zone.rb
206
217
  - lib/active_support/core_ext/range/overlaps.rb
207
218
  - lib/active_support/core_ext/regexp.rb
@@ -220,6 +231,8 @@ files:
220
231
  - lib/active_support/core_ext/string/starts_ends_with.rb
221
232
  - lib/active_support/core_ext/string/strip.rb
222
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
223
236
  - lib/active_support/core_ext/time.rb
224
237
  - lib/active_support/core_ext/time/acts_like.rb
225
238
  - lib/active_support/core_ext/time/calculations.rb
@@ -228,12 +241,15 @@ files:
228
241
  - lib/active_support/core_ext/time/zones.rb
229
242
  - lib/active_support/core_ext/uri.rb
230
243
  - lib/active_support/current_attributes.rb
244
+ - lib/active_support/current_attributes/test_helper.rb
231
245
  - lib/active_support/dependencies.rb
232
246
  - lib/active_support/dependencies/autoload.rb
233
247
  - lib/active_support/dependencies/interlock.rb
248
+ - lib/active_support/dependencies/zeitwerk_integration.rb
234
249
  - lib/active_support/deprecation.rb
235
250
  - lib/active_support/deprecation/behaviors.rb
236
251
  - lib/active_support/deprecation/constant_accessor.rb
252
+ - lib/active_support/deprecation/disallowed.rb
237
253
  - lib/active_support/deprecation/instance_delegator.rb
238
254
  - lib/active_support/deprecation/method_wrappers.rb
239
255
  - lib/active_support/deprecation/proxy_wrappers.rb
@@ -245,10 +261,12 @@ files:
245
261
  - lib/active_support/duration/iso8601_serializer.rb
246
262
  - lib/active_support/encrypted_configuration.rb
247
263
  - lib/active_support/encrypted_file.rb
264
+ - lib/active_support/environment_inquirer.rb
248
265
  - lib/active_support/evented_file_update_checker.rb
249
266
  - lib/active_support/execution_wrapper.rb
250
267
  - lib/active_support/executor.rb
251
268
  - lib/active_support/file_update_checker.rb
269
+ - lib/active_support/fork_tracker.rb
252
270
  - lib/active_support/gem_version.rb
253
271
  - lib/active_support/gzip.rb
254
272
  - lib/active_support/hash_with_indifferent_access.rb
@@ -264,6 +282,7 @@ files:
264
282
  - lib/active_support/json/encoding.rb
265
283
  - lib/active_support/key_generator.rb
266
284
  - lib/active_support/lazy_load_hooks.rb
285
+ - lib/active_support/locale/en.rb
267
286
  - lib/active_support/locale/en.yml
268
287
  - lib/active_support/log_subscriber.rb
269
288
  - lib/active_support/log_subscriber/test_helper.rb
@@ -294,12 +313,14 @@ files:
294
313
  - lib/active_support/option_merger.rb
295
314
  - lib/active_support/ordered_hash.rb
296
315
  - lib/active_support/ordered_options.rb
316
+ - lib/active_support/parameter_filter.rb
297
317
  - lib/active_support/per_thread_registry.rb
298
318
  - lib/active_support/proxy_object.rb
299
319
  - lib/active_support/rails.rb
300
320
  - lib/active_support/railtie.rb
301
321
  - lib/active_support/reloader.rb
302
322
  - lib/active_support/rescuable.rb
323
+ - lib/active_support/secure_compare_rotator.rb
303
324
  - lib/active_support/security_utils.rb
304
325
  - lib/active_support/string_inquirer.rb
305
326
  - lib/active_support/subscriber.rb
@@ -313,6 +334,9 @@ files:
313
334
  - lib/active_support/testing/file_fixtures.rb
314
335
  - lib/active_support/testing/isolation.rb
315
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
316
340
  - lib/active_support/testing/setup_and_teardown.rb
317
341
  - lib/active_support/testing/stream.rb
318
342
  - lib/active_support/testing/tagged_logging.rb
@@ -320,7 +344,6 @@ files:
320
344
  - lib/active_support/time.rb
321
345
  - lib/active_support/time_with_zone.rb
322
346
  - lib/active_support/values/time_zone.rb
323
- - lib/active_support/values/unicode_tables.dat
324
347
  - lib/active_support/version.rb
325
348
  - lib/active_support/xml_mini.rb
326
349
  - lib/active_support/xml_mini/jdom.rb
@@ -329,12 +352,16 @@ files:
329
352
  - lib/active_support/xml_mini/nokogiri.rb
330
353
  - lib/active_support/xml_mini/nokogirisax.rb
331
354
  - lib/active_support/xml_mini/rexml.rb
332
- homepage: http://rubyonrails.org
355
+ homepage: https://rubyonrails.org
333
356
  licenses:
334
357
  - MIT
335
358
  metadata:
336
- source_code_uri: https://github.com/rails/rails/tree/v5.2.8.1/activesupport
337
- changelog_uri: https://github.com/rails/rails/blob/v5.2.8.1/activesupport/CHANGELOG.md
359
+ bug_tracker_uri: https://github.com/rails/rails/issues
360
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.6.1/activesupport/CHANGELOG.md
361
+ documentation_uri: https://api.rubyonrails.org/v6.1.6.1/
362
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
363
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.6.1/activesupport
364
+ rubygems_mfa_required: 'true'
338
365
  post_install_message:
339
366
  rdoc_options:
340
367
  - "--encoding"
@@ -345,7 +372,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
345
372
  requirements:
346
373
  - - ">="
347
374
  - !ruby/object:Gem::Version
348
- version: 2.2.2
375
+ version: 2.5.0
349
376
  required_rubygems_version: !ruby/object:Gem::Requirement
350
377
  requirements:
351
378
  - - ">="
@@ -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
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Hash
4
- unless Hash.instance_methods(false).include?(:compact)
5
- # Returns a hash with non +nil+ values.
6
- #
7
- # hash = { a: true, b: false, c: nil }
8
- # hash.compact # => { a: true, b: false }
9
- # hash # => { a: true, b: false, c: nil }
10
- # { c: nil }.compact # => {}
11
- # { c: true }.compact # => { c: true }
12
- def compact
13
- select { |_, value| !value.nil? }
14
- end
15
- end
16
-
17
- unless Hash.instance_methods(false).include?(:compact!)
18
- # Replaces current hash with non +nil+ values.
19
- # Returns +nil+ if no changes were made, otherwise returns the hash.
20
- #
21
- # hash = { a: true, b: false, c: nil }
22
- # hash.compact! # => { a: true, b: false }
23
- # hash # => { a: true, b: false }
24
- # { c: true }.compact! # => nil
25
- def compact!
26
- reject! { |_, value| value.nil? }
27
- end
28
- end
29
- end