activesupport 6.0.6.1 → 6.1.0.rc1

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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +337 -573
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/active_support/array_inquirer.rb +4 -2
  6. data/lib/active_support/backtrace_cleaner.rb +3 -3
  7. data/lib/active_support/benchmarkable.rb +1 -1
  8. data/lib/active_support/cache/file_store.rb +2 -2
  9. data/lib/active_support/cache/mem_cache_store.rb +20 -14
  10. data/lib/active_support/cache/memory_store.rb +38 -26
  11. data/lib/active_support/cache/redis_cache_store.rb +25 -25
  12. data/lib/active_support/cache/strategy/local_cache.rb +13 -4
  13. data/lib/active_support/cache.rb +75 -34
  14. data/lib/active_support/callbacks.rb +65 -56
  15. data/lib/active_support/concern.rb +46 -2
  16. data/lib/active_support/configurable.rb +3 -3
  17. data/lib/active_support/configuration_file.rb +46 -0
  18. data/lib/active_support/core_ext/benchmark.rb +2 -2
  19. data/lib/active_support/core_ext/class/attribute.rb +34 -44
  20. data/lib/active_support/core_ext/class/subclasses.rb +17 -38
  21. data/lib/active_support/core_ext/date/conversions.rb +2 -1
  22. data/lib/active_support/core_ext/date_and_time/calculations.rb +13 -0
  23. data/lib/active_support/core_ext/date_and_time/compatibility.rb +15 -0
  24. data/lib/active_support/core_ext/enumerable.rb +76 -4
  25. data/lib/active_support/core_ext/hash/conversions.rb +2 -2
  26. data/lib/active_support/core_ext/hash/deep_transform_values.rb +1 -1
  27. data/lib/active_support/core_ext/hash/keys.rb +1 -1
  28. data/lib/active_support/core_ext/hash/slice.rb +3 -2
  29. data/lib/active_support/core_ext/load_error.rb +1 -1
  30. data/lib/active_support/core_ext/marshal.rb +2 -0
  31. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  32. data/lib/active_support/core_ext/module/attribute_accessors.rb +23 -29
  33. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +8 -4
  34. data/lib/active_support/core_ext/module/concerning.rb +8 -2
  35. data/lib/active_support/core_ext/module/delegation.rb +38 -28
  36. data/lib/active_support/core_ext/module/introspection.rb +1 -25
  37. data/lib/active_support/core_ext/name_error.rb +29 -2
  38. data/lib/active_support/core_ext/numeric/conversions.rb +22 -18
  39. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  40. data/lib/active_support/core_ext/object/json.rb +5 -1
  41. data/lib/active_support/core_ext/object/try.rb +2 -2
  42. data/lib/active_support/core_ext/range/compare_range.rb +9 -3
  43. data/lib/active_support/core_ext/range/include_time_with_zone.rb +8 -3
  44. data/lib/active_support/core_ext/string/access.rb +5 -24
  45. data/lib/active_support/core_ext/string/inflections.rb +38 -4
  46. data/lib/active_support/core_ext/string/inquiry.rb +1 -0
  47. data/lib/active_support/core_ext/string/multibyte.rb +2 -2
  48. data/lib/active_support/core_ext/string/output_safety.rb +8 -38
  49. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -2
  50. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +14 -0
  51. data/lib/active_support/core_ext/symbol.rb +3 -0
  52. data/lib/active_support/core_ext/time/calculations.rb +16 -0
  53. data/lib/active_support/core_ext/time/conversions.rb +1 -0
  54. data/lib/active_support/core_ext/uri.rb +5 -1
  55. data/lib/active_support/current_attributes/test_helper.rb +13 -0
  56. data/lib/active_support/current_attributes.rb +7 -2
  57. data/lib/active_support/dependencies.rb +38 -24
  58. data/lib/active_support/deprecation/behaviors.rb +15 -2
  59. data/lib/active_support/deprecation/disallowed.rb +56 -0
  60. data/lib/active_support/deprecation/instance_delegator.rb +0 -1
  61. data/lib/active_support/deprecation/method_wrappers.rb +3 -2
  62. data/lib/active_support/deprecation/proxy_wrappers.rb +2 -2
  63. data/lib/active_support/deprecation/reporting.rb +50 -7
  64. data/lib/active_support/deprecation.rb +6 -1
  65. data/lib/active_support/descendants_tracker.rb +6 -2
  66. data/lib/active_support/duration/iso8601_serializer.rb +15 -9
  67. data/lib/active_support/duration.rb +71 -22
  68. data/lib/active_support/encrypted_file.rb +19 -2
  69. data/lib/active_support/environment_inquirer.rb +20 -0
  70. data/lib/active_support/evented_file_update_checker.rb +69 -133
  71. data/lib/active_support/execution_wrapper.rb +13 -16
  72. data/lib/active_support/fork_tracker.rb +58 -0
  73. data/lib/active_support/gem_version.rb +3 -3
  74. data/lib/active_support/hash_with_indifferent_access.rb +35 -22
  75. data/lib/active_support/i18n_railtie.rb +14 -19
  76. data/lib/active_support/inflector/inflections.rb +1 -2
  77. data/lib/active_support/inflector/methods.rb +35 -31
  78. data/lib/active_support/inflector/transliterate.rb +4 -4
  79. data/lib/active_support/json/decoding.rb +4 -4
  80. data/lib/active_support/json/encoding.rb +5 -1
  81. data/lib/active_support/key_generator.rb +1 -1
  82. data/lib/active_support/locale/en.yml +7 -3
  83. data/lib/active_support/log_subscriber.rb +8 -0
  84. data/lib/active_support/logger.rb +1 -1
  85. data/lib/active_support/logger_silence.rb +2 -26
  86. data/lib/active_support/logger_thread_safe_level.rb +34 -12
  87. data/lib/active_support/message_encryptor.rb +4 -7
  88. data/lib/active_support/message_verifier.rb +5 -5
  89. data/lib/active_support/messages/rotation_configuration.rb +2 -1
  90. data/lib/active_support/messages/rotator.rb +6 -5
  91. data/lib/active_support/multibyte/chars.rb +4 -42
  92. data/lib/active_support/multibyte/unicode.rb +9 -83
  93. data/lib/active_support/notifications/fanout.rb +23 -8
  94. data/lib/active_support/notifications/instrumenter.rb +6 -15
  95. data/lib/active_support/notifications.rb +31 -4
  96. data/lib/active_support/number_helper/number_converter.rb +1 -1
  97. data/lib/active_support/number_helper/number_to_human_converter.rb +1 -1
  98. data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -1
  99. data/lib/active_support/number_helper/number_to_rounded_converter.rb +3 -3
  100. data/lib/active_support/number_helper/rounding_helper.rb +12 -28
  101. data/lib/active_support/number_helper.rb +29 -14
  102. data/lib/active_support/option_merger.rb +2 -1
  103. data/lib/active_support/ordered_options.rb +8 -2
  104. data/lib/active_support/parameter_filter.rb +15 -10
  105. data/lib/active_support/per_thread_registry.rb +1 -1
  106. data/lib/active_support/rails.rb +1 -4
  107. data/lib/active_support/railtie.rb +23 -1
  108. data/lib/active_support/reloader.rb +1 -1
  109. data/lib/active_support/secure_compare_rotator.rb +51 -0
  110. data/lib/active_support/security_utils.rb +19 -12
  111. data/lib/active_support/string_inquirer.rb +4 -2
  112. data/lib/active_support/subscriber.rb +12 -7
  113. data/lib/active_support/tagged_logging.rb +29 -4
  114. data/lib/active_support/testing/assertions.rb +18 -11
  115. data/lib/active_support/testing/parallelization/server.rb +78 -0
  116. data/lib/active_support/testing/parallelization/worker.rb +100 -0
  117. data/lib/active_support/testing/parallelization.rb +12 -95
  118. data/lib/active_support/testing/time_helpers.rb +40 -3
  119. data/lib/active_support/time_with_zone.rb +66 -42
  120. data/lib/active_support/values/time_zone.rb +20 -10
  121. data/lib/active_support/xml_mini/rexml.rb +8 -1
  122. data/lib/active_support.rb +13 -1
  123. metadata +39 -42
  124. data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -5
  125. data/lib/active_support/core_ext/hash/compact.rb +0 -5
  126. data/lib/active_support/core_ext/hash/transform_values.rb +0 -5
  127. data/lib/active_support/core_ext/module/reachable.rb +0 -6
  128. data/lib/active_support/core_ext/numeric/inquiry.rb +0 -5
  129. data/lib/active_support/core_ext/range/include_range.rb +0 -9
