activesupport 6.0.0 → 6.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +381 -349
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -2
- data/lib/active_support.rb +13 -1
- data/lib/active_support/array_inquirer.rb +4 -2
- data/lib/active_support/backtrace_cleaner.rb +3 -4
- data/lib/active_support/benchmarkable.rb +1 -1
- data/lib/active_support/cache.rb +101 -59
- data/lib/active_support/cache/file_store.rb +11 -11
- data/lib/active_support/cache/mem_cache_store.rb +34 -33
- data/lib/active_support/cache/memory_store.rb +52 -31
- data/lib/active_support/cache/null_store.rb +3 -3
- data/lib/active_support/cache/redis_cache_store.rb +38 -33
- data/lib/active_support/cache/strategy/local_cache.rb +41 -26
- data/lib/active_support/callbacks.rb +65 -59
- data/lib/active_support/concern.rb +46 -2
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
- data/lib/active_support/concurrency/share_lock.rb +0 -1
- data/lib/active_support/configurable.rb +3 -3
- data/lib/active_support/configuration_file.rb +46 -0
- data/lib/active_support/core_ext.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +5 -5
- data/lib/active_support/core_ext/benchmark.rb +2 -2
- data/lib/active_support/core_ext/class/attribute.rb +34 -44
- data/lib/active_support/core_ext/class/subclasses.rb +17 -38
- data/lib/active_support/core_ext/date/conversions.rb +2 -1
- data/lib/active_support/core_ext/date_and_time/calculations.rb +13 -0
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +15 -0
- data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
- data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
- data/lib/active_support/core_ext/enumerable.rb +76 -4
- data/lib/active_support/core_ext/hash/conversions.rb +3 -3
- data/lib/active_support/core_ext/hash/deep_transform_values.rb +1 -1
- data/lib/active_support/core_ext/hash/except.rb +1 -1
- data/lib/active_support/core_ext/hash/keys.rb +1 -1
- data/lib/active_support/core_ext/hash/slice.rb +3 -2
- data/lib/active_support/core_ext/load_error.rb +1 -1
- data/lib/active_support/core_ext/marshal.rb +2 -0
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
- data/lib/active_support/core_ext/module/attribute_accessors.rb +23 -29
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +8 -4
- data/lib/active_support/core_ext/module/concerning.rb +8 -2
- data/lib/active_support/core_ext/module/delegation.rb +46 -29
- data/lib/active_support/core_ext/module/introspection.rb +2 -25
- data/lib/active_support/core_ext/name_error.rb +29 -2
- data/lib/active_support/core_ext/numeric/conversions.rb +22 -18
- data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
- data/lib/active_support/core_ext/object/json.rb +13 -2
- data/lib/active_support/core_ext/object/try.rb +4 -2
- data/lib/active_support/core_ext/range/compare_range.rb +15 -3
- data/lib/active_support/core_ext/range/each.rb +0 -1
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +8 -3
- data/lib/active_support/core_ext/regexp.rb +8 -1
- data/lib/active_support/core_ext/string/access.rb +5 -24
- data/lib/active_support/core_ext/string/conversions.rb +1 -0
- data/lib/active_support/core_ext/string/inflections.rb +38 -4
- data/lib/active_support/core_ext/string/inquiry.rb +1 -0
- data/lib/active_support/core_ext/string/multibyte.rb +2 -2
- data/lib/active_support/core_ext/string/output_safety.rb +12 -11
- data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -2
- data/lib/active_support/core_ext/symbol.rb +3 -0
- data/lib/active_support/core_ext/symbol/starts_ends_with.rb +14 -0
- data/lib/active_support/core_ext/time/calculations.rb +27 -3
- data/lib/active_support/core_ext/time/conversions.rb +2 -0
- data/lib/active_support/core_ext/uri.rb +5 -1
- data/lib/active_support/current_attributes.rb +7 -2
- data/lib/active_support/current_attributes/test_helper.rb +13 -0
- data/lib/active_support/dependencies.rb +42 -20
- data/lib/active_support/dependencies/zeitwerk_integration.rb +9 -2
- data/lib/active_support/deprecation.rb +6 -1
- data/lib/active_support/deprecation/behaviors.rb +15 -2
- data/lib/active_support/deprecation/disallowed.rb +56 -0
- data/lib/active_support/deprecation/instance_delegator.rb +0 -1
- data/lib/active_support/deprecation/method_wrappers.rb +13 -6
- data/lib/active_support/deprecation/proxy_wrappers.rb +6 -2
- data/lib/active_support/deprecation/reporting.rb +50 -7
- data/lib/active_support/descendants_tracker.rb +6 -3
- data/lib/active_support/duration.rb +86 -35
- data/lib/active_support/duration/iso8601_parser.rb +0 -1
- data/lib/active_support/duration/iso8601_serializer.rb +15 -10
- data/lib/active_support/encrypted_file.rb +20 -3
- data/lib/active_support/environment_inquirer.rb +20 -0
- data/lib/active_support/evented_file_update_checker.rb +69 -134
- data/lib/active_support/file_update_checker.rb +0 -1
- data/lib/active_support/fork_tracker.rb +62 -0
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/hash_with_indifferent_access.rb +43 -24
- data/lib/active_support/i18n_railtie.rb +15 -16
- data/lib/active_support/inflector/inflections.rb +1 -3
- data/lib/active_support/inflector/methods.rb +36 -33
- data/lib/active_support/inflector/transliterate.rb +4 -4
- data/lib/active_support/json/decoding.rb +4 -5
- data/lib/active_support/json/encoding.rb +5 -1
- data/lib/active_support/key_generator.rb +1 -1
- data/lib/active_support/lazy_load_hooks.rb +0 -1
- data/lib/active_support/locale/en.rb +4 -2
- data/lib/active_support/locale/en.yml +7 -3
- data/lib/active_support/log_subscriber.rb +8 -1
- data/lib/active_support/logger.rb +2 -2
- data/lib/active_support/logger_silence.rb +2 -26
- data/lib/active_support/logger_thread_safe_level.rb +34 -12
- data/lib/active_support/message_encryptor.rb +5 -8
- data/lib/active_support/message_verifier.rb +7 -7
- data/lib/active_support/messages/metadata.rb +11 -2
- data/lib/active_support/messages/rotation_configuration.rb +2 -1
- data/lib/active_support/messages/rotator.rb +10 -9
- data/lib/active_support/multibyte/chars.rb +5 -44
- data/lib/active_support/multibyte/unicode.rb +9 -84
- data/lib/active_support/notifications.rb +32 -5
- data/lib/active_support/notifications/fanout.rb +23 -8
- data/lib/active_support/notifications/instrumenter.rb +7 -16
- data/lib/active_support/number_helper.rb +33 -14
- data/lib/active_support/number_helper/number_converter.rb +5 -6
- data/lib/active_support/number_helper/number_to_currency_converter.rb +2 -7
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_human_converter.rb +1 -2
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -2
- data/lib/active_support/number_helper/number_to_phone_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +3 -4
- data/lib/active_support/number_helper/rounding_helper.rb +12 -28
- data/lib/active_support/option_merger.rb +22 -3
- data/lib/active_support/ordered_hash.rb +1 -1
- data/lib/active_support/ordered_options.rb +13 -3
- data/lib/active_support/parameter_filter.rb +17 -13
- data/lib/active_support/per_thread_registry.rb +1 -1
- data/lib/active_support/rails.rb +1 -4
- data/lib/active_support/railtie.rb +23 -1
- data/lib/active_support/rescuable.rb +4 -4
- data/lib/active_support/secure_compare_rotator.rb +51 -0
- data/lib/active_support/security_utils.rb +19 -12
- data/lib/active_support/string_inquirer.rb +4 -3
- data/lib/active_support/subscriber.rb +12 -7
- data/lib/active_support/tagged_logging.rb +29 -4
- data/lib/active_support/testing/assertions.rb +18 -11
- data/lib/active_support/testing/parallelization.rb +12 -89
- data/lib/active_support/testing/parallelization/server.rb +78 -0
- data/lib/active_support/testing/parallelization/worker.rb +100 -0
- data/lib/active_support/testing/stream.rb +0 -1
- data/lib/active_support/testing/time_helpers.rb +40 -5
- data/lib/active_support/time_with_zone.rb +67 -43
- data/lib/active_support/values/time_zone.rb +20 -10
- data/lib/active_support/xml_mini.rb +0 -1
- data/lib/active_support/xml_mini/jdom.rb +0 -1
- data/lib/active_support/xml_mini/rexml.rb +8 -1
- metadata +39 -38
- data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -5
- data/lib/active_support/core_ext/hash/compact.rb +0 -5
- data/lib/active_support/core_ext/hash/transform_values.rb +0 -5
- data/lib/active_support/core_ext/module/reachable.rb +0 -6
- data/lib/active_support/core_ext/numeric/inquiry.rb +0 -5
- data/lib/active_support/core_ext/range/include_range.rb +0 -9
@@ -30,7 +30,7 @@ module ActiveSupport
|
|
30
30
|
# If set to true, precision will mean the number of significant digits instead
|
31
31
|
# of the number of decimal digits (1234 with precision 2 becomes 1200, 1.23543 becomes 1.2)
|
32
32
|
significant: false,
|
33
|
-
# If set, the zeros after the decimal separator will always be stripped (
|
33
|
+
# If set, the zeros after the decimal separator will always be stripped (e.g.: 1.200 will be 1.2)
|
34
34
|
strip_insignificant_zeros: false
|
35
35
|
},
|
36
36
|
|
@@ -136,7 +136,6 @@ module ActiveSupport
|
|
136
136
|
end
|
137
137
|
|
138
138
|
private
|
139
|
-
|
140
139
|
def options
|
141
140
|
@options ||= format_options.merge(opts)
|
142
141
|
end
|
@@ -162,12 +161,12 @@ module ActiveSupport
|
|
162
161
|
options
|
163
162
|
end
|
164
163
|
|
165
|
-
def translate_number_value_with_default(key, i18n_options
|
166
|
-
I18n.translate(key, { default: default_value(key), scope: :number }.merge!(i18n_options))
|
164
|
+
def translate_number_value_with_default(key, **i18n_options)
|
165
|
+
I18n.translate(key, **{ default: default_value(key), scope: :number }.merge!(i18n_options))
|
167
166
|
end
|
168
167
|
|
169
|
-
def translate_in_locale(key, i18n_options
|
170
|
-
translate_number_value_with_default(key, { locale: options[:locale] }.merge(i18n_options))
|
168
|
+
def translate_in_locale(key, **i18n_options)
|
169
|
+
translate_number_value_with_default(key, **{ locale: options[:locale] }.merge(i18n_options))
|
171
170
|
end
|
172
171
|
|
173
172
|
def default_value(key)
|
@@ -11,9 +11,9 @@ module ActiveSupport
|
|
11
11
|
number = self.number.to_s.strip
|
12
12
|
format = options[:format]
|
13
13
|
|
14
|
-
if number.
|
14
|
+
if number.sub!(/^-/, "") &&
|
15
|
+
(options[:precision] != 0 || number.to_f > 0.5)
|
15
16
|
format = options[:negative_format]
|
16
|
-
number = absolute_value(number)
|
17
17
|
end
|
18
18
|
|
19
19
|
rounded_number = NumberToRoundedConverter.convert(number, options)
|
@@ -21,11 +21,6 @@ module ActiveSupport
|
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
|
-
|
25
|
-
def absolute_value(number)
|
26
|
-
number.respond_to?(:abs) ? number.abs : number.sub(/\A-/, "")
|
27
|
-
end
|
28
|
-
|
29
24
|
def options
|
30
25
|
@options ||= begin
|
31
26
|
defaults = default_format_options.merge(i18n_opts)
|
@@ -16,7 +16,7 @@ module ActiveSupport
|
|
16
16
|
@number = RoundingHelper.new(options).round(number)
|
17
17
|
@number = Float(number)
|
18
18
|
|
19
|
-
#
|
19
|
+
# For backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files.
|
20
20
|
unless options.key?(:strip_insignificant_zeros)
|
21
21
|
options[:strip_insignificant_zeros] = true
|
22
22
|
end
|
@@ -31,7 +31,6 @@ module ActiveSupport
|
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
|
-
|
35
34
|
def format
|
36
35
|
options[:format] || translate_in_locale("human.decimal_units.format")
|
37
36
|
end
|
@@ -13,7 +13,7 @@ module ActiveSupport
|
|
13
13
|
def convert
|
14
14
|
@number = Float(number)
|
15
15
|
|
16
|
-
#
|
16
|
+
# For backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files.
|
17
17
|
unless options.key?(:strip_insignificant_zeros)
|
18
18
|
options[:strip_insignificant_zeros] = true
|
19
19
|
end
|
@@ -28,7 +28,6 @@ module ActiveSupport
|
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
31
|
-
|
32
31
|
def conversion_format
|
33
32
|
translate_number_value_with_default("human.storage_units.format", locale: options[:locale], raise: true)
|
34
33
|
end
|
@@ -20,14 +20,14 @@ module ActiveSupport
|
|
20
20
|
end
|
21
21
|
|
22
22
|
formatted_string =
|
23
|
-
if
|
23
|
+
if rounded_number.nan? || rounded_number.infinite? || rounded_number == rounded_number.to_i
|
24
|
+
"%00.#{precision}f" % rounded_number
|
25
|
+
else
|
24
26
|
s = rounded_number.to_s("F")
|
25
27
|
s << "0" * precision
|
26
28
|
a, b = s.split(".", 2)
|
27
29
|
a << "."
|
28
30
|
a << b[0, precision]
|
29
|
-
else
|
30
|
-
"%00.#{precision}f" % rounded_number
|
31
31
|
end
|
32
32
|
else
|
33
33
|
formatted_string = rounded_number
|
@@ -38,7 +38,6 @@ module ActiveSupport
|
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
41
|
-
|
42
41
|
def strip_insignificant_zeros
|
43
42
|
options[:strip_insignificant_zeros]
|
44
43
|
end
|
@@ -10,57 +10,41 @@ module ActiveSupport
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def round(number)
|
13
|
+
precision = absolute_precision(number)
|
13
14
|
return number unless precision
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
else
|
18
|
-
round_without_significant(number)
|
19
|
-
end
|
15
|
+
|
16
|
+
rounded_number = convert_to_decimal(number).round(precision, options.fetch(:round_mode, :default))
|
17
|
+
rounded_number.zero? ? rounded_number.abs : rounded_number # prevent showing negative zeros
|
20
18
|
end
|
21
19
|
|
22
20
|
def digit_count(number)
|
23
21
|
return 1 if number.zero?
|
24
|
-
(Math.log10(
|
22
|
+
(Math.log10(number.abs) + 1).floor
|
25
23
|
end
|
26
24
|
|
27
25
|
private
|
28
|
-
def round_without_significant(number)
|
29
|
-
number = number.round(precision)
|
30
|
-
number = number.to_i if precision == 0 && number.finite?
|
31
|
-
number = number.abs if number.zero? # prevent showing negative zeros
|
32
|
-
number
|
33
|
-
end
|
34
|
-
|
35
|
-
def round_significant(number)
|
36
|
-
return 0 if number.zero?
|
37
|
-
digits = digit_count(number)
|
38
|
-
multiplier = 10**(digits - precision)
|
39
|
-
(number / BigDecimal(multiplier.to_f.to_s)).round * multiplier
|
40
|
-
end
|
41
|
-
|
42
26
|
def convert_to_decimal(number)
|
43
27
|
case number
|
44
28
|
when Float, String
|
45
29
|
BigDecimal(number.to_s)
|
46
30
|
when Rational
|
47
|
-
BigDecimal(number, digit_count(number.to_i) + precision)
|
31
|
+
BigDecimal(number, digit_count(number.to_i) + options[:precision])
|
48
32
|
else
|
49
33
|
number.to_d
|
50
34
|
end
|
51
35
|
end
|
52
36
|
|
53
|
-
def
|
54
|
-
options[:precision]
|
37
|
+
def absolute_precision(number)
|
38
|
+
if significant && options[:precision] > 0
|
39
|
+
options[:precision] - digit_count(convert_to_decimal(number))
|
40
|
+
else
|
41
|
+
options[:precision]
|
42
|
+
end
|
55
43
|
end
|
56
44
|
|
57
45
|
def significant
|
58
46
|
options[:significant]
|
59
47
|
end
|
60
|
-
|
61
|
-
def absolute_number(number)
|
62
|
-
number.respond_to?(:abs) ? number.abs : number.to_d.abs
|
63
|
-
end
|
64
48
|
end
|
65
49
|
end
|
66
50
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support/core_ext/hash/deep_merge"
|
4
|
+
require "active_support/core_ext/symbol/starts_ends_with"
|
4
5
|
|
5
6
|
module ActiveSupport
|
6
7
|
class OptionMerger #:nodoc:
|
7
8
|
instance_methods.each do |method|
|
8
|
-
undef_method(method)
|
9
|
+
undef_method(method) unless method.start_with?("__", "instance_eval", "class", "object_id")
|
9
10
|
end
|
10
11
|
|
11
12
|
def initialize(context, options)
|
@@ -14,14 +15,32 @@ module ActiveSupport
|
|
14
15
|
|
15
16
|
private
|
16
17
|
def method_missing(method, *arguments, &block)
|
18
|
+
options = nil
|
17
19
|
if arguments.first.is_a?(Proc)
|
18
20
|
proc = arguments.pop
|
19
21
|
arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) }
|
22
|
+
elsif arguments.last.respond_to?(:to_hash)
|
23
|
+
options = @options.deep_merge(arguments.pop)
|
20
24
|
else
|
21
|
-
|
25
|
+
options = @options
|
22
26
|
end
|
23
27
|
|
24
|
-
|
28
|
+
invoke_method(method, arguments, options, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
if RUBY_VERSION >= "2.7"
|
32
|
+
def invoke_method(method, arguments, options, &block)
|
33
|
+
if options
|
34
|
+
@context.__send__(method, *arguments, **options, &block)
|
35
|
+
else
|
36
|
+
@context.__send__(method, *arguments, &block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
else
|
40
|
+
def invoke_method(method, arguments, options, &block)
|
41
|
+
arguments << options.dup if options
|
42
|
+
@context.__send__(method, *arguments, &block)
|
43
|
+
end
|
25
44
|
end
|
26
45
|
end
|
27
46
|
end
|
@@ -16,7 +16,7 @@ module ActiveSupport
|
|
16
16
|
# oh.keys # => [:a, :b], this order is guaranteed
|
17
17
|
#
|
18
18
|
# Also, maps the +omap+ feature for YAML files
|
19
|
-
# (See
|
19
|
+
# (See https://yaml.org/type/omap.html) to support ordered items
|
20
20
|
# when loading from yaml.
|
21
21
|
#
|
22
22
|
# <tt>ActiveSupport::OrderedHash</tt> is namespaced to prevent conflicts
|
@@ -3,7 +3,9 @@
|
|
3
3
|
require "active_support/core_ext/object/blank"
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
|
-
#
|
6
|
+
# +OrderedOptions+ inherits from +Hash+ and provides dynamic accessor methods.
|
7
|
+
#
|
8
|
+
# With a +Hash+, key-value pairs are typically managed like this:
|
7
9
|
#
|
8
10
|
# h = {}
|
9
11
|
# h[:boy] = 'John'
|
@@ -12,7 +14,7 @@ module ActiveSupport
|
|
12
14
|
# h[:girl] # => 'Mary'
|
13
15
|
# h[:dog] # => nil
|
14
16
|
#
|
15
|
-
# Using +OrderedOptions+, the above code
|
17
|
+
# Using +OrderedOptions+, the above code can be written as:
|
16
18
|
#
|
17
19
|
# h = ActiveSupport::OrderedOptions.new
|
18
20
|
# h.boy = 'John'
|
@@ -39,7 +41,7 @@ module ActiveSupport
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def method_missing(name, *args)
|
42
|
-
name_string = name.to_s
|
44
|
+
name_string = +name.to_s
|
43
45
|
if name_string.chomp!("=")
|
44
46
|
self[name_string] = args.first
|
45
47
|
else
|
@@ -56,6 +58,14 @@ module ActiveSupport
|
|
56
58
|
def respond_to_missing?(name, include_private)
|
57
59
|
true
|
58
60
|
end
|
61
|
+
|
62
|
+
def extractable_options?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
def inspect
|
67
|
+
"#<#{self.class.name} #{super}>"
|
68
|
+
end
|
59
69
|
end
|
60
70
|
|
61
71
|
# +InheritableOptions+ provides a constructor to build an +OrderedOptions+
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support/core_ext/object/duplicable"
|
4
|
-
require "active_support/core_ext/array/extract"
|
5
4
|
|
6
5
|
module ActiveSupport
|
7
6
|
# +ParameterFilter+ allows you to specify keys for sensitive data from
|
@@ -22,7 +21,7 @@ module ActiveSupport
|
|
22
21
|
# change { file: { code: "xxxx"} }
|
23
22
|
#
|
24
23
|
# ActiveSupport::ParameterFilter.new([-> (k, v) do
|
25
|
-
# v.reverse! if
|
24
|
+
# v.reverse! if /secret/i.match?(k)
|
26
25
|
# end])
|
27
26
|
# => reverses the value to all keys matching /secret/i
|
28
27
|
class ParameterFilter
|
@@ -34,7 +33,7 @@ module ActiveSupport
|
|
34
33
|
#
|
35
34
|
# ==== Options
|
36
35
|
#
|
37
|
-
# * <tt>:mask</tt> - A replaced object when filtered. Defaults to
|
36
|
+
# * <tt>:mask</tt> - A replaced object when filtered. Defaults to <tt>"[FILTERED]"</tt>.
|
38
37
|
def initialize(filters = [], mask: FILTERED)
|
39
38
|
@filters = filters
|
40
39
|
@mask = mask
|
@@ -51,7 +50,6 @@ module ActiveSupport
|
|
51
50
|
end
|
52
51
|
|
53
52
|
private
|
54
|
-
|
55
53
|
def compiled_filter
|
56
54
|
@compiled_filter ||= CompiledFilter.compile(@filters, mask: @mask)
|
57
55
|
end
|
@@ -60,24 +58,30 @@ module ActiveSupport
|
|
60
58
|
def self.compile(filters, mask:)
|
61
59
|
return lambda { |params| params.dup } if filters.empty?
|
62
60
|
|
63
|
-
strings, regexps, blocks = [], [], []
|
61
|
+
strings, regexps, blocks, deep_regexps, deep_strings = [], [], [], nil, nil
|
64
62
|
|
65
63
|
filters.each do |item|
|
66
64
|
case item
|
67
65
|
when Proc
|
68
66
|
blocks << item
|
69
67
|
when Regexp
|
70
|
-
|
68
|
+
if item.to_s.include?("\\.")
|
69
|
+
(deep_regexps ||= []) << item
|
70
|
+
else
|
71
|
+
regexps << item
|
72
|
+
end
|
71
73
|
else
|
72
|
-
|
74
|
+
s = Regexp.escape(item.to_s)
|
75
|
+
if s.include?("\\.")
|
76
|
+
(deep_strings ||= []) << s
|
77
|
+
else
|
78
|
+
strings << s
|
79
|
+
end
|
73
80
|
end
|
74
81
|
end
|
75
82
|
|
76
|
-
deep_regexps = regexps.extract! { |r| r.to_s.include?("\\.") }
|
77
|
-
deep_strings = strings.extract! { |s| s.include?("\\.") }
|
78
|
-
|
79
83
|
regexps << Regexp.new(strings.join("|"), true) unless strings.empty?
|
80
|
-
deep_regexps << Regexp.new(deep_strings.join("|"), true)
|
84
|
+
(deep_regexps ||= []) << Regexp.new(deep_strings.join("|"), true) if deep_strings&.any?
|
81
85
|
|
82
86
|
new regexps, deep_regexps, blocks, mask: mask
|
83
87
|
end
|
@@ -86,7 +90,7 @@ module ActiveSupport
|
|
86
90
|
|
87
91
|
def initialize(regexps, deep_regexps, blocks, mask:)
|
88
92
|
@regexps = regexps
|
89
|
-
@deep_regexps = deep_regexps
|
93
|
+
@deep_regexps = deep_regexps&.any? ? deep_regexps : nil
|
90
94
|
@blocks = blocks
|
91
95
|
@mask = mask
|
92
96
|
end
|
@@ -103,7 +107,7 @@ module ActiveSupport
|
|
103
107
|
|
104
108
|
def value_for_key(key, value, parents = [], original_params = nil)
|
105
109
|
parents.push(key) if deep_regexps
|
106
|
-
if regexps.any? { |r| r.match?(key) }
|
110
|
+
if regexps.any? { |r| r.match?(key.to_s) }
|
107
111
|
value = @mask
|
108
112
|
elsif deep_regexps && (joined = parents.join(".")) && deep_regexps.any? { |r| r.match?(joined) }
|
109
113
|
value = @mask
|
@@ -40,7 +40,7 @@ module ActiveSupport
|
|
40
40
|
# If the class has an initializer, it must accept no arguments.
|
41
41
|
module PerThreadRegistry
|
42
42
|
def self.extended(object)
|
43
|
-
object.instance_variable_set
|
43
|
+
object.instance_variable_set :@per_thread_registry_key, object.name.freeze
|
44
44
|
end
|
45
45
|
|
46
46
|
def instance
|
data/lib/active_support/rails.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# This is private interface.
|
3
|
+
# This is a private interface.
|
4
4
|
#
|
5
5
|
# Rails components cherry pick from Active Support as needed, but there are a
|
6
6
|
# few features that are used for sure in some way or another and it is not worth
|
@@ -13,9 +13,6 @@
|
|
13
13
|
# Defines Object#blank? and Object#present?.
|
14
14
|
require "active_support/core_ext/object/blank"
|
15
15
|
|
16
|
-
# Rails own autoload, eager_load, etc.
|
17
|
-
require "active_support/dependencies/autoload"
|
18
|
-
|
19
16
|
# Support for ClassMethods and the included macro.
|
20
17
|
require "active_support/concern"
|
21
18
|
|
@@ -22,12 +22,25 @@ module ActiveSupport
|
|
22
22
|
app.reloader.before_class_unload { ActiveSupport::CurrentAttributes.clear_all }
|
23
23
|
app.executor.to_run { ActiveSupport::CurrentAttributes.reset_all }
|
24
24
|
app.executor.to_complete { ActiveSupport::CurrentAttributes.reset_all }
|
25
|
+
|
26
|
+
ActiveSupport.on_load(:active_support_test_case) do
|
27
|
+
require "active_support/current_attributes/test_helper"
|
28
|
+
include ActiveSupport::CurrentAttributes::TestHelper
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
initializer "active_support.deprecation_behavior" do |app|
|
28
33
|
if deprecation = app.config.active_support.deprecation
|
29
34
|
ActiveSupport::Deprecation.behavior = deprecation
|
30
35
|
end
|
36
|
+
|
37
|
+
if disallowed_deprecation = app.config.active_support.disallowed_deprecation
|
38
|
+
ActiveSupport::Deprecation.disallowed_behavior = disallowed_deprecation
|
39
|
+
end
|
40
|
+
|
41
|
+
if disallowed_warnings = app.config.active_support.disallowed_deprecation_warnings
|
42
|
+
ActiveSupport::Deprecation.disallowed_warnings = disallowed_warnings
|
43
|
+
end
|
31
44
|
end
|
32
45
|
|
33
46
|
# Sets the default value for Time.zone
|
@@ -65,15 +78,24 @@ module ActiveSupport
|
|
65
78
|
initializer "active_support.set_configs" do |app|
|
66
79
|
app.config.active_support.each do |k, v|
|
67
80
|
k = "#{k}="
|
68
|
-
ActiveSupport.
|
81
|
+
ActiveSupport.public_send(k, v) if ActiveSupport.respond_to? k
|
69
82
|
end
|
70
83
|
end
|
71
84
|
|
72
85
|
initializer "active_support.set_hash_digest_class" do |app|
|
73
86
|
config.after_initialize do
|
74
87
|
if app.config.active_support.use_sha1_digests
|
88
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
89
|
+
config.active_support.use_sha1_digests is deprecated and will
|
90
|
+
be removed from Rails 6.2. Use
|
91
|
+
config.active_support.hash_digest_class = ::Digest::SHA1 instead.
|
92
|
+
MSG
|
75
93
|
ActiveSupport::Digest.hash_digest_class = ::Digest::SHA1
|
76
94
|
end
|
95
|
+
|
96
|
+
if klass = app.config.active_support.hash_digest_class
|
97
|
+
ActiveSupport::Digest.hash_digest_class = klass
|
98
|
+
end
|
77
99
|
end
|
78
100
|
end
|
79
101
|
end
|