activesupport 7.1.3.2 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +74 -1126
- data/lib/active_support/array_inquirer.rb +1 -1
- data/lib/active_support/backtrace_cleaner.rb +15 -3
- data/lib/active_support/benchmark.rb +21 -0
- data/lib/active_support/benchmarkable.rb +3 -2
- data/lib/active_support/broadcast_logger.rb +19 -18
- data/lib/active_support/cache/file_store.rb +27 -12
- data/lib/active_support/cache/mem_cache_store.rb +16 -74
- data/lib/active_support/cache/memory_store.rb +8 -3
- data/lib/active_support/cache/redis_cache_store.rb +21 -15
- data/lib/active_support/cache/serializer_with_fallback.rb +0 -23
- data/lib/active_support/cache.rb +76 -78
- data/lib/active_support/callbacks.rb +79 -116
- data/lib/active_support/class_attribute.rb +33 -0
- data/lib/active_support/code_generator.rb +24 -10
- data/lib/active_support/concurrency/share_lock.rb +0 -1
- data/lib/active_support/configuration_file.rb +15 -6
- data/lib/active_support/core_ext/array/conversions.rb +3 -5
- data/lib/active_support/core_ext/benchmark.rb +6 -9
- data/lib/active_support/core_ext/class/attribute.rb +24 -20
- data/lib/active_support/core_ext/class/subclasses.rb +15 -35
- data/lib/active_support/core_ext/date/blank.rb +4 -0
- data/lib/active_support/core_ext/date/conversions.rb +2 -2
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +28 -1
- data/lib/active_support/core_ext/date_time/blank.rb +4 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +0 -4
- data/lib/active_support/core_ext/digest/uuid.rb +6 -0
- data/lib/active_support/core_ext/enumerable.rb +8 -3
- data/lib/active_support/core_ext/erb/util.rb +7 -2
- data/lib/active_support/core_ext/hash/except.rb +0 -12
- data/lib/active_support/core_ext/hash/keys.rb +4 -4
- data/lib/active_support/core_ext/module/attr_internal.rb +16 -6
- data/lib/active_support/core_ext/module/delegation.rb +20 -148
- data/lib/active_support/core_ext/module/deprecation.rb +1 -4
- data/lib/active_support/core_ext/numeric/conversions.rb +3 -3
- data/lib/active_support/core_ext/object/blank.rb +45 -1
- data/lib/active_support/core_ext/object/duplicable.rb +24 -15
- data/lib/active_support/core_ext/object/instance_variables.rb +11 -19
- data/lib/active_support/core_ext/object/json.rb +21 -13
- data/lib/active_support/core_ext/object/with.rb +5 -3
- data/lib/active_support/core_ext/pathname/blank.rb +4 -0
- data/lib/active_support/core_ext/range/overlap.rb +1 -1
- data/lib/active_support/core_ext/securerandom.rb +4 -4
- data/lib/active_support/core_ext/string/conversions.rb +1 -1
- data/lib/active_support/core_ext/string/filters.rb +1 -1
- data/lib/active_support/core_ext/string/multibyte.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +0 -7
- data/lib/active_support/core_ext/thread/backtrace/location.rb +2 -7
- data/lib/active_support/core_ext/time/calculations.rb +32 -30
- data/lib/active_support/core_ext/time/compatibility.rb +24 -0
- data/lib/active_support/core_ext/time/conversions.rb +2 -2
- data/lib/active_support/core_ext/time/zones.rb +1 -1
- data/lib/active_support/core_ext.rb +0 -1
- data/lib/active_support/current_attributes.rb +38 -40
- data/lib/active_support/delegation.rb +200 -0
- data/lib/active_support/dependencies/autoload.rb +0 -12
- data/lib/active_support/dependencies.rb +0 -1
- data/lib/active_support/deprecation/constant_accessor.rb +47 -26
- data/lib/active_support/deprecation/proxy_wrappers.rb +9 -12
- data/lib/active_support/deprecation/reporting.rb +3 -17
- data/lib/active_support/deprecation.rb +8 -5
- data/lib/active_support/descendants_tracker.rb +9 -87
- data/lib/active_support/duration/iso8601_parser.rb +2 -2
- data/lib/active_support/duration/iso8601_serializer.rb +1 -2
- data/lib/active_support/duration.rb +25 -16
- data/lib/active_support/encrypted_configuration.rb +20 -2
- data/lib/active_support/encrypted_file.rb +1 -1
- data/lib/active_support/error_reporter.rb +65 -3
- data/lib/active_support/evented_file_update_checker.rb +0 -2
- data/lib/active_support/execution_wrapper.rb +0 -1
- data/lib/active_support/file_update_checker.rb +1 -1
- data/lib/active_support/fork_tracker.rb +2 -38
- data/lib/active_support/gem_version.rb +4 -4
- data/lib/active_support/hash_with_indifferent_access.rb +21 -23
- data/lib/active_support/html_safe_translation.rb +7 -4
- data/lib/active_support/i18n_railtie.rb +19 -11
- data/lib/active_support/isolated_execution_state.rb +0 -2
- data/lib/active_support/json/encoding.rb +3 -3
- data/lib/active_support/log_subscriber.rb +1 -12
- data/lib/active_support/logger.rb +15 -2
- data/lib/active_support/logger_thread_safe_level.rb +0 -8
- data/lib/active_support/message_pack/extensions.rb +15 -2
- data/lib/active_support/message_verifier.rb +12 -0
- data/lib/active_support/messages/codec.rb +1 -1
- data/lib/active_support/multibyte/chars.rb +2 -2
- data/lib/active_support/notifications/fanout.rb +4 -8
- data/lib/active_support/notifications/instrumenter.rb +32 -21
- data/lib/active_support/notifications.rb +28 -27
- data/lib/active_support/number_helper/number_converter.rb +2 -2
- data/lib/active_support/number_helper.rb +22 -0
- data/lib/active_support/option_merger.rb +2 -2
- data/lib/active_support/ordered_options.rb +53 -15
- data/lib/active_support/railtie.rb +8 -11
- data/lib/active_support/string_inquirer.rb +1 -1
- data/lib/active_support/subscriber.rb +1 -0
- data/lib/active_support/syntax_error_proxy.rb +1 -11
- data/lib/active_support/tagged_logging.rb +9 -1
- data/lib/active_support/test_case.rb +3 -1
- data/lib/active_support/testing/assertions.rb +79 -21
- data/lib/active_support/testing/constant_stubbing.rb +30 -8
- data/lib/active_support/testing/deprecation.rb +5 -12
- data/lib/active_support/testing/isolation.rb +19 -9
- data/lib/active_support/testing/method_call_assertions.rb +2 -16
- data/lib/active_support/testing/parallelization/server.rb +3 -0
- data/lib/active_support/testing/setup_and_teardown.rb +2 -0
- data/lib/active_support/testing/strict_warnings.rb +8 -4
- data/lib/active_support/testing/tests_without_assertions.rb +19 -0
- data/lib/active_support/testing/time_helpers.rb +4 -3
- data/lib/active_support/time_with_zone.rb +30 -17
- data/lib/active_support/values/time_zone.rb +25 -14
- data/lib/active_support/xml_mini.rb +11 -2
- data/lib/active_support.rb +12 -4
- metadata +68 -19
- data/lib/active_support/deprecation/instance_delegator.rb +0 -65
- data/lib/active_support/proxy_object.rb +0 -17
- data/lib/active_support/ruby_features.rb +0 -7
|
@@ -5,6 +5,8 @@ Warning[:deprecated] = true
|
|
|
5
5
|
|
|
6
6
|
module ActiveSupport
|
|
7
7
|
module RaiseWarnings # :nodoc:
|
|
8
|
+
class WarningError < StandardError; end
|
|
9
|
+
|
|
8
10
|
PROJECT_ROOT = File.expand_path("../../../../", __dir__)
|
|
9
11
|
ALLOWED_WARNINGS = Regexp.union(
|
|
10
12
|
/circular require considered harmful.*delayed_job/, # Bug in delayed job.
|
|
@@ -12,6 +14,9 @@ module ActiveSupport
|
|
|
12
14
|
# Expected non-verbose warning emitted by Rails.
|
|
13
15
|
/Ignoring .*\.yml because it has expired/,
|
|
14
16
|
/Failed to validate the schema cache because/,
|
|
17
|
+
|
|
18
|
+
# TODO: We need to decide what to do with this.
|
|
19
|
+
/Status code :unprocessable_entity is deprecated/,
|
|
15
20
|
)
|
|
16
21
|
|
|
17
22
|
SUPPRESSED_WARNINGS = Regexp.union(
|
|
@@ -21,18 +26,17 @@ module ActiveSupport
|
|
|
21
26
|
%r{/lib/mail/parsers/.*assigned but unused variable - testEof}
|
|
22
27
|
)
|
|
23
28
|
|
|
24
|
-
def warn(message,
|
|
29
|
+
def warn(message, ...)
|
|
25
30
|
return if SUPPRESSED_WARNINGS.match?(message)
|
|
26
31
|
|
|
27
32
|
super
|
|
28
33
|
|
|
29
34
|
return unless message.include?(PROJECT_ROOT)
|
|
30
35
|
return if ALLOWED_WARNINGS.match?(message)
|
|
31
|
-
return unless ENV["RAILS_STRICT_WARNINGS"] || ENV["
|
|
36
|
+
return unless ENV["RAILS_STRICT_WARNINGS"] || ENV["BUILDKITE"]
|
|
32
37
|
|
|
33
|
-
raise message
|
|
38
|
+
raise WarningError.new(message)
|
|
34
39
|
end
|
|
35
|
-
ruby2_keywords :warn if respond_to?(:ruby2_keywords, true)
|
|
36
40
|
end
|
|
37
41
|
end
|
|
38
42
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ActiveSupport
|
|
4
|
+
module Testing
|
|
5
|
+
# Warns when a test case does not perform any assertions.
|
|
6
|
+
#
|
|
7
|
+
# This is helpful in detecting broken tests that do not perform intended assertions.
|
|
8
|
+
module TestsWithoutAssertions # :nodoc:
|
|
9
|
+
def after_teardown
|
|
10
|
+
super
|
|
11
|
+
|
|
12
|
+
if assertions.zero? && !skipped? && !error?
|
|
13
|
+
file, line = method(name).source_location
|
|
14
|
+
warn "Test is missing assertions: `#{name}` #{file}:#{line}"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -163,12 +163,13 @@ module ActiveSupport
|
|
|
163
163
|
now = date_or_time.midnight.to_time
|
|
164
164
|
elsif date_or_time.is_a?(String)
|
|
165
165
|
now = Time.zone.parse(date_or_time)
|
|
166
|
-
elsif with_usec
|
|
167
|
-
now = date_or_time.to_time
|
|
168
166
|
else
|
|
169
|
-
now = date_or_time
|
|
167
|
+
now = date_or_time
|
|
168
|
+
now = now.to_time unless now.is_a?(Time)
|
|
170
169
|
end
|
|
171
170
|
|
|
171
|
+
now = now.change(usec: 0) unless with_usec
|
|
172
|
+
|
|
172
173
|
# +now+ must be in local system timezone, because +Time.at(now)+
|
|
173
174
|
# and +now.to_date+ (see stubs below) will use +now+'s timezone too!
|
|
174
175
|
now = now.getlocal
|
|
@@ -85,7 +85,7 @@ module ActiveSupport
|
|
|
85
85
|
end
|
|
86
86
|
alias_method :getlocal, :localtime
|
|
87
87
|
|
|
88
|
-
# Returns true if the current time is within Daylight Savings Time for the
|
|
88
|
+
# Returns true if the current time is within Daylight Savings \Time for the
|
|
89
89
|
# specified time zone.
|
|
90
90
|
#
|
|
91
91
|
# Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
|
|
@@ -136,9 +136,9 @@ module ActiveSupport
|
|
|
136
136
|
|
|
137
137
|
# Returns a string of the object's date, time, zone, and offset from UTC.
|
|
138
138
|
#
|
|
139
|
-
# Time.zone.now.inspect # => "
|
|
139
|
+
# Time.zone.now.inspect # => "2024-11-13 07:00:10.528054960 UTC +00:00"
|
|
140
140
|
def inspect
|
|
141
|
-
"#{time.strftime('%
|
|
141
|
+
"#{time.strftime('%F %H:%M:%S.%9N')} #{zone} #{formatted_offset}"
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
# Returns a string of the object's date and time in the ISO 8601 standard
|
|
@@ -157,11 +157,11 @@ module ActiveSupport
|
|
|
157
157
|
# to +false+.
|
|
158
158
|
#
|
|
159
159
|
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true
|
|
160
|
-
# Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").
|
|
160
|
+
# Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").as_json
|
|
161
161
|
# # => "2005-02-01T05:15:10.000-10:00"
|
|
162
162
|
#
|
|
163
163
|
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
|
|
164
|
-
# Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").
|
|
164
|
+
# Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").as_json
|
|
165
165
|
# # => "2005/02/01 05:15:10 -1000"
|
|
166
166
|
def as_json(options = nil)
|
|
167
167
|
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
|
|
@@ -215,8 +215,7 @@ module ActiveSupport
|
|
|
215
215
|
elsif formatter = ::Time::DATE_FORMATS[format]
|
|
216
216
|
formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
|
|
217
217
|
else
|
|
218
|
-
|
|
219
|
-
"#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}"
|
|
218
|
+
to_s
|
|
220
219
|
end
|
|
221
220
|
end
|
|
222
221
|
alias_method :to_formatted_s, :to_fs
|
|
@@ -300,7 +299,16 @@ module ActiveSupport
|
|
|
300
299
|
if duration_of_variable_length?(other)
|
|
301
300
|
method_missing(:+, other)
|
|
302
301
|
else
|
|
303
|
-
|
|
302
|
+
begin
|
|
303
|
+
result = utc + other
|
|
304
|
+
rescue TypeError
|
|
305
|
+
result = utc.to_datetime.since(other)
|
|
306
|
+
ActiveSupport.deprecator.warn(
|
|
307
|
+
"Adding an instance of #{other.class} to an instance of #{self.class} is deprecated. This behavior will raise " \
|
|
308
|
+
"a `TypeError` in Rails 8.1."
|
|
309
|
+
)
|
|
310
|
+
result.in_time_zone(time_zone)
|
|
311
|
+
end
|
|
304
312
|
result.in_time_zone(time_zone)
|
|
305
313
|
end
|
|
306
314
|
end
|
|
@@ -332,11 +340,11 @@ module ActiveSupport
|
|
|
332
340
|
#
|
|
333
341
|
def -(other)
|
|
334
342
|
if other.acts_like?(:time)
|
|
335
|
-
|
|
343
|
+
getutc - other.getutc
|
|
336
344
|
elsif duration_of_variable_length?(other)
|
|
337
345
|
method_missing(:-, other)
|
|
338
346
|
else
|
|
339
|
-
result = utc
|
|
347
|
+
result = utc - other
|
|
340
348
|
result.in_time_zone(time_zone)
|
|
341
349
|
end
|
|
342
350
|
end
|
|
@@ -375,8 +383,8 @@ module ActiveSupport
|
|
|
375
383
|
#
|
|
376
384
|
# t = Time.zone.now # => Fri, 14 Apr 2017 11:45:15.116992711 EST -05:00
|
|
377
385
|
# t.change(year: 2020) # => Tue, 14 Apr 2020 11:45:15.116992711 EST -05:00
|
|
378
|
-
# t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00.
|
|
379
|
-
# t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00.
|
|
386
|
+
# t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00.000000000 EST -05:00
|
|
387
|
+
# t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00.000000000 EST -05:00
|
|
380
388
|
# t.change(offset: "-10:00") # => Fri, 14 Apr 2017 11:45:15.116992711 HST -10:00
|
|
381
389
|
# t.change(zone: "Hawaii") # => Fri, 14 Apr 2017 11:45:15.116992711 HST -10:00
|
|
382
390
|
def change(options)
|
|
@@ -479,11 +487,13 @@ module ActiveSupport
|
|
|
479
487
|
@to_datetime ||= utc.to_datetime.new_offset(Rational(utc_offset, 86_400))
|
|
480
488
|
end
|
|
481
489
|
|
|
482
|
-
# Returns an instance of +Time+, either with the same
|
|
483
|
-
# as +self+ or in the local system timezone
|
|
484
|
-
# of +ActiveSupport.to_time_preserves_timezone+.
|
|
490
|
+
# Returns an instance of +Time+, either with the same timezone as +self+,
|
|
491
|
+
# with the same UTC offset as +self+ or in the local system timezone
|
|
492
|
+
# depending on the setting of +ActiveSupport.to_time_preserves_timezone+.
|
|
485
493
|
def to_time
|
|
486
|
-
if preserve_timezone
|
|
494
|
+
if preserve_timezone == :zone
|
|
495
|
+
@to_time_with_timezone ||= getlocal(time_zone)
|
|
496
|
+
elsif preserve_timezone
|
|
487
497
|
@to_time_with_instance_offset ||= getlocal(utc_offset)
|
|
488
498
|
else
|
|
489
499
|
@to_time_with_system_offset ||= getlocal
|
|
@@ -506,6 +516,10 @@ module ActiveSupport
|
|
|
506
516
|
false
|
|
507
517
|
end
|
|
508
518
|
|
|
519
|
+
def present? # :nodoc:
|
|
520
|
+
true
|
|
521
|
+
end
|
|
522
|
+
|
|
509
523
|
def freeze
|
|
510
524
|
# preload instance variables before freezing
|
|
511
525
|
period; utc; time; to_datetime; to_time
|
|
@@ -531,7 +545,6 @@ module ActiveSupport
|
|
|
531
545
|
# Ensure proxy class responds to all methods that underlying time instance
|
|
532
546
|
# responds to.
|
|
533
547
|
def respond_to_missing?(sym, include_priv)
|
|
534
|
-
return false if sym.to_sym == :acts_like_date?
|
|
535
548
|
time.respond_to?(sym, include_priv)
|
|
536
549
|
end
|
|
537
550
|
|
|
@@ -12,7 +12,7 @@ module ActiveSupport
|
|
|
12
12
|
# * Limit the set of zones provided by TZInfo to a meaningful subset of 134
|
|
13
13
|
# zones.
|
|
14
14
|
# * Retrieve and display zones with a friendlier name
|
|
15
|
-
# (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").
|
|
15
|
+
# (e.g., "Eastern \Time (US & Canada)" instead of "America/New_York").
|
|
16
16
|
# * Lazily load +TZInfo::Timezone+ instances only when they're needed.
|
|
17
17
|
# * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+,
|
|
18
18
|
# +parse+, +at+, and +now+ methods.
|
|
@@ -134,10 +134,10 @@ module ActiveSupport
|
|
|
134
134
|
"Mumbai" => "Asia/Kolkata",
|
|
135
135
|
"New Delhi" => "Asia/Kolkata",
|
|
136
136
|
"Kathmandu" => "Asia/Kathmandu",
|
|
137
|
-
"Astana" => "Asia/Dhaka",
|
|
138
137
|
"Dhaka" => "Asia/Dhaka",
|
|
139
138
|
"Sri Jayawardenepura" => "Asia/Colombo",
|
|
140
139
|
"Almaty" => "Asia/Almaty",
|
|
140
|
+
"Astana" => "Asia/Almaty",
|
|
141
141
|
"Novosibirsk" => "Asia/Novosibirsk",
|
|
142
142
|
"Rangoon" => "Asia/Rangoon",
|
|
143
143
|
"Bangkok" => "Asia/Bangkok",
|
|
@@ -208,7 +208,7 @@ module ActiveSupport
|
|
|
208
208
|
TZInfo::Timezone.get(MAPPING[name] || name)
|
|
209
209
|
end
|
|
210
210
|
|
|
211
|
-
alias_method :create, :new
|
|
211
|
+
alias_method :create, :new # :nodoc:
|
|
212
212
|
|
|
213
213
|
# Returns a TimeZone instance with the given name, or +nil+ if no
|
|
214
214
|
# such TimeZone instance exists. (This exists to support the use of
|
|
@@ -296,15 +296,22 @@ module ActiveSupport
|
|
|
296
296
|
attr_reader :name
|
|
297
297
|
attr_reader :tzinfo
|
|
298
298
|
|
|
299
|
+
##
|
|
300
|
+
# :singleton-method: create
|
|
301
|
+
# :call-seq: create(name, utc_offset = nil, tzinfo = nil)
|
|
302
|
+
#
|
|
299
303
|
# Create a new TimeZone object with the given name and offset. The
|
|
300
304
|
# offset is the number of seconds that this time zone is offset from UTC
|
|
301
305
|
# (GMT). Seconds were chosen as the offset unit because that is the unit
|
|
302
306
|
# that Ruby uses to represent time zone offsets (see Time#utc_offset).
|
|
307
|
+
|
|
308
|
+
# :stopdoc:
|
|
303
309
|
def initialize(name, utc_offset = nil, tzinfo = nil)
|
|
304
310
|
@name = name
|
|
305
311
|
@utc_offset = utc_offset
|
|
306
312
|
@tzinfo = tzinfo || TimeZone.find_tzinfo(name)
|
|
307
313
|
end
|
|
314
|
+
# :startdoc:
|
|
308
315
|
|
|
309
316
|
# Returns the offset of this time zone from UTC in seconds.
|
|
310
317
|
def utc_offset
|
|
@@ -348,7 +355,7 @@ module ActiveSupport
|
|
|
348
355
|
"(GMT#{formatted_offset}) #{name}"
|
|
349
356
|
end
|
|
350
357
|
|
|
351
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
358
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
352
359
|
# of +self+ from given values.
|
|
353
360
|
#
|
|
354
361
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
|
@@ -358,7 +365,7 @@ module ActiveSupport
|
|
|
358
365
|
ActiveSupport::TimeWithZone.new(nil, self, time)
|
|
359
366
|
end
|
|
360
367
|
|
|
361
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
368
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
362
369
|
# of +self+ from number of seconds since the Unix epoch.
|
|
363
370
|
#
|
|
364
371
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
|
@@ -373,7 +380,7 @@ module ActiveSupport
|
|
|
373
380
|
Time.at(*args).utc.in_time_zone(self)
|
|
374
381
|
end
|
|
375
382
|
|
|
376
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
383
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
377
384
|
# of +self+ from an ISO 8601 string.
|
|
378
385
|
#
|
|
379
386
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
|
@@ -425,7 +432,7 @@ module ActiveSupport
|
|
|
425
432
|
raise ArgumentError, "invalid date"
|
|
426
433
|
end
|
|
427
434
|
|
|
428
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
435
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
429
436
|
# of +self+ from parsed string.
|
|
430
437
|
#
|
|
431
438
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
|
@@ -447,7 +454,7 @@ module ActiveSupport
|
|
|
447
454
|
parts_to_time(Date._parse(str, false), now)
|
|
448
455
|
end
|
|
449
456
|
|
|
450
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
457
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
|
451
458
|
# of +self+ from an RFC 3339 string.
|
|
452
459
|
#
|
|
453
460
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
|
@@ -545,15 +552,11 @@ module ActiveSupport
|
|
|
545
552
|
tzinfo.local_to_utc(time, dst)
|
|
546
553
|
end
|
|
547
554
|
|
|
548
|
-
|
|
549
|
-
# instances.
|
|
550
|
-
def period_for_utc(time)
|
|
555
|
+
def period_for_utc(time) # :nodoc:
|
|
551
556
|
tzinfo.period_for_utc(time)
|
|
552
557
|
end
|
|
553
558
|
|
|
554
|
-
|
|
555
|
-
# instances.
|
|
556
|
-
def period_for_local(time, dst = true)
|
|
559
|
+
def period_for_local(time, dst = true) # :nodoc:
|
|
557
560
|
tzinfo.period_for_local(time, dst) { |periods| periods.last }
|
|
558
561
|
end
|
|
559
562
|
|
|
@@ -561,6 +564,14 @@ module ActiveSupport
|
|
|
561
564
|
tzinfo.periods_for_local(time)
|
|
562
565
|
end
|
|
563
566
|
|
|
567
|
+
def abbr(time) # :nodoc:
|
|
568
|
+
tzinfo.abbr(time)
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
def dst?(time) # :nodoc:
|
|
572
|
+
tzinfo.dst?(time)
|
|
573
|
+
end
|
|
574
|
+
|
|
564
575
|
def init_with(coder) # :nodoc:
|
|
565
576
|
initialize(coder["name"])
|
|
566
577
|
end
|
|
@@ -12,7 +12,7 @@ module ActiveSupport
|
|
|
12
12
|
# = \XmlMini
|
|
13
13
|
#
|
|
14
14
|
# To use the much faster libxml parser:
|
|
15
|
-
# gem
|
|
15
|
+
# gem "libxml-ruby"
|
|
16
16
|
# XmlMini.backend = 'LibXML'
|
|
17
17
|
module XmlMini
|
|
18
18
|
extend self
|
|
@@ -46,6 +46,7 @@ module ActiveSupport
|
|
|
46
46
|
"Date" => "date",
|
|
47
47
|
"DateTime" => "dateTime",
|
|
48
48
|
"Time" => "dateTime",
|
|
49
|
+
"ActiveSupport::Duration" => "duration",
|
|
49
50
|
"Array" => "array",
|
|
50
51
|
"Hash" => "hash"
|
|
51
52
|
}
|
|
@@ -56,6 +57,7 @@ module ActiveSupport
|
|
|
56
57
|
"symbol" => Proc.new { |symbol| symbol.to_s },
|
|
57
58
|
"date" => Proc.new { |date| date.to_fs(:db) },
|
|
58
59
|
"dateTime" => Proc.new { |time| time.xmlschema },
|
|
60
|
+
"duration" => Proc.new { |duration| duration.iso8601 },
|
|
59
61
|
"binary" => Proc.new { |binary| ::Base64.encode64(binary) },
|
|
60
62
|
"yaml" => Proc.new { |yaml| yaml.to_yaml }
|
|
61
63
|
} unless defined?(FORMATTING)
|
|
@@ -66,6 +68,7 @@ module ActiveSupport
|
|
|
66
68
|
"symbol" => Proc.new { |symbol| symbol.to_s.to_sym },
|
|
67
69
|
"date" => Proc.new { |date| ::Date.parse(date) },
|
|
68
70
|
"datetime" => Proc.new { |time| Time.xmlschema(time).utc rescue ::DateTime.parse(time).utc },
|
|
71
|
+
"duration" => Proc.new { |duration| Duration.parse(duration) },
|
|
69
72
|
"integer" => Proc.new { |integer| integer.to_i },
|
|
70
73
|
"float" => Proc.new { |float| float.to_f },
|
|
71
74
|
"decimal" => Proc.new do |number|
|
|
@@ -79,6 +82,7 @@ module ActiveSupport
|
|
|
79
82
|
"string" => Proc.new { |string| string.to_s },
|
|
80
83
|
"yaml" => Proc.new { |yaml| YAML.load(yaml) rescue yaml },
|
|
81
84
|
"base64Binary" => Proc.new { |bin| ::Base64.decode64(bin) },
|
|
85
|
+
"hexBinary" => Proc.new { |bin| _parse_hex_binary(bin) },
|
|
82
86
|
"binary" => Proc.new { |bin, entity| _parse_binary(bin, entity) },
|
|
83
87
|
"file" => Proc.new { |file, entity| _parse_file(file, entity) }
|
|
84
88
|
}
|
|
@@ -162,11 +166,12 @@ module ActiveSupport
|
|
|
162
166
|
"#{left}#{middle.tr('_ ', '--')}#{right}"
|
|
163
167
|
end
|
|
164
168
|
|
|
165
|
-
# TODO: Add support for other encodings
|
|
166
169
|
def _parse_binary(bin, entity)
|
|
167
170
|
case entity["encoding"]
|
|
168
171
|
when "base64"
|
|
169
172
|
::Base64.decode64(bin)
|
|
173
|
+
when "hex", "hexBinary"
|
|
174
|
+
_parse_hex_binary(bin)
|
|
170
175
|
else
|
|
171
176
|
bin
|
|
172
177
|
end
|
|
@@ -180,6 +185,10 @@ module ActiveSupport
|
|
|
180
185
|
f
|
|
181
186
|
end
|
|
182
187
|
|
|
188
|
+
def _parse_hex_binary(bin)
|
|
189
|
+
[bin].pack("H*")
|
|
190
|
+
end
|
|
191
|
+
|
|
183
192
|
def current_thread_backend
|
|
184
193
|
IsolatedExecutionState[:xml_mini_backend]
|
|
185
194
|
end
|
data/lib/active_support.rb
CHANGED
|
@@ -32,7 +32,7 @@ require "active_support/broadcast_logger"
|
|
|
32
32
|
require "active_support/lazy_load_hooks"
|
|
33
33
|
require "active_support/core_ext/date_and_time/compatibility"
|
|
34
34
|
|
|
35
|
-
# :include:
|
|
35
|
+
# :include: ../README.rdoc
|
|
36
36
|
module ActiveSupport
|
|
37
37
|
extend ActiveSupport::Autoload
|
|
38
38
|
|
|
@@ -57,12 +57,14 @@ module ActiveSupport
|
|
|
57
57
|
|
|
58
58
|
eager_autoload do
|
|
59
59
|
autoload :BacktraceCleaner
|
|
60
|
-
autoload :
|
|
60
|
+
autoload :Benchmark
|
|
61
61
|
autoload :Benchmarkable
|
|
62
62
|
autoload :Cache
|
|
63
63
|
autoload :Callbacks
|
|
64
64
|
autoload :Configurable
|
|
65
|
+
autoload :ClassAttribute
|
|
65
66
|
autoload :Deprecation
|
|
67
|
+
autoload :Delegation
|
|
66
68
|
autoload :Digest
|
|
67
69
|
autoload :ExecutionContext
|
|
68
70
|
autoload :Gzip
|
|
@@ -114,9 +116,15 @@ module ActiveSupport
|
|
|
114
116
|
end
|
|
115
117
|
|
|
116
118
|
def self.to_time_preserves_timezone=(value)
|
|
117
|
-
|
|
119
|
+
if !value
|
|
118
120
|
ActiveSupport.deprecator.warn(
|
|
119
|
-
"
|
|
121
|
+
"`to_time` will always preserve the receiver timezone rather than system local time in Rails 8.1. " \
|
|
122
|
+
"To opt in to the new behavior, set `config.active_support.to_time_preserves_timezone = :zone`."
|
|
123
|
+
)
|
|
124
|
+
elsif value != :zone
|
|
125
|
+
ActiveSupport.deprecator.warn(
|
|
126
|
+
"`to_time` will always preserve the full timezone rather than offset of the receiver in Rails 8.1. " \
|
|
127
|
+
"To opt in to the new behavior, set `config.active_support.to_time_preserves_timezone = :zone`."
|
|
120
128
|
)
|
|
121
129
|
end
|
|
122
130
|
|
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:
|
|
4
|
+
version: 8.0.1
|
|
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: 2024-
|
|
11
|
+
date: 2024-12-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: i18n
|
|
@@ -37,6 +37,9 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '2.0'
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 2.0.5
|
|
40
43
|
type: :runtime
|
|
41
44
|
prerelease: false
|
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -44,6 +47,9 @@ dependencies:
|
|
|
44
47
|
- - "~>"
|
|
45
48
|
- !ruby/object:Gem::Version
|
|
46
49
|
version: '2.0'
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 2.0.5
|
|
47
53
|
- !ruby/object:Gem::Dependency
|
|
48
54
|
name: concurrent-ruby
|
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,7 +59,7 @@ dependencies:
|
|
|
53
59
|
version: '1.0'
|
|
54
60
|
- - ">="
|
|
55
61
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: 1.
|
|
62
|
+
version: 1.3.1
|
|
57
63
|
type: :runtime
|
|
58
64
|
prerelease: false
|
|
59
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -63,7 +69,7 @@ dependencies:
|
|
|
63
69
|
version: '1.0'
|
|
64
70
|
- - ">="
|
|
65
71
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: 1.
|
|
72
|
+
version: 1.3.1
|
|
67
73
|
- !ruby/object:Gem::Dependency
|
|
68
74
|
name: connection_pool
|
|
69
75
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -121,7 +127,7 @@ dependencies:
|
|
|
121
127
|
- !ruby/object:Gem::Version
|
|
122
128
|
version: '0'
|
|
123
129
|
- !ruby/object:Gem::Dependency
|
|
124
|
-
name:
|
|
130
|
+
name: bigdecimal
|
|
125
131
|
requirement: !ruby/object:Gem::Requirement
|
|
126
132
|
requirements:
|
|
127
133
|
- - ">="
|
|
@@ -135,19 +141,61 @@ dependencies:
|
|
|
135
141
|
- !ruby/object:Gem::Version
|
|
136
142
|
version: '0'
|
|
137
143
|
- !ruby/object:Gem::Dependency
|
|
138
|
-
name:
|
|
144
|
+
name: logger
|
|
139
145
|
requirement: !ruby/object:Gem::Requirement
|
|
140
146
|
requirements:
|
|
141
147
|
- - ">="
|
|
142
148
|
- !ruby/object:Gem::Version
|
|
143
|
-
version:
|
|
149
|
+
version: 1.4.2
|
|
144
150
|
type: :runtime
|
|
145
151
|
prerelease: false
|
|
146
152
|
version_requirements: !ruby/object:Gem::Requirement
|
|
147
153
|
requirements:
|
|
148
154
|
- - ">="
|
|
149
155
|
- !ruby/object:Gem::Version
|
|
150
|
-
version:
|
|
156
|
+
version: 1.4.2
|
|
157
|
+
- !ruby/object:Gem::Dependency
|
|
158
|
+
name: securerandom
|
|
159
|
+
requirement: !ruby/object:Gem::Requirement
|
|
160
|
+
requirements:
|
|
161
|
+
- - ">="
|
|
162
|
+
- !ruby/object:Gem::Version
|
|
163
|
+
version: '0.3'
|
|
164
|
+
type: :runtime
|
|
165
|
+
prerelease: false
|
|
166
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
167
|
+
requirements:
|
|
168
|
+
- - ">="
|
|
169
|
+
- !ruby/object:Gem::Version
|
|
170
|
+
version: '0.3'
|
|
171
|
+
- !ruby/object:Gem::Dependency
|
|
172
|
+
name: uri
|
|
173
|
+
requirement: !ruby/object:Gem::Requirement
|
|
174
|
+
requirements:
|
|
175
|
+
- - ">="
|
|
176
|
+
- !ruby/object:Gem::Version
|
|
177
|
+
version: 0.13.1
|
|
178
|
+
type: :runtime
|
|
179
|
+
prerelease: false
|
|
180
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
181
|
+
requirements:
|
|
182
|
+
- - ">="
|
|
183
|
+
- !ruby/object:Gem::Version
|
|
184
|
+
version: 0.13.1
|
|
185
|
+
- !ruby/object:Gem::Dependency
|
|
186
|
+
name: benchmark
|
|
187
|
+
requirement: !ruby/object:Gem::Requirement
|
|
188
|
+
requirements:
|
|
189
|
+
- - ">="
|
|
190
|
+
- !ruby/object:Gem::Version
|
|
191
|
+
version: '0.3'
|
|
192
|
+
type: :runtime
|
|
193
|
+
prerelease: false
|
|
194
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
195
|
+
requirements:
|
|
196
|
+
- - ">="
|
|
197
|
+
- !ruby/object:Gem::Version
|
|
198
|
+
version: '0.3'
|
|
151
199
|
description: A toolkit of support libraries and Ruby core extensions extracted from
|
|
152
200
|
the Rails framework. Rich support for multibyte strings, internationalization, time
|
|
153
201
|
zones, and testing.
|
|
@@ -164,6 +212,7 @@ files:
|
|
|
164
212
|
- lib/active_support/all.rb
|
|
165
213
|
- lib/active_support/array_inquirer.rb
|
|
166
214
|
- lib/active_support/backtrace_cleaner.rb
|
|
215
|
+
- lib/active_support/benchmark.rb
|
|
167
216
|
- lib/active_support/benchmarkable.rb
|
|
168
217
|
- lib/active_support/broadcast_logger.rb
|
|
169
218
|
- lib/active_support/builder.rb
|
|
@@ -179,6 +228,7 @@ files:
|
|
|
179
228
|
- lib/active_support/cache/strategy/local_cache.rb
|
|
180
229
|
- lib/active_support/cache/strategy/local_cache_middleware.rb
|
|
181
230
|
- lib/active_support/callbacks.rb
|
|
231
|
+
- lib/active_support/class_attribute.rb
|
|
182
232
|
- lib/active_support/code_generator.rb
|
|
183
233
|
- lib/active_support/concern.rb
|
|
184
234
|
- lib/active_support/concurrency/load_interlock_aware_monitor.rb
|
|
@@ -308,6 +358,7 @@ files:
|
|
|
308
358
|
- lib/active_support/current_attributes.rb
|
|
309
359
|
- lib/active_support/current_attributes/test_helper.rb
|
|
310
360
|
- lib/active_support/deep_mergeable.rb
|
|
361
|
+
- lib/active_support/delegation.rb
|
|
311
362
|
- lib/active_support/dependencies.rb
|
|
312
363
|
- lib/active_support/dependencies/autoload.rb
|
|
313
364
|
- lib/active_support/dependencies/interlock.rb
|
|
@@ -317,7 +368,6 @@ files:
|
|
|
317
368
|
- lib/active_support/deprecation/constant_accessor.rb
|
|
318
369
|
- lib/active_support/deprecation/deprecators.rb
|
|
319
370
|
- lib/active_support/deprecation/disallowed.rb
|
|
320
|
-
- lib/active_support/deprecation/instance_delegator.rb
|
|
321
371
|
- lib/active_support/deprecation/method_wrappers.rb
|
|
322
372
|
- lib/active_support/deprecation/proxy_wrappers.rb
|
|
323
373
|
- lib/active_support/deprecation/reporting.rb
|
|
@@ -398,12 +448,10 @@ files:
|
|
|
398
448
|
- lib/active_support/ordered_hash.rb
|
|
399
449
|
- lib/active_support/ordered_options.rb
|
|
400
450
|
- lib/active_support/parameter_filter.rb
|
|
401
|
-
- lib/active_support/proxy_object.rb
|
|
402
451
|
- lib/active_support/rails.rb
|
|
403
452
|
- lib/active_support/railtie.rb
|
|
404
453
|
- lib/active_support/reloader.rb
|
|
405
454
|
- lib/active_support/rescuable.rb
|
|
406
|
-
- lib/active_support/ruby_features.rb
|
|
407
455
|
- lib/active_support/secure_compare_rotator.rb
|
|
408
456
|
- lib/active_support/security_utils.rb
|
|
409
457
|
- lib/active_support/string_inquirer.rb
|
|
@@ -429,6 +477,7 @@ files:
|
|
|
429
477
|
- lib/active_support/testing/stream.rb
|
|
430
478
|
- lib/active_support/testing/strict_warnings.rb
|
|
431
479
|
- lib/active_support/testing/tagged_logging.rb
|
|
480
|
+
- lib/active_support/testing/tests_without_assertions.rb
|
|
432
481
|
- lib/active_support/testing/time_helpers.rb
|
|
433
482
|
- lib/active_support/time.rb
|
|
434
483
|
- lib/active_support/time_with_zone.rb
|
|
@@ -446,12 +495,12 @@ licenses:
|
|
|
446
495
|
- MIT
|
|
447
496
|
metadata:
|
|
448
497
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
|
449
|
-
changelog_uri: https://github.com/rails/rails/blob/
|
|
450
|
-
documentation_uri: https://api.rubyonrails.org/
|
|
498
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.0.1/activesupport/CHANGELOG.md
|
|
499
|
+
documentation_uri: https://api.rubyonrails.org/v8.0.1/
|
|
451
500
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
|
452
|
-
source_code_uri: https://github.com/rails/rails/tree/
|
|
501
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.0.1/activesupport
|
|
453
502
|
rubygems_mfa_required: 'true'
|
|
454
|
-
post_install_message:
|
|
503
|
+
post_install_message:
|
|
455
504
|
rdoc_options:
|
|
456
505
|
- "--encoding"
|
|
457
506
|
- UTF-8
|
|
@@ -461,15 +510,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
461
510
|
requirements:
|
|
462
511
|
- - ">="
|
|
463
512
|
- !ruby/object:Gem::Version
|
|
464
|
-
version: 2.
|
|
513
|
+
version: 3.2.0
|
|
465
514
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
466
515
|
requirements:
|
|
467
516
|
- - ">="
|
|
468
517
|
- !ruby/object:Gem::Version
|
|
469
518
|
version: '0'
|
|
470
519
|
requirements: []
|
|
471
|
-
rubygems_version: 3.5.
|
|
472
|
-
signing_key:
|
|
520
|
+
rubygems_version: 3.5.22
|
|
521
|
+
signing_key:
|
|
473
522
|
specification_version: 4
|
|
474
523
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|
|
475
524
|
Rails framework.
|