@@ -15,25 +15,25 @@ module ActiveSupport
15
15
  # and +in_time_zone+ on Time and DateTime instances.
16
16
  #
17
17
  # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
18
- # Time.zone.local(2007, 2, 10, 15, 30, 45) # => Sat, 10 Feb 2007 15:30:45 EST -05:00
19
- # Time.zone.parse('2007-02-10 15:30:45') # => Sat, 10 Feb 2007 15:30:45 EST -05:00
20
- # Time.zone.at(1171139445) # => Sat, 10 Feb 2007 15:30:45 EST -05:00
21
- # Time.zone.now # => Sun, 18 May 2008 13:07:55 EDT -04:00
22
- # Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone # => Sat, 10 Feb 2007 15:30:45 EST -05:00
18
+ # Time.zone.local(2007, 2, 10, 15, 30, 45) # => Sat, 10 Feb 2007 15:30:45.000000000 EST -05:00
19
+ # Time.zone.parse('2007-02-10 15:30:45') # => Sat, 10 Feb 2007 15:30:45.000000000 EST -05:00
20
+ # Time.zone.at(1171139445) # => Sat, 10 Feb 2007 15:30:45.000000000 EST -05:00
21
+ # Time.zone.now # => Sun, 18 May 2008 13:07:55.754107581 EDT -04:00
22
+ # Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone # => Sat, 10 Feb 2007 15:30:45.000000000 EST -05:00
23
23
  #
