activesupport 7.0.8.7 → 7.2.2.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 +143 -459
- 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 +3 -1
- data/lib/active_support/backtrace_cleaner.rb +39 -7
- data/lib/active_support/benchmarkable.rb +1 -0
- data/lib/active_support/broadcast_logger.rb +251 -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 +134 -0
- data/lib/active_support/cache/file_store.rb +49 -17
- data/lib/active_support/cache/mem_cache_store.rb +94 -128
- data/lib/active_support/cache/memory_store.rb +80 -25
- data/lib/active_support/cache/null_store.rb +6 -0
- data/lib/active_support/cache/redis_cache_store.rb +165 -152
- data/lib/active_support/cache/serializer_with_fallback.rb +152 -0
- data/lib/active_support/cache/strategy/local_cache.rb +29 -14
- data/lib/active_support/cache.rb +363 -291
- data/lib/active_support/callbacks.rb +118 -134
- data/lib/active_support/code_generator.rb +15 -10
- 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 +1 -2
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/class/subclasses.rb +17 -34
- data/lib/active_support/core_ext/date/blank.rb +4 -0
- data/lib/active_support/core_ext/date/conversions.rb +1 -2
- 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_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 +2 -2
- data/lib/active_support/core_ext/date_time.rb +0 -1
- data/lib/active_support/core_ext/digest/uuid.rb +7 -10
- data/lib/active_support/core_ext/enumerable.rb +3 -75
- data/lib/active_support/core_ext/erb/util.rb +201 -0
- data/lib/active_support/core_ext/hash/conversions.rb +1 -1
- data/lib/active_support/core_ext/hash/deep_merge.rb +22 -14
- data/lib/active_support/core_ext/hash/keys.rb +4 -4
- data/lib/active_support/core_ext/module/attr_internal.rb +17 -6
- 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/concerning.rb +6 -6
- data/lib/active_support/core_ext/module/delegation.rb +20 -119
- data/lib/active_support/core_ext/module/deprecation.rb +12 -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 +5 -3
- data/lib/active_support/core_ext/numeric.rb +0 -1
- data/lib/active_support/core_ext/object/blank.rb +45 -1
- data/lib/active_support/core_ext/object/deep_dup.rb +16 -0
- data/lib/active_support/core_ext/object/inclusion.rb +13 -5
- data/lib/active_support/core_ext/object/instance_variables.rb +4 -2
- data/lib/active_support/core_ext/object/json.rb +17 -7
- data/lib/active_support/core_ext/object/with.rb +46 -0
- data/lib/active_support/core_ext/object/with_options.rb +4 -4
- data/lib/active_support/core_ext/object.rb +1 -0
- data/lib/active_support/core_ext/pathname/blank.rb +20 -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/overlap.rb +40 -0
- data/lib/active_support/core_ext/range.rb +1 -2
- data/lib/active_support/core_ext/securerandom.rb +1 -5
- data/lib/active_support/core_ext/string/conversions.rb +1 -1
- data/lib/active_support/core_ext/string/filters.rb +21 -15
- data/lib/active_support/core_ext/string/indent.rb +1 -1
- data/lib/active_support/core_ext/string/inflections.rb +16 -5
- data/lib/active_support/core_ext/string/multibyte.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +34 -177
- data/lib/active_support/core_ext/thread/backtrace/location.rb +12 -0
- data/lib/active_support/core_ext/time/calculations.rb +36 -30
- data/lib/active_support/core_ext/time/compatibility.rb +16 -0
- data/lib/active_support/core_ext/time/conversions.rb +1 -3
- 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/core_ext.rb +0 -1
- data/lib/active_support/current_attributes.rb +53 -46
- data/lib/active_support/deep_mergeable.rb +53 -0
- data/lib/active_support/delegation.rb +202 -0
- data/lib/active_support/dependencies/autoload.rb +9 -16
- data/lib/active_support/deprecation/behaviors.rb +65 -42
- data/lib/active_support/deprecation/constant_accessor.rb +47 -25
- data/lib/active_support/deprecation/deprecators.rb +104 -0
- data/lib/active_support/deprecation/disallowed.rb +3 -5
- data/lib/active_support/deprecation/method_wrappers.rb +6 -23
- data/lib/active_support/deprecation/proxy_wrappers.rb +34 -22
- data/lib/active_support/deprecation/reporting.rb +49 -27
- data/lib/active_support/deprecation.rb +39 -9
- data/lib/active_support/deprecator.rb +7 -0
- data/lib/active_support/descendants_tracker.rb +66 -172
- data/lib/active_support/duration/iso8601_parser.rb +2 -2
- data/lib/active_support/duration/iso8601_serializer.rb +1 -4
- data/lib/active_support/duration.rb +13 -7
- data/lib/active_support/encrypted_configuration.rb +30 -9
- data/lib/active_support/encrypted_file.rb +9 -4
- 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 +160 -36
- data/lib/active_support/evented_file_update_checker.rb +0 -1
- data/lib/active_support/execution_wrapper.rb +4 -5
- data/lib/active_support/file_update_checker.rb +5 -3
- data/lib/active_support/fork_tracker.rb +4 -32
- 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 +41 -25
- data/lib/active_support/html_safe_translation.rb +19 -6
- 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 +23 -11
- 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 +74 -34
- data/lib/active_support/logger.rb +22 -60
- data/lib/active_support/logger_thread_safe_level.rb +10 -32
- data/lib/active_support/message_encryptor.rb +197 -53
- data/lib/active_support/message_encryptors.rb +141 -0
- data/lib/active_support/message_pack/cache_serializer.rb +23 -0
- data/lib/active_support/message_pack/extensions.rb +305 -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 +220 -89
- data/lib/active_support/message_verifiers.rb +135 -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 +4 -2
- data/lib/active_support/multibyte/unicode.rb +9 -37
- data/lib/active_support/notifications/fanout.rb +248 -87
- data/lib/active_support/notifications/instrumenter.rb +93 -25
- data/lib/active_support/notifications.rb +29 -28
- data/lib/active_support/number_helper/number_converter.rb +16 -7
- data/lib/active_support/number_helper/number_to_currency_converter.rb +6 -6
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +3 -3
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -0
- data/lib/active_support/number_helper.rb +379 -318
- data/lib/active_support/option_merger.rb +2 -2
- data/lib/active_support/ordered_hash.rb +3 -3
- data/lib/active_support/ordered_options.rb +67 -15
- data/lib/active_support/parameter_filter.rb +84 -69
- data/lib/active_support/proxy_object.rb +8 -3
- data/lib/active_support/railtie.rb +25 -20
- 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 +4 -2
- data/lib/active_support/subscriber.rb +10 -27
- data/lib/active_support/syntax_error_proxy.rb +60 -0
- data/lib/active_support/tagged_logging.rb +64 -25
- data/lib/active_support/test_case.rb +156 -7
- data/lib/active_support/testing/assertions.rb +28 -12
- data/lib/active_support/testing/autorun.rb +0 -2
- data/lib/active_support/testing/constant_stubbing.rb +54 -0
- data/lib/active_support/testing/deprecation.rb +20 -27
- data/lib/active_support/testing/error_reporter_assertions.rb +107 -0
- data/lib/active_support/testing/isolation.rb +21 -9
- data/lib/active_support/testing/method_call_assertions.rb +7 -8
- data/lib/active_support/testing/parallelization/server.rb +3 -0
- data/lib/active_support/testing/parallelize_executor.rb +8 -3
- data/lib/active_support/testing/setup_and_teardown.rb +2 -0
- data/lib/active_support/testing/stream.rb +1 -1
- data/lib/active_support/testing/strict_warnings.rb +43 -0
- data/lib/active_support/testing/tests_without_assertions.rb +19 -0
- data/lib/active_support/testing/time_helpers.rb +38 -16
- data/lib/active_support/time_with_zone.rb +12 -18
- data/lib/active_support/values/time_zone.rb +25 -14
- 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 +12 -3
- data/lib/active_support.rb +15 -3
- metadata +140 -19
- 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/range/overlaps.rb +0 -10
- 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/deprecation/instance_delegator.rb +0 -38
- data/lib/active_support/per_thread_registry.rb +0 -65
- data/lib/active_support/ruby_features.rb +0 -7
@@ -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
|
-
# (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").
|
14
|
-
# * Lazily load
|
15
|
+
# (e.g., "Eastern \Time (US & Canada)" instead of "America/New_York").
|
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",
|
@@ -132,10 +134,10 @@ module ActiveSupport
|
|
132
134
|
"Mumbai" => "Asia/Kolkata",
|
133
135
|
"New Delhi" => "Asia/Kolkata",
|
134
136
|
"Kathmandu" => "Asia/Kathmandu",
|
135
|
-
"Astana" => "Asia/Dhaka",
|
136
137
|
"Dhaka" => "Asia/Dhaka",
|
137
138
|
"Sri Jayawardenepura" => "Asia/Colombo",
|
138
139
|
"Almaty" => "Asia/Almaty",
|
140
|
+
"Astana" => "Asia/Almaty",
|
139
141
|
"Novosibirsk" => "Asia/Novosibirsk",
|
140
142
|
"Rangoon" => "Asia/Rangoon",
|
141
143
|
"Bangkok" => "Asia/Bangkok",
|
@@ -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",
|
@@ -206,7 +208,9 @@ module ActiveSupport
|
|
206
208
|
TZInfo::Timezone.get(MAPPING[name] || name)
|
207
209
|
end
|
208
210
|
|
211
|
+
# :stopdoc:
|
209
212
|
alias_method :create, :new
|
213
|
+
# :startdoc:
|
210
214
|
|
211
215
|
# Returns a TimeZone instance with the given name, or +nil+ if no
|
212
216
|
# such TimeZone instance exists. (This exists to support the use of
|
@@ -294,15 +298,22 @@ module ActiveSupport
|
|
294
298
|
attr_reader :name
|
295
299
|
attr_reader :tzinfo
|
296
300
|
|
301
|
+
##
|
302
|
+
# :singleton-method: create
|
303
|
+
# :call-seq: create(name, utc_offset = nil, tzinfo = nil)
|
304
|
+
#
|
297
305
|
# Create a new TimeZone object with the given name and offset. The
|
298
306
|
# offset is the number of seconds that this time zone is offset from UTC
|
299
307
|
# (GMT). Seconds were chosen as the offset unit because that is the unit
|
300
308
|
# that Ruby uses to represent time zone offsets (see Time#utc_offset).
|
309
|
+
|
310
|
+
# :stopdoc:
|
301
311
|
def initialize(name, utc_offset = nil, tzinfo = nil)
|
302
312
|
@name = name
|
303
313
|
@utc_offset = utc_offset
|
304
314
|
@tzinfo = tzinfo || TimeZone.find_tzinfo(name)
|
305
315
|
end
|
316
|
+
# :startdoc:
|
306
317
|
|
307
318
|
# Returns the offset of this time zone from UTC in seconds.
|
308
319
|
def utc_offset
|
@@ -346,7 +357,7 @@ module ActiveSupport
|
|
346
357
|
"(GMT#{formatted_offset}) #{name}"
|
347
358
|
end
|
348
359
|
|
349
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
360
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
350
361
|
# of +self+ from given values.
|
351
362
|
#
|
352
363
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
@@ -356,7 +367,7 @@ module ActiveSupport
|
|
356
367
|
ActiveSupport::TimeWithZone.new(nil, self, time)
|
357
368
|
end
|
358
369
|
|
359
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
370
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
360
371
|
# of +self+ from number of seconds since the Unix epoch.
|
361
372
|
#
|
362
373
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
@@ -371,7 +382,7 @@ module ActiveSupport
|
|
371
382
|
Time.at(*args).utc.in_time_zone(self)
|
372
383
|
end
|
373
384
|
|
374
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
385
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
375
386
|
# of +self+ from an ISO 8601 string.
|
376
387
|
#
|
377
388
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
@@ -423,7 +434,7 @@ module ActiveSupport
|
|
423
434
|
raise ArgumentError, "invalid date"
|
424
435
|
end
|
425
436
|
|
426
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
437
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
427
438
|
# of +self+ from parsed string.
|
428
439
|
#
|
429
440
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
@@ -445,7 +456,7 @@ module ActiveSupport
|
|
445
456
|
parts_to_time(Date._parse(str, false), now)
|
446
457
|
end
|
447
458
|
|
448
|
-
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
459
|
+
# \Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
449
460
|
# of +self+ from an RFC 3339 string.
|
450
461
|
#
|
451
462
|
# Time.zone = 'Hawaii' # => "Hawaii"
|
@@ -543,13 +554,13 @@ module ActiveSupport
|
|
543
554
|
tzinfo.local_to_utc(time, dst)
|
544
555
|
end
|
545
556
|
|
546
|
-
# Available so that TimeZone instances respond like
|
557
|
+
# Available so that TimeZone instances respond like +TZInfo::Timezone+
|
547
558
|
# instances.
|
548
559
|
def period_for_utc(time)
|
549
560
|
tzinfo.period_for_utc(time)
|
550
561
|
end
|
551
562
|
|
552
|
-
# Available so that TimeZone instances respond like
|
563
|
+
# Available so that TimeZone instances respond like +TZInfo::Timezone+
|
553
564
|
# instances.
|
554
565
|
def period_for_local(time, dst = true)
|
555
566
|
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
|
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
@@ -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,13 @@
|
|
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"
|
31
|
+
require "active_support/broadcast_logger"
|
30
32
|
require "active_support/lazy_load_hooks"
|
31
33
|
require "active_support/core_ext/date_and_time/compatibility"
|
32
34
|
|
35
|
+
# :include: ../README.rdoc
|
33
36
|
module ActiveSupport
|
34
37
|
extend ActiveSupport::Autoload
|
35
38
|
|
@@ -40,7 +43,6 @@ module ActiveSupport
|
|
40
43
|
autoload :CurrentAttributes
|
41
44
|
autoload :Dependencies
|
42
45
|
autoload :DescendantsTracker
|
43
|
-
autoload :ExecutionContext
|
44
46
|
autoload :ExecutionWrapper
|
45
47
|
autoload :Executor
|
46
48
|
autoload :ErrorReporter
|
@@ -51,7 +53,6 @@ module ActiveSupport
|
|
51
53
|
autoload :IsolatedExecutionState
|
52
54
|
autoload :Notifications
|
53
55
|
autoload :Reloader
|
54
|
-
autoload :PerThreadRegistry
|
55
56
|
autoload :SecureCompareRotator
|
56
57
|
|
57
58
|
eager_autoload do
|
@@ -62,13 +63,17 @@ module ActiveSupport
|
|
62
63
|
autoload :Callbacks
|
63
64
|
autoload :Configurable
|
64
65
|
autoload :Deprecation
|
66
|
+
autoload :Delegation
|
65
67
|
autoload :Digest
|
68
|
+
autoload :ExecutionContext
|
66
69
|
autoload :Gzip
|
67
70
|
autoload :Inflector
|
68
71
|
autoload :JSON
|
69
72
|
autoload :KeyGenerator
|
70
73
|
autoload :MessageEncryptor
|
74
|
+
autoload :MessageEncryptors
|
71
75
|
autoload :MessageVerifier
|
76
|
+
autoload :MessageVerifiers
|
72
77
|
autoload :Multibyte
|
73
78
|
autoload :NumberHelper
|
74
79
|
autoload :OptionMerger
|
@@ -94,6 +99,7 @@ module ActiveSupport
|
|
94
99
|
cattr_accessor :test_order # :nodoc:
|
95
100
|
cattr_accessor :test_parallelization_threshold, default: 50 # :nodoc:
|
96
101
|
|
102
|
+
@error_reporter = ActiveSupport::ErrorReporter.new
|
97
103
|
singleton_class.attr_accessor :error_reporter # :nodoc:
|
98
104
|
|
99
105
|
def self.cache_format_version
|
@@ -109,6 +115,12 @@ module ActiveSupport
|
|
109
115
|
end
|
110
116
|
|
111
117
|
def self.to_time_preserves_timezone=(value)
|
118
|
+
unless value
|
119
|
+
ActiveSupport.deprecator.warn(
|
120
|
+
"Support for the pre-Ruby 2.4 behavior of to_time has been deprecated and will be removed in Rails 8.0."
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
112
124
|
DateAndTime::Compatibility.preserve_timezone = value
|
113
125
|
end
|
114
126
|
|