activesupport 7.0.8.7 → 7.1.0.beta1
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 +722 -314
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -4
- data/lib/active_support/actionable_error.rb +3 -1
- data/lib/active_support/array_inquirer.rb +2 -0
- data/lib/active_support/backtrace_cleaner.rb +25 -5
- data/lib/active_support/benchmarkable.rb +1 -0
- data/lib/active_support/builder.rb +1 -1
- data/lib/active_support/cache/coder.rb +153 -0
- data/lib/active_support/cache/entry.rb +128 -0
- data/lib/active_support/cache/file_store.rb +36 -9
- data/lib/active_support/cache/mem_cache_store.rb +84 -68
- data/lib/active_support/cache/memory_store.rb +76 -24
- data/lib/active_support/cache/null_store.rb +6 -0
- data/lib/active_support/cache/redis_cache_store.rb +126 -131
- data/lib/active_support/cache/serializer_with_fallback.rb +175 -0
- data/lib/active_support/cache/strategy/local_cache.rb +20 -8
- data/lib/active_support/cache.rb +304 -246
- data/lib/active_support/callbacks.rb +38 -18
- data/lib/active_support/concern.rb +4 -2
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +42 -3
- data/lib/active_support/concurrency/null_lock.rb +13 -0
- data/lib/active_support/configurable.rb +10 -0
- data/lib/active_support/core_ext/array/conversions.rb +2 -1
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/class/subclasses.rb +13 -10
- data/lib/active_support/core_ext/date/conversions.rb +1 -0
- data/lib/active_support/core_ext/date.rb +0 -1
- data/lib/active_support/core_ext/date_and_time/calculations.rb +10 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +6 -2
- data/lib/active_support/core_ext/date_time.rb +0 -1
- data/lib/active_support/core_ext/digest/uuid.rb +1 -10
- data/lib/active_support/core_ext/enumerable.rb +3 -75
- data/lib/active_support/core_ext/erb/util.rb +196 -0
- data/lib/active_support/core_ext/hash/conversions.rb +1 -1
- data/lib/active_support/core_ext/module/attribute_accessors.rb +6 -0
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +34 -16
- data/lib/active_support/core_ext/module/delegation.rb +40 -11
- data/lib/active_support/core_ext/module/deprecation.rb +15 -12
- data/lib/active_support/core_ext/module/introspection.rb +0 -1
- data/lib/active_support/core_ext/numeric/bytes.rb +9 -0
- data/lib/active_support/core_ext/numeric/conversions.rb +2 -0
- data/lib/active_support/core_ext/numeric.rb +0 -1
- data/lib/active_support/core_ext/object/deep_dup.rb +16 -0
- data/lib/active_support/core_ext/object/duplicable.rb +15 -24
- data/lib/active_support/core_ext/object/inclusion.rb +13 -5
- data/lib/active_support/core_ext/object/instance_variables.rb +22 -12
- data/lib/active_support/core_ext/object/json.rb +10 -2
- data/lib/active_support/core_ext/object/with.rb +44 -0
- data/lib/active_support/core_ext/object/with_options.rb +3 -3
- data/lib/active_support/core_ext/object.rb +1 -0
- data/lib/active_support/core_ext/pathname/blank.rb +16 -0
- data/lib/active_support/core_ext/pathname/existence.rb +2 -0
- data/lib/active_support/core_ext/pathname.rb +1 -0
- data/lib/active_support/core_ext/range/conversions.rb +28 -7
- data/lib/active_support/core_ext/range/{overlaps.rb → overlap.rb} +5 -3
- data/lib/active_support/core_ext/range.rb +1 -2
- data/lib/active_support/core_ext/securerandom.rb +24 -12
- data/lib/active_support/core_ext/string/filters.rb +20 -14
- data/lib/active_support/core_ext/string/inflections.rb +16 -5
- data/lib/active_support/core_ext/string/output_safety.rb +38 -174
- data/lib/active_support/core_ext/thread/backtrace/location.rb +12 -0
- data/lib/active_support/core_ext/time/calculations.rb +18 -2
- data/lib/active_support/core_ext/time/conversions.rb +2 -2
- data/lib/active_support/core_ext/time/zones.rb +4 -4
- data/lib/active_support/core_ext/time.rb +0 -1
- data/lib/active_support/current_attributes.rb +15 -6
- data/lib/active_support/dependencies/autoload.rb +17 -12
- data/lib/active_support/deprecation/behaviors.rb +53 -32
- data/lib/active_support/deprecation/constant_accessor.rb +5 -4
- data/lib/active_support/deprecation/deprecators.rb +104 -0
- data/lib/active_support/deprecation/disallowed.rb +3 -5
- data/lib/active_support/deprecation/instance_delegator.rb +31 -4
- data/lib/active_support/deprecation/method_wrappers.rb +6 -23
- data/lib/active_support/deprecation/proxy_wrappers.rb +37 -22
- data/lib/active_support/deprecation/reporting.rb +35 -21
- data/lib/active_support/deprecation.rb +32 -5
- data/lib/active_support/deprecator.rb +7 -0
- data/lib/active_support/descendants_tracker.rb +104 -132
- data/lib/active_support/duration/iso8601_serializer.rb +0 -2
- data/lib/active_support/duration.rb +2 -1
- data/lib/active_support/encrypted_configuration.rb +30 -9
- data/lib/active_support/encrypted_file.rb +8 -3
- data/lib/active_support/environment_inquirer.rb +22 -2
- data/lib/active_support/error_reporter/test_helper.rb +15 -0
- data/lib/active_support/error_reporter.rb +121 -35
- data/lib/active_support/execution_wrapper.rb +4 -4
- data/lib/active_support/file_update_checker.rb +4 -2
- data/lib/active_support/fork_tracker.rb +10 -2
- data/lib/active_support/gem_version.rb +4 -4
- data/lib/active_support/gzip.rb +2 -0
- data/lib/active_support/hash_with_indifferent_access.rb +35 -17
- data/lib/active_support/i18n.rb +1 -1
- data/lib/active_support/i18n_railtie.rb +20 -13
- data/lib/active_support/inflector/inflections.rb +2 -0
- data/lib/active_support/inflector/methods.rb +22 -10
- data/lib/active_support/inflector/transliterate.rb +3 -1
- data/lib/active_support/isolated_execution_state.rb +26 -22
- data/lib/active_support/json/decoding.rb +2 -1
- data/lib/active_support/json/encoding.rb +25 -43
- data/lib/active_support/key_generator.rb +9 -1
- data/lib/active_support/lazy_load_hooks.rb +6 -4
- data/lib/active_support/locale/en.yml +2 -0
- data/lib/active_support/log_subscriber.rb +78 -33
- data/lib/active_support/logger.rb +1 -1
- data/lib/active_support/logger_thread_safe_level.rb +9 -21
- data/lib/active_support/message_encryptor.rb +197 -53
- data/lib/active_support/message_encryptors.rb +140 -0
- data/lib/active_support/message_pack/cache_serializer.rb +23 -0
- data/lib/active_support/message_pack/extensions.rb +292 -0
- data/lib/active_support/message_pack/serializer.rb +63 -0
- data/lib/active_support/message_pack.rb +50 -0
- data/lib/active_support/message_verifier.rb +212 -93
- data/lib/active_support/message_verifiers.rb +134 -0
- data/lib/active_support/messages/codec.rb +65 -0
- data/lib/active_support/messages/metadata.rb +111 -45
- data/lib/active_support/messages/rotation_coordinator.rb +93 -0
- data/lib/active_support/messages/rotator.rb +34 -32
- data/lib/active_support/messages/serializer_with_fallback.rb +158 -0
- data/lib/active_support/multibyte/chars.rb +2 -0
- data/lib/active_support/multibyte/unicode.rb +9 -37
- data/lib/active_support/notifications/fanout.rb +239 -81
- data/lib/active_support/notifications/instrumenter.rb +71 -14
- data/lib/active_support/notifications.rb +1 -1
- data/lib/active_support/number_helper/number_converter.rb +2 -2
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -0
- data/lib/active_support/ordered_hash.rb +3 -3
- data/lib/active_support/ordered_options.rb +14 -0
- data/lib/active_support/parameter_filter.rb +84 -69
- data/lib/active_support/proxy_object.rb +2 -0
- data/lib/active_support/railtie.rb +33 -21
- data/lib/active_support/reloader.rb +12 -4
- data/lib/active_support/rescuable.rb +2 -0
- data/lib/active_support/secure_compare_rotator.rb +16 -9
- data/lib/active_support/string_inquirer.rb +3 -1
- data/lib/active_support/subscriber.rb +9 -27
- data/lib/active_support/syntax_error_proxy.rb +49 -0
- data/lib/active_support/tagged_logging.rb +60 -24
- data/lib/active_support/test_case.rb +153 -6
- data/lib/active_support/testing/assertions.rb +25 -9
- data/lib/active_support/testing/autorun.rb +0 -2
- data/lib/active_support/testing/constant_stubbing.rb +32 -0
- data/lib/active_support/testing/deprecation.rb +25 -25
- data/lib/active_support/testing/error_reporter_assertions.rb +108 -0
- data/lib/active_support/testing/isolation.rb +1 -1
- data/lib/active_support/testing/method_call_assertions.rb +21 -8
- data/lib/active_support/testing/parallelize_executor.rb +8 -3
- data/lib/active_support/testing/stream.rb +1 -1
- data/lib/active_support/testing/strict_warnings.rb +38 -0
- data/lib/active_support/testing/time_helpers.rb +32 -14
- data/lib/active_support/time_with_zone.rb +4 -14
- data/lib/active_support/values/time_zone.rb +9 -7
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini/jdom.rb +3 -10
- data/lib/active_support/xml_mini/nokogiri.rb +1 -1
- data/lib/active_support/xml_mini/nokogirisax.rb +1 -1
- data/lib/active_support/xml_mini/rexml.rb +1 -1
- data/lib/active_support/xml_mini.rb +2 -2
- data/lib/active_support.rb +13 -3
- metadata +106 -21
- data/lib/active_support/core_ext/array/deprecated_conversions.rb +0 -25
- data/lib/active_support/core_ext/date/deprecated_conversions.rb +0 -40
- data/lib/active_support/core_ext/date_time/deprecated_conversions.rb +0 -36
- data/lib/active_support/core_ext/numeric/deprecated_conversions.rb +0 -60
- data/lib/active_support/core_ext/range/deprecated_conversions.rb +0 -36
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +0 -5
- data/lib/active_support/core_ext/time/deprecated_conversions.rb +0 -73
- data/lib/active_support/core_ext/uri.rb +0 -5
- data/lib/active_support/per_thread_registry.rb +0 -65
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require "active_support/core_ext/module/redefine_method"
|
4
4
|
require "active_support/core_ext/time/calculations"
|
5
|
-
require "concurrent/map"
|
6
5
|
|
7
6
|
module ActiveSupport
|
8
7
|
module Testing
|
@@ -11,7 +10,7 @@ module ActiveSupport
|
|
11
10
|
Stub = Struct.new(:object, :method_name, :original_method)
|
12
11
|
|
13
12
|
def initialize
|
14
|
-
@stubs =
|
13
|
+
@stubs = Hash.new { |h, k| h[k] = {} }
|
15
14
|
end
|
16
15
|
|
17
16
|
# Stubs object.method_name with the given block
|
@@ -76,6 +75,11 @@ module ActiveSupport
|
|
76
75
|
# stubbing +Time.now+, +Date.today+, and +DateTime.now+. The stubs are automatically removed
|
77
76
|
# at the end of the test.
|
78
77
|
#
|
78
|
+
# Note that the usec for the resulting time will be set to 0 to prevent rounding
|
79
|
+
# errors with external services, like MySQL (which will round instead of floor,
|
80
|
+
# leading to off-by-one-second errors), unless the <tt>with_usec</tt> argument
|
81
|
+
# is set to <tt>true</tt>.
|
82
|
+
#
|
79
83
|
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
|
80
84
|
# travel 1.day
|
81
85
|
# Time.current # => Sun, 10 Nov 2013 15:34:49 EST -05:00
|
@@ -90,11 +94,11 @@ module ActiveSupport
|
|
90
94
|
# User.create.created_at # => Sun, 10 Nov 2013 15:34:49 EST -05:00
|
91
95
|
# end
|
92
96
|
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
|
93
|
-
def travel(duration, &block)
|
94
|
-
travel_to Time.now + duration, &block
|
97
|
+
def travel(duration, with_usec: false, &block)
|
98
|
+
travel_to Time.now + duration, with_usec: with_usec, &block
|
95
99
|
end
|
96
100
|
|
97
|
-
# Changes current time to the given time by stubbing +Time.now+,
|
101
|
+
# Changes current time to the given time by stubbing +Time.now+, +Time.new+,
|
98
102
|
# +Date.today+, and +DateTime.now+ to return the time or date passed into this method.
|
99
103
|
# The stubs are automatically removed at the end of the test.
|
100
104
|
#
|
@@ -115,7 +119,8 @@ module ActiveSupport
|
|
115
119
|
#
|
116
120
|
# Note that the usec for the time passed will be set to 0 to prevent rounding
|
117
121
|
# errors with external services, like MySQL (which will round instead of floor,
|
118
|
-
# leading to off-by-one-second errors)
|
122
|
+
# leading to off-by-one-second errors), unless the <tt>with_usec</tt> argument
|
123
|
+
# is set to <tt>true</tt>.
|
119
124
|
#
|
120
125
|
# This method also accepts a block, which will return the current time back to its original
|
121
126
|
# state at the end of the block:
|
@@ -125,7 +130,7 @@ module ActiveSupport
|
|
125
130
|
# Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
|
126
131
|
# end
|
127
132
|
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
|
128
|
-
def travel_to(date_or_time)
|
133
|
+
def travel_to(date_or_time, with_usec: false)
|
129
134
|
if block_given? && in_block
|
130
135
|
travel_to_nested_block_call = <<~MSG
|
131
136
|
|
@@ -158,14 +163,27 @@ module ActiveSupport
|
|
158
163
|
now = date_or_time.midnight.to_time
|
159
164
|
elsif date_or_time.is_a?(String)
|
160
165
|
now = Time.zone.parse(date_or_time)
|
166
|
+
elsif with_usec
|
167
|
+
now = date_or_time.to_time
|
161
168
|
else
|
162
169
|
now = date_or_time.to_time.change(usec: 0)
|
163
170
|
end
|
164
171
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
172
|
+
stubs = simple_stubs
|
173
|
+
stubbed_time = Time.now if stubs.stubbing(Time, :now)
|
174
|
+
stubs.stub_object(Time, :now) { at(now) }
|
175
|
+
|
176
|
+
stubs.stub_object(Time, :new) do |*args, **options|
|
177
|
+
if args.empty? && options.empty?
|
178
|
+
at(now)
|
179
|
+
else
|
180
|
+
stub = stubs.stubbing(Time, :new)
|
181
|
+
Time.send(stub.original_method, *args, **options)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
stubs.stub_object(Date, :today) { jd(now.to_date.jd) }
|
186
|
+
stubs.stub_object(DateTime, :now) { jd(now.to_date.jd, now.hour, now.min, now.sec, Rational(now.utc_offset, 86400)) }
|
169
187
|
|
170
188
|
if block_given?
|
171
189
|
begin
|
@@ -215,7 +233,7 @@ module ActiveSupport
|
|
215
233
|
end
|
216
234
|
alias_method :unfreeze_time, :travel_back
|
217
235
|
|
218
|
-
# Calls +travel_to+ with +Time.now+.
|
236
|
+
# Calls +travel_to+ with +Time.now+. Forwards optional <tt>with_usec</tt> argument.
|
219
237
|
#
|
220
238
|
# Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00
|
221
239
|
# freeze_time
|
@@ -231,8 +249,8 @@ module ActiveSupport
|
|
231
249
|
# User.create.created_at # => Sun, 09 Jul 2017 15:34:49 EST -05:00
|
232
250
|
# end
|
233
251
|
# Time.current # => Sun, 09 Jul 2017 15:34:50 EST -05:00
|
234
|
-
def freeze_time(&block)
|
235
|
-
travel_to Time.now, &block
|
252
|
+
def freeze_time(with_usec: false, &block)
|
253
|
+
travel_to Time.now, with_usec: with_usec, &block
|
236
254
|
end
|
237
255
|
|
238
256
|
private
|
@@ -8,6 +8,8 @@ require "active_support/core_ext/object/acts_like"
|
|
8
8
|
require "active_support/core_ext/date_and_time/compatibility"
|
9
9
|
|
10
10
|
module ActiveSupport
|
11
|
+
# = Active Support \Time With Zone
|
12
|
+
#
|
11
13
|
# A Time-like class that can represent a time in any time zone. Necessary
|
12
14
|
# because standard Ruby Time instances are limited to UTC and the
|
13
15
|
# system's <tt>ENV['TZ']</tt> zone.
|
@@ -40,18 +42,6 @@ module ActiveSupport
|
|
40
42
|
# t.is_a?(Time) # => true
|
41
43
|
# t.is_a?(ActiveSupport::TimeWithZone) # => true
|
42
44
|
class TimeWithZone
|
43
|
-
# Report class name as 'Time' to thwart type checking.
|
44
|
-
def self.name
|
45
|
-
ActiveSupport::Deprecation.warn(<<~EOM)
|
46
|
-
ActiveSupport::TimeWithZone.name has been deprecated and
|
47
|
-
from Rails 7.1 will use the default Ruby implementation.
|
48
|
-
You can set `config.active_support.remove_deprecated_time_with_zone_name = true`
|
49
|
-
to enable the new behavior now.
|
50
|
-
EOM
|
51
|
-
|
52
|
-
"Time"
|
53
|
-
end
|
54
|
-
|
55
45
|
PRECISIONS = Hash.new { |h, n| h[n] = "%FT%T.%#{n}N" }
|
56
46
|
PRECISIONS[0] = "%FT%T"
|
57
47
|
|
@@ -78,7 +68,7 @@ module ActiveSupport
|
|
78
68
|
alias_method :getutc, :utc
|
79
69
|
alias_method :gmtime, :utc
|
80
70
|
|
81
|
-
# Returns the underlying
|
71
|
+
# Returns the underlying +TZInfo::TimezonePeriod+.
|
82
72
|
def period
|
83
73
|
@period ||= time_zone.period_for_utc(@utc)
|
84
74
|
end
|
@@ -218,7 +208,7 @@ module ActiveSupport
|
|
218
208
|
# Accepts an optional <tt>format</tt>:
|
219
209
|
# * <tt>:default</tt> - default value, mimics Ruby Time#to_s format.
|
220
210
|
# * <tt>:db</tt> - format outputs time in UTC :db time. See Time#to_fs(:db).
|
221
|
-
# * Any key in
|
211
|
+
# * Any key in +Time::DATE_FORMATS+ can be used. See active_support/core_ext/time/conversions.rb.
|
222
212
|
def to_fs(format = :default)
|
223
213
|
if format == :db
|
224
214
|
utc.to_fs(format)
|
@@ -4,18 +4,20 @@ require "tzinfo"
|
|
4
4
|
require "concurrent/map"
|
5
5
|
|
6
6
|
module ActiveSupport
|
7
|
-
#
|
7
|
+
# = Active Support \Time Zone
|
8
|
+
#
|
9
|
+
# The TimeZone class serves as a wrapper around +TZInfo::Timezone+ instances.
|
8
10
|
# It allows us to do the following:
|
9
11
|
#
|
10
12
|
# * Limit the set of zones provided by TZInfo to a meaningful subset of 134
|
11
13
|
# zones.
|
12
14
|
# * Retrieve and display zones with a friendlier name
|
13
15
|
# (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").
|
14
|
-
# * Lazily load
|
16
|
+
# * Lazily load +TZInfo::Timezone+ instances only when they're needed.
|
15
17
|
# * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+,
|
16
18
|
# +parse+, +at+, and +now+ methods.
|
17
19
|
#
|
18
|
-
# If you set <tt>config.time_zone</tt> in the Rails Application, you can
|
20
|
+
# If you set <tt>config.time_zone</tt> in the \Rails Application, you can
|
19
21
|
# access this TimeZone object via <tt>Time.zone</tt>:
|
20
22
|
#
|
21
23
|
# # application.rb:
|
@@ -27,7 +29,7 @@ module ActiveSupport
|
|
27
29
|
# Time.zone.name # => "Eastern Time (US & Canada)"
|
28
30
|
# Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00
|
29
31
|
class TimeZone
|
30
|
-
# Keys are Rails TimeZone names, values are TZInfo identifiers.
|
32
|
+
# Keys are \Rails TimeZone names, values are TZInfo identifiers.
|
31
33
|
MAPPING = {
|
32
34
|
"International Date Line West" => "Etc/GMT+12",
|
33
35
|
"Midway Island" => "Pacific/Midway",
|
@@ -159,7 +161,7 @@ module ActiveSupport
|
|
159
161
|
"Yakutsk" => "Asia/Yakutsk",
|
160
162
|
"Darwin" => "Australia/Darwin",
|
161
163
|
"Adelaide" => "Australia/Adelaide",
|
162
|
-
"Canberra" => "Australia/
|
164
|
+
"Canberra" => "Australia/Canberra",
|
163
165
|
"Melbourne" => "Australia/Melbourne",
|
164
166
|
"Sydney" => "Australia/Sydney",
|
165
167
|
"Brisbane" => "Australia/Brisbane",
|
@@ -543,13 +545,13 @@ module ActiveSupport
|
|
543
545
|
tzinfo.local_to_utc(time, dst)
|
544
546
|
end
|
545
547
|
|
546
|
-
# Available so that TimeZone instances respond like
|
548
|
+
# Available so that TimeZone instances respond like +TZInfo::Timezone+
|
547
549
|
# instances.
|
548
550
|
def period_for_utc(time)
|
549
551
|
tzinfo.period_for_utc(time)
|
550
552
|
end
|
551
553
|
|
552
|
-
# Available so that TimeZone instances respond like
|
554
|
+
# Available so that TimeZone instances respond like +TZInfo::Timezone+
|
553
555
|
# instances.
|
554
556
|
def period_for_local(time, dst = true)
|
555
557
|
tzinfo.period_for_local(time, dst) { |periods| periods.last }
|
@@ -20,13 +20,6 @@ module ActiveSupport
|
|
20
20
|
|
21
21
|
CONTENT_KEY = "__content__"
|
22
22
|
|
23
|
-
NODE_TYPE_NAMES = %w{ATTRIBUTE_NODE CDATA_SECTION_NODE COMMENT_NODE DOCUMENT_FRAGMENT_NODE
|
24
|
-
DOCUMENT_NODE DOCUMENT_TYPE_NODE ELEMENT_NODE ENTITY_NODE ENTITY_REFERENCE_NODE NOTATION_NODE
|
25
|
-
PROCESSING_INSTRUCTION_NODE TEXT_NODE}
|
26
|
-
|
27
|
-
node_type_map = {}
|
28
|
-
NODE_TYPE_NAMES.each { |type| node_type_map[Node.send(type)] = type }
|
29
|
-
|
30
23
|
# Parse an XML Document string or IO into a simple hash using Java's jdom.
|
31
24
|
# data::
|
32
25
|
# XML Document string or IO to parse
|
@@ -80,7 +73,7 @@ module ActiveSupport
|
|
80
73
|
if child_nodes.length > 0
|
81
74
|
(0...child_nodes.length).each do |i|
|
82
75
|
child = child_nodes.item(i)
|
83
|
-
merge_element!(hash, child, depth - 1) unless child.node_type == Node
|
76
|
+
merge_element!(hash, child, depth - 1) unless child.node_type == Node::TEXT_NODE
|
84
77
|
end
|
85
78
|
merge_texts!(hash, element) unless empty_content?(element)
|
86
79
|
hash
|
@@ -156,7 +149,7 @@ module ActiveSupport
|
|
156
149
|
child_nodes = element.child_nodes
|
157
150
|
(0...child_nodes.length).each do |i|
|
158
151
|
item = child_nodes.item(i)
|
159
|
-
if item.node_type == Node
|
152
|
+
if item.node_type == Node::TEXT_NODE
|
160
153
|
texts << item.get_data
|
161
154
|
end
|
162
155
|
end
|
@@ -172,7 +165,7 @@ module ActiveSupport
|
|
172
165
|
child_nodes = element.child_nodes
|
173
166
|
(0...child_nodes.length).each do |i|
|
174
167
|
item = child_nodes.item(i)
|
175
|
-
if item.node_type == Node
|
168
|
+
if item.node_type == Node::TEXT_NODE
|
176
169
|
text << item.get_data.strip
|
177
170
|
end
|
178
171
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
begin
|
4
4
|
require "nokogiri"
|
5
5
|
rescue LoadError => e
|
6
|
-
|
6
|
+
warn "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install"
|
7
7
|
raise e
|
8
8
|
end
|
9
9
|
require "active_support/core_ext/object/blank"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
begin
|
4
4
|
require "nokogiri"
|
5
5
|
rescue LoadError => e
|
6
|
-
|
6
|
+
warn "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install"
|
7
7
|
raise e
|
8
8
|
end
|
9
9
|
require "active_support/core_ext/object/blank"
|
@@ -41,7 +41,7 @@ module ActiveSupport
|
|
41
41
|
def require_rexml
|
42
42
|
silence_warnings { require "rexml/document" }
|
43
43
|
rescue LoadError => e
|
44
|
-
|
44
|
+
warn "You don't have rexml installed in your application. Please add it to your Gemfile and run bundle install"
|
45
45
|
raise e
|
46
46
|
end
|
47
47
|
|
@@ -9,10 +9,10 @@ require "active_support/core_ext/string/inflections"
|
|
9
9
|
require "active_support/core_ext/date_time/calculations"
|
10
10
|
|
11
11
|
module ActiveSupport
|
12
|
-
# = XmlMini
|
12
|
+
# = \XmlMini
|
13
13
|
#
|
14
14
|
# To use the much faster libxml parser:
|
15
|
-
# gem 'libxml-ruby'
|
15
|
+
# gem 'libxml-ruby'
|
16
16
|
# XmlMini.backend = 'LibXML'
|
17
17
|
module XmlMini
|
18
18
|
extend self
|
data/lib/active_support.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c)
|
4
|
+
# Copyright (c) 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
|
@@ -26,10 +26,12 @@
|
|
26
26
|
require "securerandom"
|
27
27
|
require "active_support/dependencies/autoload"
|
28
28
|
require "active_support/version"
|
29
|
+
require "active_support/deprecator"
|
29
30
|
require "active_support/logger"
|
30
31
|
require "active_support/lazy_load_hooks"
|
31
32
|
require "active_support/core_ext/date_and_time/compatibility"
|
32
33
|
|
34
|
+
# :include: activesupport/README.rdoc
|
33
35
|
module ActiveSupport
|
34
36
|
extend ActiveSupport::Autoload
|
35
37
|
|
@@ -40,7 +42,6 @@ module ActiveSupport
|
|
40
42
|
autoload :CurrentAttributes
|
41
43
|
autoload :Dependencies
|
42
44
|
autoload :DescendantsTracker
|
43
|
-
autoload :ExecutionContext
|
44
45
|
autoload :ExecutionWrapper
|
45
46
|
autoload :Executor
|
46
47
|
autoload :ErrorReporter
|
@@ -51,7 +52,6 @@ module ActiveSupport
|
|
51
52
|
autoload :IsolatedExecutionState
|
52
53
|
autoload :Notifications
|
53
54
|
autoload :Reloader
|
54
|
-
autoload :PerThreadRegistry
|
55
55
|
autoload :SecureCompareRotator
|
56
56
|
|
57
57
|
eager_autoload do
|
@@ -63,12 +63,15 @@ module ActiveSupport
|
|
63
63
|
autoload :Configurable
|
64
64
|
autoload :Deprecation
|
65
65
|
autoload :Digest
|
66
|
+
autoload :ExecutionContext
|
66
67
|
autoload :Gzip
|
67
68
|
autoload :Inflector
|
68
69
|
autoload :JSON
|
69
70
|
autoload :KeyGenerator
|
70
71
|
autoload :MessageEncryptor
|
72
|
+
autoload :MessageEncryptors
|
71
73
|
autoload :MessageVerifier
|
74
|
+
autoload :MessageVerifiers
|
72
75
|
autoload :Multibyte
|
73
76
|
autoload :NumberHelper
|
74
77
|
autoload :OptionMerger
|
@@ -94,6 +97,7 @@ module ActiveSupport
|
|
94
97
|
cattr_accessor :test_order # :nodoc:
|
95
98
|
cattr_accessor :test_parallelization_threshold, default: 50 # :nodoc:
|
96
99
|
|
100
|
+
@error_reporter = ActiveSupport::ErrorReporter.new
|
97
101
|
singleton_class.attr_accessor :error_reporter # :nodoc:
|
98
102
|
|
99
103
|
def self.cache_format_version
|
@@ -109,6 +113,12 @@ module ActiveSupport
|
|
109
113
|
end
|
110
114
|
|
111
115
|
def self.to_time_preserves_timezone=(value)
|
116
|
+
unless value
|
117
|
+
ActiveSupport.deprecator.warn(
|
118
|
+
"Support for the pre-Ruby 2.4 behavior of to_time has been deprecated and will be removed in Rails 7.2."
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
112
122
|
DateAndTime::Compatibility.preserve_timezone = value
|
113
123
|
end
|
114
124
|
|