24
24
  # See Time and TimeZone for further documentation of these methods.
25
25
  #
26
26
  # TimeWithZone instances implement the same API as Ruby Time instances, so
27
27
  # that Time and TimeWithZone instances are interchangeable.
28
28
  #
29
- # t = Time.zone.now # => Sun, 18 May 2008 13:27:25 EDT -04:00
29
+ # t = Time.zone.now # => Sun, 18 May 2008 13:27:25.031505668 EDT -04:00
30
30
  # t.hour # => 13
31
31
  # t.dst? # => true
32
32
  # t.utc_offset # => -14400
33
33
  # t.zone # => "EDT"
34
34
  # t.to_s(:rfc822) # => "Sun, 18 May 2008 13:27:25 -0400"
35
- # t + 1.day # => Mon, 19 May 2008 13:27:25 EDT -04:00
36
- # t.beginning_of_year # => Tue, 01 Jan 2008 00:00:00 EST -05:00
35
+ # t + 1.day # => Mon, 19 May 2008 13:27:25.031505668 EDT -04:00
36
+ # t.beginning_of_year # => Tue, 01 Jan 2008 00:00:00.000000000 EST -05:00
37
37
  # t > Time.utc(1999) # => true
38
38
  # t.is_a?(Time) # => true
39
39
  # t.is_a?(ActiveSupport::TimeWithZone) # => true
@@ -57,12 +57,12 @@ module ActiveSupport
57
57
 
58
58
  # Returns a <tt>Time</tt> instance that represents the time in +time_zone+.
59
59
  def time
60
- @time ||= period.to_local(@utc)
60
+ @time ||= incorporate_utc_offset(@utc, utc_offset)
61
61
  end
62
62
 
63
63
  # Returns a <tt>Time</tt> instance of the simultaneous time in the UTC timezone.
64
64
  def utc
65
- @utc ||= period.to_utc(@time)
65
+ @utc ||= incorporate_utc_offset(@time, -utc_offset)
66
66
  end
67
67
  alias_method :comparable_time, :utc
68
68
  alias_method :getgm, :utc
@@ -104,13 +104,13 @@ module ActiveSupport
104
104
  # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
105
105
  # Time.zone.now.utc? # => false
106
106
  def utc?
107
- period.offset.abbreviation == :UTC || period.offset.abbreviation == :UCT
107
+ zone == "UTC" || zone == "UCT"
108
108
  end
109
109
  alias_method :gmt?, :utc?
110
110
 
111
111
  # Returns the offset from current time to UTC time in seconds.
112
112
  def utc_offset
113
- period.utc_total_offset
113
+ period.observed_utc_offset
114
114
  end
115
115
  alias_method :gmt_offset, :utc_offset
116
116
  alias_method :gmtoff, :utc_offset
@@ -132,14 +132,14 @@ module ActiveSupport
132
132
  # Time.zone = 'Eastern Time (US & Canada)' # => "Eastern Time (US & Canada)"
133
133
  # Time.zone.now.zone # => "EST"
134
134
  def zone
135
- period.zone_identifier.to_s
135
+ period.abbreviation
136
136
  end
137
137
 
138
138
  # Returns a string of the object's date, time, zone, and offset from UTC.
139
139
  #
140
- # Time.zone.now.inspect # => "Thu, 04 Dec 2014 11:00:25 EST -05:00"
140
+ # Time.zone.now.inspect # => "Thu, 04 Dec 2014 11:00:25.624541392 EST -05:00"
141
141
  def inspect
142
- "#{time.strftime('%a, %d %b %Y %H:%M:%S')} #{zone} #{formatted_offset}"
142
+ "#{time.strftime('%a, %d %b %Y %H:%M:%S.%9N')} #{zone} #{formatted_offset}"
143
143
  end
144
144
 
145
145
  # Returns a string of the object's date and time in the ISO 8601 standard
@@ -245,6 +245,20 @@ module ActiveSupport
245
245
  time.today?
246
246
  end
247
247
 
248
+ # Returns true if the current object's time falls within
249
+ # the next day (tomorrow).
250
+ def tomorrow?
251
+ time.tomorrow?
252
+ end
253
+ alias :next_day? :tomorrow?
254
+
255
+ # Returns true if the current object's time falls within
256
+ # the previous day (yesterday).
257
+ def yesterday?
258
+ time.yesterday?
259
+ end
260
+ alias :prev_day? :yesterday?
261
+
248
262
  # Returns true if the current object's time is in the future.
249
263
  def future?
250
264
  utc.future?
@@ -263,8 +277,8 @@ module ActiveSupport
263
277
  # value as a new TimeWithZone object.
264
278
  #
265
279
  # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
266
- # now = Time.zone.now # => Sun, 02 Nov 2014 01:26:28 EDT -04:00
267
- # now + 1000 # => Sun, 02 Nov 2014 01:43:08 EDT -04:00
280
+ # now = Time.zone.now # => Sun, 02 Nov 2014 01:26:28.725182881 EDT -04:00
281
+ # now + 1000 # => Sun, 02 Nov 2014 01:43:08.725182881 EDT -04:00
268
282
  #
269
283
  # If we're adding a Duration of variable length (i.e., years, months, days),
270
284
  # move forward from #time, otherwise move forward from #utc, for accuracy
@@ -273,8 +287,8 @@ module ActiveSupport
273
287
  # For instance, a time + 24.hours will advance exactly 24 hours, while a
274
288
  # time + 1.day will advance 23-25 hours, depending on the day.
275
289
  #
276
- # now + 24.hours # => Mon, 03 Nov 2014 00:26:28 EST -05:00
277
- # now + 1.day # => Mon, 03 Nov 2014 01:26:28 EST -05:00
290
+ # now + 24.hours # => Mon, 03 Nov 2014 00:26:28.725182881 EST -05:00
291
+ # now + 1.day # => Mon, 03 Nov 2014 01:26:28.725182881 EST -05:00
278
292
  def +(other)
279
293
  if duration_of_variable_length?(other)
280
294
  method_missing(:+, other)
@@ -292,8 +306,8 @@ module ActiveSupport
292
306
  # object's time and the +other+ time.
293
307
  #
294
308
  # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
295
- # now = Time.zone.now # => Mon, 03 Nov 2014 00:26:28 EST -05:00
296
- # now - 1000 # => Mon, 03 Nov 2014 00:09:48 EST -05:00
309
+ # now = Time.zone.now # => Mon, 03 Nov 2014 00:26:28.725182881 EST -05:00
310
+ # now - 1000 # => Mon, 03 Nov 2014 00:09:48.725182881 EST -05:00
297
311
  #
298
312
  # If subtracting a Duration of variable length (i.e., years, months, days),
299
313
  # move backward from #time, otherwise move backward from #utc, for accuracy
@@ -302,8 +316,8 @@ module ActiveSupport
302
316
  # For instance, a time - 24.hours will go subtract exactly 24 hours, while a
303
317
  # time - 1.day will subtract 23-25 hours, depending on the day.
304
318
  #
305
- # now - 24.hours # => Sun, 02 Nov 2014 01:26:28 EDT -04:00
306
- # now - 1.day # => Sun, 02 Nov 2014 00:26:28 EDT -04:00
319
+ # now - 24.hours # => Sun, 02 Nov 2014 01:26:28.725182881 EDT -04:00
320
+ # now - 1.day # => Sun, 02 Nov 2014 00:26:28.725182881 EDT -04:00
307
321
  #
308
322
  # If both the TimeWithZone object and the other value act like Time, a Float
309
323
  # will be returned.
@@ -325,8 +339,8 @@ module ActiveSupport
325
339
  # the result as a new TimeWithZone object.
326
340
  #
327
341
  # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
328
- # now = Time.zone.now # => Mon, 03 Nov 2014 00:26:28 EST -05:00
329
- # now.ago(1000) # => Mon, 03 Nov 2014 00:09:48 EST -05:00
342
+ # now = Time.zone.now # => Mon, 03 Nov 2014 00:26:28.725182881 EST -05:00
343
+ # now.ago(1000) # => Mon, 03 Nov 2014 00:09:48.725182881 EST -05:00
330
344
  #
331
345
  # If we're subtracting a Duration of variable length (i.e., years, months,
332
346
  # days), move backward from #time, otherwise move backward from #utc, for
@@ -336,8 +350,8 @@ module ActiveSupport
336
350
  # while <tt>time.ago(1.day)</tt> will move back 23-25 hours, depending on
337
351
  # the day.
338
352
  #
339
- # now.ago(24.hours) # => Sun, 02 Nov 2014 01:26:28 EDT -04:00
340
- # now.ago(1.day) # => Sun, 02 Nov 2014 00:26:28 EDT -04:00
353
+ # now.ago(24.hours) # => Sun, 02 Nov 2014 01:26:28.725182881 EDT -04:00
354
+ # now.ago(1.day) # => Sun, 02 Nov 2014 00:26:28.725182881 EDT -04:00
341
355
  def ago(other)
342
356
  since(-other)
343
357
  end
@@ -353,12 +367,12 @@ module ActiveSupport
353
367
  # or <tt>:nsec</tt>, not both. Similarly, pass either <tt>:zone</tt> or
354
368
  # <tt>:offset</tt>, not both.
355
369
  #
356
- # t = Time.zone.now # => Fri, 14 Apr 2017 11:45:15 EST -05:00
357
- # t.change(year: 2020) # => Tue, 14 Apr 2020 11:45:15 EST -05:00
358
- # t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00 EST -05:00
359
- # t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00 EST -05:00
360
- # t.change(offset: "-10:00") # => Fri, 14 Apr 2017 11:45:15 HST -10:00
361
- # t.change(zone: "Hawaii") # => Fri, 14 Apr 2017 11:45:15 HST -10:00
370
+ # t = Time.zone.now # => Fri, 14 Apr 2017 11:45:15.116992711 EST -05:00
371
+ # t.change(year: 2020) # => Tue, 14 Apr 2020 11:45:15.116992711 EST -05:00
372
+ # t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00.116992711 EST -05:00
373
+ # t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00.116992711 EST -05:00
374
+ # t.change(offset: "-10:00") # => Fri, 14 Apr 2017 11:45:15.116992711 HST -10:00
375
+ # t.change(zone: "Hawaii") # => Fri, 14 Apr 2017 11:45:15.116992711 HST -10:00
362
376
  def change(options)
363
377
  if options[:zone] && options[:offset]
364
378
  raise ArgumentError, "Can't change both :offset and :zone at the same time: #{options.inspect}"
@@ -391,14 +405,14 @@ module ActiveSupport
391
405
  # accuracy when moving across DST boundaries.
392
406
  #
393
407
  # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
394
- # now = Time.zone.now # => Sun, 02 Nov 2014 01:26:28 EDT -04:00
395
- # now.advance(seconds: 1) # => Sun, 02 Nov 2014 01:26:29 EDT -04:00
396
- # now.advance(minutes: 1) # => Sun, 02 Nov 2014 01:27:28 EDT -04:00
397
- # now.advance(hours: 1) # => Sun, 02 Nov 2014 01:26:28 EST -05:00
398
- # now.advance(days: 1) # => Mon, 03 Nov 2014 01:26:28 EST -05:00
399
- # now.advance(weeks: 1) # => Sun, 09 Nov 2014 01:26:28 EST -05:00
400
- # now.advance(months: 1) # => Tue, 02 Dec 2014 01:26:28 EST -05:00
401
- # now.advance(years: 1) # => Mon, 02 Nov 2015 01:26:28 EST -05:00
408
+ # now = Time.zone.now # => Sun, 02 Nov 2014 01:26:28.558049687 EDT -04:00
409
+ # now.advance(seconds: 1) # => Sun, 02 Nov 2014 01:26:29.558049687 EDT -04:00
410
+ # now.advance(minutes: 1) # => Sun, 02 Nov 2014 01:27:28.558049687 EDT -04:00
411
+ # now.advance(hours: 1) # => Sun, 02 Nov 2014 01:26:28.558049687 EST -05:00
412
+ # now.advance(days: 1) # => Mon, 03 Nov 2014 01:26:28.558049687 EST -05:00
413
+ # now.advance(weeks: 1) # => Sun, 09 Nov 2014 01:26:28.558049687 EST -05:00
414
+ # now.advance(months: 1) # => Tue, 02 Dec 2014 01:26:28.558049687 EST -05:00
415
+ # now.advance(years: 1) # => Mon, 02 Nov 2015 01:26:28.558049687 EST -05:00
402
416
  def advance(options)
403
417
  # If we're advancing a value of variable length (i.e., years, weeks, months, days), advance from #time,
404
418
  # otherwise advance from #utc, for accuracy when moving across DST boundaries
@@ -420,7 +434,7 @@ module ActiveSupport
420
434
  # Returns Array of parts of Time in sequence of
421
435
  # [seconds, minutes, hours, day, month, year, weekday, yearday, dst?, zone].
422
436
  #
423
- # now = Time.zone.now # => Tue, 18 Aug 2015 02:29:27 UTC +00:00
437
+ # now = Time.zone.now # => Tue, 18 Aug 2015 02:29:27.485278555 UTC +00:00
424
438
  # now.to_a # => [27, 29, 2, 18, 8, 2015, 2, 230, false, "UTC"]
425
439
  def to_a
426
440
  [time.sec, time.min, time.hour, time.day, time.mon, time.year, time.wday, time.yday, dst?, zone]
@@ -524,6 +538,16 @@ module ActiveSupport
524
538
  end
525
539
 
526
540
  private
541
+ SECONDS_PER_DAY = 86400
542
+
543
+ def incorporate_utc_offset(time, offset)
544
+ if time.kind_of?(Date)
545
+ time + Rational(offset, SECONDS_PER_DAY)
546
+ else
547
+ time + offset
548
+ end
549
+ end
550
+
527
551
  def get_period_and_ensure_valid_local_time(period)
528
552
  # we don't want a Time.local instance enforcing its own DST rules as well,
529
553
  # so transfer time values to a utc constructor if necessary
@@ -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
@@ -273,7 +273,7 @@ module ActiveSupport
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
278
  end.sort!
279
279
  end
@@ -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}"
@@ -500,10 +503,17 @@ module ActiveSupport
500
503
  end
501
504
 
502
505
  # Adjust the given time to the simultaneous time in the time zone
503
- # represented by +self+. Returns a Time.utc() instance -- if you want an
504
- # 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.
505
512
  def utc_to_local(time)
506
- 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
507
517
  end
508
518
 
509
519
  # Adjust the given time to the simultaneous time in UTC. Returns a
@@ -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::
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2005-2019 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
@@ -35,6 +35,7 @@ module ActiveSupport
35
35
 
36
36
  autoload :Concern
37
37
  autoload :ActionableError
38
+ autoload :ConfigurationFile
38
39
  autoload :CurrentAttributes
39
40
  autoload :Dependencies
40
41
  autoload :DescendantsTracker
@@ -42,9 +43,11 @@ module ActiveSupport
42
43
  autoload :Executor
43
44
  autoload :FileUpdateChecker
44
45
  autoload :EventedFileUpdateChecker
46
+ autoload :ForkTracker
45
47
  autoload :LogSubscriber
46
48
  autoload :Notifications
47
49
  autoload :Reloader
50
+ autoload :SecureCompareRotator
48
51
 
49
52
  eager_autoload do
50
53
  autoload :BacktraceCleaner
@@ -67,6 +70,7 @@ module ActiveSupport
67
70
  autoload :OrderedHash
68
71
  autoload :OrderedOptions
69
72
  autoload :StringInquirer
73
+ autoload :EnvironmentInquirer
70
74
  autoload :TaggedLogging
71
75
  autoload :XmlMini
72
76
  autoload :ArrayInquirer
@@ -91,6 +95,14 @@ module ActiveSupport
91
95
  def self.to_time_preserves_timezone=(value)
92
96
  DateAndTime::Compatibility.preserve_timezone = value
93
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
94
106
  end
95
107
 
96
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: 6.0.6.1
4
+ version: 6.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-17 00:00:00.000000000 Z
11
+ date: 2020-11-02 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,28 +36,14 @@ 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'
47
- - !ruby/object:Gem::Dependency
48
- name: minitest
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '5.1'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '5.1'
46
+ version: '2.0'
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: concurrent-ruby
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -84,20 +70,28 @@ dependencies:
84
70
  requirements:
85
71
  - - "~>"
86
72
  - !ruby/object:Gem::Version
87
- version: '2.2'
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: 2.2.2
73
+ version: '2.3'
91
74
  type: :runtime
92
75
  prerelease: false
93
76
  version_requirements: !ruby/object:Gem::Requirement
94
77
  requirements:
95
78
  - - "~>"
96
79
  - !ruby/object:Gem::Version
97
- version: '2.2'
80
+ version: '2.3'
81
+ - !ruby/object:Gem::Dependency
82
+ name: minitest
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '5.1'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
98
92
  - - ">="
99
93
  - !ruby/object:Gem::Version
100
- version: 2.2.2
94
+ version: '5.1'
101
95
  description: A toolkit of support libraries and Ruby core extensions extracted from
102
96
  the Rails framework. Rich support for multibyte strings, internationalization, time
103
97
  zones, and testing.
@@ -129,6 +123,7 @@ files:
129
123
  - lib/active_support/concurrency/load_interlock_aware_monitor.rb
130
124
  - lib/active_support/concurrency/share_lock.rb
131
125
  - lib/active_support/configurable.rb
126
+ - lib/active_support/configuration_file.rb
132
127
  - lib/active_support/core_ext.rb
133
128
  - lib/active_support/core_ext/array.rb
134
129
  - lib/active_support/core_ext/array/access.rb
@@ -137,7 +132,6 @@ files:
137
132
  - lib/active_support/core_ext/array/extract_options.rb
138
133
  - lib/active_support/core_ext/array/grouping.rb
139
134
  - lib/active_support/core_ext/array/inquiry.rb
140
- - lib/active_support/core_ext/array/prepend_and_append.rb
141
135
  - lib/active_support/core_ext/array/wrap.rb
142
136
  - lib/active_support/core_ext/benchmark.rb
143
137
  - lib/active_support/core_ext/big_decimal.rb
@@ -167,7 +161,6 @@ files:
167
161
  - lib/active_support/core_ext/file.rb
168
162
  - lib/active_support/core_ext/file/atomic.rb
169
163
  - lib/active_support/core_ext/hash.rb
170
- - lib/active_support/core_ext/hash/compact.rb
171
164
  - lib/active_support/core_ext/hash/conversions.rb
172
165
  - lib/active_support/core_ext/hash/deep_merge.rb
173
166
  - lib/active_support/core_ext/hash/deep_transform_values.rb
@@ -176,7 +169,6 @@ files:
176
169
  - lib/active_support/core_ext/hash/keys.rb
177
170
  - lib/active_support/core_ext/hash/reverse_merge.rb
178
171
  - lib/active_support/core_ext/hash/slice.rb
179
- - lib/active_support/core_ext/hash/transform_values.rb
180
172
  - lib/active_support/core_ext/integer.rb
181
173
  - lib/active_support/core_ext/integer/inflections.rb
182
174
  - lib/active_support/core_ext/integer/multiple.rb
@@ -197,14 +189,12 @@ files:
197
189
  - lib/active_support/core_ext/module/delegation.rb
198
190
  - lib/active_support/core_ext/module/deprecation.rb
199
191
  - lib/active_support/core_ext/module/introspection.rb
200
- - lib/active_support/core_ext/module/reachable.rb
201
192
  - lib/active_support/core_ext/module/redefine_method.rb
202
193
  - lib/active_support/core_ext/module/remove_method.rb
203
194
  - lib/active_support/core_ext/name_error.rb
204
195
  - lib/active_support/core_ext/numeric.rb
205
196
  - lib/active_support/core_ext/numeric/bytes.rb
206
197
  - lib/active_support/core_ext/numeric/conversions.rb
207
- - lib/active_support/core_ext/numeric/inquiry.rb
208
198
  - lib/active_support/core_ext/numeric/time.rb
209
199
  - lib/active_support/core_ext/object.rb
210
200
  - lib/active_support/core_ext/object/acts_like.rb
@@ -223,7 +213,6 @@ files:
223
213
  - lib/active_support/core_ext/range/compare_range.rb
224
214
  - lib/active_support/core_ext/range/conversions.rb
225
215
  - lib/active_support/core_ext/range/each.rb
226
- - lib/active_support/core_ext/range/include_range.rb
227
216
  - lib/active_support/core_ext/range/include_time_with_zone.rb
228
217
  - lib/active_support/core_ext/range/overlaps.rb
229
218
  - lib/active_support/core_ext/regexp.rb
@@ -242,6 +231,8 @@ files:
242
231
  - lib/active_support/core_ext/string/starts_ends_with.rb
243
232
  - lib/active_support/core_ext/string/strip.rb
244
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
245
236
  - lib/active_support/core_ext/time.rb
246
237
  - lib/active_support/core_ext/time/acts_like.rb
247
238
  - lib/active_support/core_ext/time/calculations.rb
@@ -250,6 +241,7 @@ files:
250
241
  - lib/active_support/core_ext/time/zones.rb
251
242
  - lib/active_support/core_ext/uri.rb
252
243
  - lib/active_support/current_attributes.rb
244
+ - lib/active_support/current_attributes/test_helper.rb
253
245
  - lib/active_support/dependencies.rb
254
246
  - lib/active_support/dependencies/autoload.rb
255
247
  - lib/active_support/dependencies/interlock.rb
@@ -257,6 +249,7 @@ files:
257
249
  - lib/active_support/deprecation.rb
258
250
  - lib/active_support/deprecation/behaviors.rb
259
251
  - lib/active_support/deprecation/constant_accessor.rb
252
+ - lib/active_support/deprecation/disallowed.rb
260
253
  - lib/active_support/deprecation/instance_delegator.rb
261
254
  - lib/active_support/deprecation/method_wrappers.rb
262
255
  - lib/active_support/deprecation/proxy_wrappers.rb
@@ -268,10 +261,12 @@ files:
268
261
  - lib/active_support/duration/iso8601_serializer.rb
269
262
  - lib/active_support/encrypted_configuration.rb
270
263
  - lib/active_support/encrypted_file.rb
264
+ - lib/active_support/environment_inquirer.rb
271
265
  - lib/active_support/evented_file_update_checker.rb
272
266
  - lib/active_support/execution_wrapper.rb
273
267
  - lib/active_support/executor.rb
274
268
  - lib/active_support/file_update_checker.rb
269
+ - lib/active_support/fork_tracker.rb
275
270
  - lib/active_support/gem_version.rb
276
271
  - lib/active_support/gzip.rb
277
272
  - lib/active_support/hash_with_indifferent_access.rb
@@ -325,6 +320,7 @@ files:
325
320
  - lib/active_support/railtie.rb
326
321
  - lib/active_support/reloader.rb
327
322
  - lib/active_support/rescuable.rb
323
+ - lib/active_support/secure_compare_rotator.rb
328
324
  - lib/active_support/security_utils.rb
329
325
  - lib/active_support/string_inquirer.rb
330
326
  - lib/active_support/subscriber.rb
@@ -339,6 +335,8 @@ files:
339
335
  - lib/active_support/testing/isolation.rb
340
336
  - lib/active_support/testing/method_call_assertions.rb
341
337
  - lib/active_support/testing/parallelization.rb
338
+ - lib/active_support/testing/parallelization/server.rb
339
+ - lib/active_support/testing/parallelization/worker.rb
342
340
  - lib/active_support/testing/setup_and_teardown.rb
343
341
  - lib/active_support/testing/stream.rb
344
342
  - lib/active_support/testing/tagged_logging.rb
@@ -359,12 +357,11 @@ licenses:
359
357
  - MIT
360
358
  metadata:
361
359
  bug_tracker_uri: https://github.com/rails/rails/issues
362
- changelog_uri: https://github.com/rails/rails/blob/v6.0.6.1/activesupport/CHANGELOG.md
363
- documentation_uri: https://api.rubyonrails.org/v6.0.6.1/
360
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.0.rc1/activesupport/CHANGELOG.md
361
+ documentation_uri: https://api.rubyonrails.org/v6.1.0.rc1/
364
362
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
365
- source_code_uri: https://github.com/rails/rails/tree/v6.0.6.1/activesupport
366
- rubygems_mfa_required: 'true'
367
- post_install_message:
363
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.0.rc1/activesupport
364
+ post_install_message:
368
365
  rdoc_options:
369
366
  - "--encoding"
370
367
  - UTF-8
@@ -377,12 +374,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
377
374
  version: 2.5.0
378
375
  required_rubygems_version: !ruby/object:Gem::Requirement
379
376
  requirements:
380
- - - ">="
377
+ - - ">"
381
378
  - !ruby/object:Gem::Version
382
- version: '0'
379
+ version: 1.3.1
383
380
  requirements: []
384
- rubygems_version: 3.4.3
385
- signing_key:
381
+ rubygems_version: 3.1.4
382
+ signing_key:
386
383
  specification_version: 4
387
384
  summary: A toolkit of support libraries and Ruby core extensions extracted from the
388
385
  Rails framework.
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/deprecation"
4
-
5
- ActiveSupport::Deprecation.warn "Ruby 2.5+ (required by Rails 6) provides Array#append and Array#prepend natively, so requiring active_support/core_ext/array/prepend_and_append is no longer necessary. Requiring it will raise LoadError in Rails 6.1."
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/deprecation"
4
-
5
- ActiveSupport::Deprecation.warn "Ruby 2.5+ (required by Rails 6) provides Hash#compact and Hash#compact! natively, so requiring active_support/core_ext/hash/compact is no longer necessary. Requiring it will raise LoadError in Rails 6.1."
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/deprecation"
4
-
5
- ActiveSupport::Deprecation.warn "Ruby 2.5+ (required by Rails 6) provides Hash#transform_values natively, so requiring active_support/core_ext/hash/transform_values is no longer necessary. Requiring it will raise LoadError in Rails 6.1."
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/core_ext/module/anonymous"
4
- require "active_support/core_ext/string/inflections"
5
-
6
- ActiveSupport::Deprecation.warn("reachable is deprecated and will be removed from the framework.")
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/deprecation"
4
-
5
- ActiveSupport::Deprecation.warn "Ruby 2.5+ (required by Rails 6) provides Numeric#positive? and Numeric#negative? natively, so requiring active_support/core_ext/numeric/inquiry is no longer necessary. Requiring it will raise LoadError in Rails 6.1."
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/deprecation"
4
-
5
- ActiveSupport::Deprecation.warn "You have required `active_support/core_ext/range/include_range`. " \
6
- "This file will be removed in Rails 6.1. You should require `active_support/core_ext/range/compare_range` " \
7
- "instead."
8
-
9
- require "active_support/core_ext/range/compare_range"