activesupport 6.1.4.1 → 7.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +151 -526
  3. data/MIT-LICENSE +1 -1
  4. data/lib/active_support/actionable_error.rb +1 -1
  5. data/lib/active_support/array_inquirer.rb +0 -2
  6. data/lib/active_support/benchmarkable.rb +2 -2
  7. data/lib/active_support/cache/file_store.rb +15 -9
  8. data/lib/active_support/cache/mem_cache_store.rb +119 -28
  9. data/lib/active_support/cache/memory_store.rb +21 -13
  10. data/lib/active_support/cache/null_store.rb +10 -2
  11. data/lib/active_support/cache/redis_cache_store.rb +39 -59
  12. data/lib/active_support/cache/strategy/local_cache.rb +29 -49
  13. data/lib/active_support/cache.rb +189 -45
  14. data/lib/active_support/callbacks.rb +35 -31
  15. data/lib/active_support/concern.rb +5 -5
  16. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +2 -4
  17. data/lib/active_support/concurrency/share_lock.rb +2 -2
  18. data/lib/active_support/configurable.rb +6 -3
  19. data/lib/active_support/configuration_file.rb +1 -1
  20. data/lib/active_support/core_ext/array/access.rb +1 -5
  21. data/lib/active_support/core_ext/array/conversions.rb +6 -6
  22. data/lib/active_support/core_ext/array/grouping.rb +6 -6
  23. data/lib/active_support/core_ext/big_decimal/conversions.rb +1 -1
  24. data/lib/active_support/core_ext/date/blank.rb +1 -1
  25. data/lib/active_support/core_ext/date/calculations.rb +2 -2
  26. data/lib/active_support/core_ext/date_time/blank.rb +1 -1
  27. data/lib/active_support/core_ext/digest/uuid.rb +13 -12
  28. data/lib/active_support/core_ext/enumerable.rb +64 -12
  29. data/lib/active_support/core_ext/file/atomic.rb +1 -1
  30. data/lib/active_support/core_ext/hash/keys.rb +1 -1
  31. data/lib/active_support/core_ext/kernel/reporting.rb +4 -4
  32. data/lib/active_support/core_ext/module/delegation.rb +2 -8
  33. data/lib/active_support/core_ext/name_error.rb +2 -8
  34. data/lib/active_support/core_ext/numeric/conversions.rb +2 -2
  35. data/lib/active_support/core_ext/object/blank.rb +2 -2
  36. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  37. data/lib/active_support/core_ext/object/duplicable.rb +11 -0
  38. data/lib/active_support/core_ext/object/json.rb +29 -24
  39. data/lib/active_support/core_ext/object/to_query.rb +2 -2
  40. data/lib/active_support/core_ext/object/try.rb +20 -20
  41. data/lib/active_support/core_ext/range/compare_range.rb +0 -25
  42. data/lib/active_support/core_ext/range/each.rb +1 -1
  43. data/lib/active_support/core_ext/range/include_time_with_zone.rb +1 -1
  44. data/lib/active_support/core_ext/string/filters.rb +1 -1
  45. data/lib/active_support/core_ext/string/inflections.rb +1 -1
  46. data/lib/active_support/core_ext/string/output_safety.rb +60 -36
  47. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +0 -8
  48. data/lib/active_support/core_ext/time/calculations.rb +6 -5
  49. data/lib/active_support/core_ext/time/zones.rb +2 -17
  50. data/lib/active_support/core_ext/uri.rb +1 -15
  51. data/lib/active_support/current_attributes.rb +17 -1
  52. data/lib/active_support/dependencies/interlock.rb +10 -18
  53. data/lib/active_support/dependencies/require_dependency.rb +28 -0
  54. data/lib/active_support/dependencies.rb +58 -788
  55. data/lib/active_support/deprecation/behaviors.rb +4 -1
  56. data/lib/active_support/deprecation/method_wrappers.rb +3 -3
  57. data/lib/active_support/deprecation/proxy_wrappers.rb +1 -1
  58. data/lib/active_support/deprecation.rb +1 -1
  59. data/lib/active_support/descendants_tracker.rb +12 -9
  60. data/lib/active_support/digest.rb +5 -3
  61. data/lib/active_support/duration/iso8601_parser.rb +3 -3
  62. data/lib/active_support/duration/iso8601_serializer.rb +9 -1
  63. data/lib/active_support/duration.rb +77 -48
  64. data/lib/active_support/encrypted_configuration.rb +11 -1
  65. data/lib/active_support/encrypted_file.rb +1 -1
  66. data/lib/active_support/environment_inquirer.rb +1 -1
  67. data/lib/active_support/evented_file_update_checker.rb +1 -1
  68. data/lib/active_support/fork_tracker.rb +2 -4
  69. data/lib/active_support/gem_version.rb +4 -4
  70. data/lib/active_support/hash_with_indifferent_access.rb +3 -1
  71. data/lib/active_support/i18n.rb +1 -0
  72. data/lib/active_support/inflector/inflections.rb +11 -4
  73. data/lib/active_support/inflector/methods.rb +23 -47
  74. data/lib/active_support/json/encoding.rb +3 -3
  75. data/lib/active_support/key_generator.rb +18 -1
  76. data/lib/active_support/locale/en.yml +1 -1
  77. data/lib/active_support/log_subscriber.rb +13 -3
  78. data/lib/active_support/logger_thread_safe_level.rb +5 -13
  79. data/lib/active_support/message_encryptor.rb +3 -3
  80. data/lib/active_support/message_verifier.rb +4 -4
  81. data/lib/active_support/messages/metadata.rb +2 -2
  82. data/lib/active_support/multibyte/chars.rb +10 -11
  83. data/lib/active_support/multibyte/unicode.rb +2 -2
  84. data/lib/active_support/multibyte.rb +1 -1
  85. data/lib/active_support/notifications/fanout.rb +31 -11
  86. data/lib/active_support/notifications/instrumenter.rb +17 -0
  87. data/lib/active_support/notifications.rb +10 -0
  88. data/lib/active_support/number_helper/number_converter.rb +1 -3
  89. data/lib/active_support/number_helper/number_to_currency_converter.rb +11 -6
  90. data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -1
  91. data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -1
  92. data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -1
  93. data/lib/active_support/number_helper/rounding_helper.rb +1 -5
  94. data/lib/active_support/number_helper.rb +0 -2
  95. data/lib/active_support/option_merger.rb +4 -16
  96. data/lib/active_support/ordered_hash.rb +1 -1
  97. data/lib/active_support/parameter_filter.rb +5 -0
  98. data/lib/active_support/per_thread_registry.rb +1 -0
  99. data/lib/active_support/railtie.rb +34 -11
  100. data/lib/active_support/rescuable.rb +2 -2
  101. data/lib/active_support/secure_compare_rotator.rb +1 -1
  102. data/lib/active_support/string_inquirer.rb +0 -2
  103. data/lib/active_support/subscriber.rb +5 -0
  104. data/lib/active_support/tagged_logging.rb +1 -1
  105. data/lib/active_support/test_case.rb +9 -21
  106. data/lib/active_support/testing/assertions.rb +35 -5
  107. data/lib/active_support/testing/deprecation.rb +1 -1
  108. data/lib/active_support/testing/isolation.rb +1 -1
  109. data/lib/active_support/testing/method_call_assertions.rb +5 -5
  110. data/lib/active_support/testing/parallelization/server.rb +4 -0
  111. data/lib/active_support/testing/parallelization/worker.rb +3 -0
  112. data/lib/active_support/testing/parallelization.rb +4 -0
  113. data/lib/active_support/testing/parallelize_executor.rb +76 -0
  114. data/lib/active_support/testing/stream.rb +3 -5
  115. data/lib/active_support/testing/tagged_logging.rb +1 -1
  116. data/lib/active_support/testing/time_helpers.rb +13 -2
  117. data/lib/active_support/time_with_zone.rb +19 -6
  118. data/lib/active_support/values/time_zone.rb +25 -9
  119. data/lib/active_support/xml_mini/jdom.rb +1 -1
  120. data/lib/active_support/xml_mini/libxml.rb +5 -5
  121. data/lib/active_support/xml_mini/libxmlsax.rb +1 -1
  122. data/lib/active_support/xml_mini/nokogiri.rb +4 -4
  123. data/lib/active_support/xml_mini/nokogirisax.rb +1 -1
  124. data/lib/active_support/xml_mini/rexml.rb +1 -1
  125. data/lib/active_support/xml_mini.rb +2 -1
  126. data/lib/active_support.rb +14 -1
  127. metadata +14 -28
  128. data/lib/active_support/core_ext/marshal.rb +0 -26
  129. data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -117
@@ -3,8 +3,8 @@
3
3
  require "time"
4
4
 
5
5
  module ActiveSupport
6
- module Messages #:nodoc:
7
- class Metadata #:nodoc:
6
+ module Messages # :nodoc:
7
+ class Metadata # :nodoc:
8
8
  def initialize(message, expires_at = nil, purpose = nil)
9
9
  @message, @purpose = message, purpose
10
10
  @expires_at = expires_at.is_a?(String) ? parse_expires_at(expires_at) : expires_at
@@ -3,11 +3,10 @@
3
3
  require "active_support/json"
4
4
  require "active_support/core_ext/string/access"
5
5
  require "active_support/core_ext/string/behavior"
6
- require "active_support/core_ext/symbol/starts_ends_with"
7
6
  require "active_support/core_ext/module/delegation"
8
7
 
9
- module ActiveSupport #:nodoc:
10
- module Multibyte #:nodoc:
8
+ module ActiveSupport # :nodoc:
9
+ module Multibyte # :nodoc:
11
10
  # Chars enables you to work transparently with UTF-8 encoding in the Ruby
12
11
  # String class without having extensive knowledge about the encoding. A
13
12
  # Chars object accepts a string upon initialization and proxies String
@@ -103,7 +102,7 @@ module ActiveSupport #:nodoc:
103
102
  #
104
103
  # 'Café'.mb_chars.reverse.to_s # => 'éfaC'
105
104
  def reverse
106
- chars(@wrapped_string.scan(/\X/).reverse.join)
105
+ chars(@wrapped_string.grapheme_clusters.reverse.join)
107
106
  end
108
107
 
109
108
  # Limits the byte size of the string to a number of bytes without breaking
@@ -126,16 +125,16 @@ module ActiveSupport #:nodoc:
126
125
 
127
126
  # Performs canonical decomposition on all the characters.
128
127
  #
129
- # 'é'.length # => 2
130
- # 'é'.mb_chars.decompose.to_s.length # => 3
128
+ # 'é'.length # => 1
129
+ # 'é'.mb_chars.decompose.to_s.length # => 2
131
130
  def decompose
132
131
  chars(Unicode.decompose(:canonical, @wrapped_string.codepoints.to_a).pack("U*"))
133
132
  end
134
133
 
135
134
  # Performs composition on all the characters.
136
135
  #
137
- # 'é'.length # => 3
138
- # 'é'.mb_chars.compose.to_s.length # => 2
136
+ # 'é'.length # => 1
137
+ # 'é'.mb_chars.compose.to_s.length # => 1
139
138
  def compose
140
139
  chars(Unicode.compose(@wrapped_string.codepoints.to_a).pack("U*"))
141
140
  end
@@ -143,9 +142,9 @@ module ActiveSupport #:nodoc:
143
142
  # Returns the number of grapheme clusters in the string.
144
143
  #
145
144
  # 'क्षि'.mb_chars.length # => 4
146
- # 'क्षि'.mb_chars.grapheme_length # => 3
145
+ # 'क्षि'.mb_chars.grapheme_length # => 2
147
146
  def grapheme_length
148
- @wrapped_string.scan(/\X/).length
147
+ @wrapped_string.grapheme_clusters.length
149
148
  end
150
149
 
151
150
  # Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent
@@ -157,7 +156,7 @@ module ActiveSupport #:nodoc:
157
156
  chars(Unicode.tidy_bytes(@wrapped_string, force))
158
157
  end
159
158
 
160
- def as_json(options = nil) #:nodoc:
159
+ def as_json(options = nil) # :nodoc:
161
160
  to_s.as_json(options)
162
161
  end
163
162
 
@@ -10,13 +10,13 @@ module ActiveSupport
10
10
 
11
11
  def default_normalization_form
12
12
  ActiveSupport::Deprecation.warn(
13
- "ActiveSupport::Multibyte::Unicode.default_normalization_form is deprecated and will be removed in Rails 6.2."
13
+ "ActiveSupport::Multibyte::Unicode.default_normalization_form is deprecated and will be removed in Rails 7.0."
14
14
  )
15
15
  end
16
16
 
17
17
  def default_normalization_form=(_)
18
18
  ActiveSupport::Deprecation.warn(
19
- "ActiveSupport::Multibyte::Unicode.default_normalization_form= is deprecated and will be removed in Rails 6.2."
19
+ "ActiveSupport::Multibyte::Unicode.default_normalization_form= is deprecated and will be removed in Rails 7.0."
20
20
  )
21
21
  end
22
22
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ActiveSupport #:nodoc:
3
+ module ActiveSupport # :nodoc:
4
4
  module Multibyte
5
5
  autoload :Chars, "active_support/multibyte/chars"
6
6
  autoload :Unicode, "active_support/multibyte/unicode"
@@ -24,12 +24,15 @@ module ActiveSupport
24
24
  def subscribe(pattern = nil, callable = nil, monotonic: false, &block)
25
25
  subscriber = Subscribers.new(pattern, callable || block, monotonic)
26
26
  synchronize do
27
- if String === pattern
27
+ case pattern
28
+ when String
28
29
  @string_subscribers[pattern] << subscriber
29
30
  @listeners_for.delete(pattern)
30
- else
31
+ when NilClass, Regexp
31
32
  @other_subscribers << subscriber
32
33
  @listeners_for.clear
34
+ else
35
+ raise ArgumentError, "pattern must be specified as a String, Regexp or empty"
33
36
  end
34
37
  end
35
38
  subscriber
@@ -67,6 +70,10 @@ module ActiveSupport
67
70
  listeners_for(name).each { |s| s.publish(name, *args) }
68
71
  end
69
72
 
73
+ def publish_event(event)
74
+ listeners_for(event.name).each { |s| s.publish_event(event) }
75
+ end
76
+
70
77
  def listeners_for(name)
71
78
  # this is correctly done double-checked locking (Concurrent::Map's lookups have volatile semantics)
72
79
  @listeners_for[name] || synchronize do
@@ -91,13 +98,13 @@ module ActiveSupport
91
98
  if listener.respond_to?(:start) && listener.respond_to?(:finish)
92
99
  subscriber_class = Evented
93
100
  else
94
- # Doing all this to detect a block like `proc { |x| }` vs
95
- # `proc { |*x| }` or `proc { |**x| }`
96
- if listener.respond_to?(:parameters)
97
- params = listener.parameters
98
- if params.length == 1 && params.first.first == :opt
99
- subscriber_class = EventObject
100
- end
101
+ # Doing this to detect a single argument block or callable
102
+ # like `proc { |x| }` vs `proc { |*x| }`, `proc { |**x| }`,
103
+ # or `proc { |x, **y| }`
104
+ procish = listener.respond_to?(:parameters) ? listener : listener.method(:call)
105
+
106
+ if procish.arity == 1 && procish.parameters.length == 1
107
+ subscriber_class = EventObject
101
108
  end
102
109
  end
103
110
 
@@ -112,7 +119,7 @@ module ActiveSupport
112
119
  end
113
120
  end
114
121
 
115
- class Matcher #:nodoc:
122
+ class Matcher # :nodoc:
116
123
  attr_reader :pattern, :exclusions
117
124
 
118
125
  def self.wrap(pattern)
@@ -134,13 +141,14 @@ module ActiveSupport
134
141
  end
135
142
  end
136
143
 
137
- class Evented #:nodoc:
144
+ class Evented # :nodoc:
138
145
  attr_reader :pattern
139
146
 
140
147
  def initialize(pattern, delegate)
141
148
  @pattern = Matcher.wrap(pattern)
142
149
  @delegate = delegate
143
150
  @can_publish = delegate.respond_to?(:publish)
151
+ @can_publish_event = delegate.respond_to?(:publish_event)
144
152
  end
145
153
 
146
154
  def publish(name, *args)
@@ -149,6 +157,14 @@ module ActiveSupport
149
157
  end
150
158
  end
151
159
 
160
+ def publish_event(event)
161
+ if @can_publish_event
162
+ @delegate.publish_event event
163
+ else
164
+ publish(event.name, event.time, event.end, event.transaction_id, event.payload)
165
+ end
166
+ end
167
+
152
168
  def start(name, id, payload)
153
169
  @delegate.start name, id, payload
154
170
  end
@@ -220,6 +236,10 @@ module ActiveSupport
220
236
  @delegate.call event
221
237
  end
222
238
 
239
+ def publish_event(event)
240
+ @delegate.call event
241
+ end
242
+
223
243
  private
224
244
  def build_event(name, id, payload)
225
245
  ActiveSupport::Notifications::Event.new name, nil, nil, id, payload
@@ -31,6 +31,10 @@ module ActiveSupport
31
31
  end
32
32
  end
33
33
 
34
+ def new_event(name, payload = {}) # :nodoc:
35
+ Event.new(name, nil, nil, @id, payload)
36
+ end
37
+
34
38
  # Send a start notification with +name+ and +payload+.
35
39
  def start(name, payload)
36
40
  @notifier.start name, @id, payload
@@ -68,6 +72,19 @@ module ActiveSupport
68
72
  @allocation_count_finish = 0
69
73
  end
70
74
 
75
+ def record
76
+ start!
77
+ begin
78
+ yield payload if block_given?
79
+ rescue Exception => e
80
+ payload[:exception] = [e.class.name, e.message]
81
+ payload[:exception_object] = e
82
+ raise e
83
+ ensure
84
+ finish!
85
+ end
86
+ end
87
+
71
88
  # Record information at the time this event starts
72
89
  def start!
73
90
  @time = now
@@ -198,6 +198,10 @@ module ActiveSupport
198
198
  notifier.publish(name, *args)
199
199
  end
200
200
 
201
+ def publish_event(event) # :nodoc:
202
+ notifier.publish_event(event)
203
+ end
204
+
201
205
  def instrument(name, payload = {})
202
206
  if notifier.listening?(name)
203
207
  instrumenter.instrument(name, payload) { yield payload if block_given? }
@@ -231,6 +235,12 @@ module ActiveSupport
231
235
  # ActiveSupport::Notifications.subscribe(/render/) do |event|
232
236
  # @event = event
233
237
  # end
238
+ #
239
+ # Raises an error if invalid event name type is passed:
240
+ #
241
+ # ActiveSupport::Notifications.subscribe(:render) {|*args| ...}
242
+ # #=> ArgumentError (pattern must be specified as a String, Regexp or empty)
243
+ #
234
244
  def subscribe(pattern = nil, callback = nil, &block)
235
245
  notifier.subscribe(pattern, callback, monotonic: false, &block)
236
246
  end
@@ -174,9 +174,7 @@ module ActiveSupport
174
174
  end
175
175
 
176
176
  def valid_float?
177
- Float(number)
178
- rescue ArgumentError, TypeError
179
- false
177
+ Float(number, exception: false)
180
178
  end
181
179
  end
182
180
  end
@@ -8,16 +8,21 @@ module ActiveSupport
8
8
  self.namespace = :currency
9
9
 
10
10
  def convert
11
- number = self.number.to_s.strip
12
11
  format = options[:format]
13
12
 
14
- if number.sub!(/^-/, "") &&
15
- (options[:precision] != 0 || number.to_f > 0.5)
16
- format = options[:negative_format]
13
+ number_f = valid_float?
14
+ if number_f
15
+ if number_f.negative?
16
+ number_f = number_f.abs
17
+ format = options[:negative_format] if (number_f * 10**options[:precision]) >= 0.5
18
+ end
19
+ number_s = NumberToRoundedConverter.convert(number_f, options)
20
+ else
21
+ number_s = number.to_s.strip
22
+ format = options[:negative_format] if number_s.sub!(/^-/, "")
17
23
  end
18
24
 
19
- rounded_number = NumberToRoundedConverter.convert(number, options)
20
- format.gsub("%n", rounded_number).gsub("%u", options[:unit])
25
+ format.gsub("%n", number_s).gsub("%u", options[:unit])
21
26
  end
22
27
 
23
28
  private
@@ -4,7 +4,7 @@ require "active_support/number_helper/number_converter"
4
4
 
5
5
  module ActiveSupport
6
6
  module NumberHelper
7
- class NumberToDelimitedConverter < NumberConverter #:nodoc:
7
+ class NumberToDelimitedConverter < NumberConverter # :nodoc:
8
8
  self.validate_float = true
9
9
 
10
10
  DEFAULT_DELIMITER_REGEX = /(\d)(?=(\d\d\d)+(?!\d))/
@@ -4,7 +4,7 @@ require "active_support/number_helper/number_converter"
4
4
 
5
5
  module ActiveSupport
6
6
  module NumberHelper
7
- class NumberToHumanSizeConverter < NumberConverter #:nodoc:
7
+ class NumberToHumanSizeConverter < NumberConverter # :nodoc:
8
8
  STORAGE_UNITS = [:byte, :kb, :mb, :gb, :tb, :pb, :eb]
9
9
 
10
10
  self.namespace = :human
@@ -4,7 +4,7 @@ require "active_support/number_helper/number_converter"
4
4
 
5
5
  module ActiveSupport
6
6
  module NumberHelper
7
- class NumberToPhoneConverter < NumberConverter #:nodoc:
7
+ class NumberToPhoneConverter < NumberConverter # :nodoc:
8
8
  def convert
9
9
  str = country_code(opts[:country_code]).dup
10
10
  str << convert_to_phone_number(number.to_s.strip)
@@ -35,16 +35,12 @@ module ActiveSupport
35
35
  end
36
36
 
37
37
  def absolute_precision(number)
38
- if significant && options[:precision] > 0
38
+ if options[:significant] && options[:precision] > 0
39
39
  options[:precision] - digit_count(convert_to_decimal(number))
40
40
  else
41
41
  options[:precision]
42
42
  end
43
43
  end
44
-
45
- def significant
46
- options[:significant]
47
- end
48
44
  end
49
45
  end
50
46
  end
@@ -99,8 +99,6 @@ module ActiveSupport
99
99
  # number_to_currency(1234567890.506, locale: :fr) # => "1 234 567 890,51 €"
100
100
  # number_to_currency('123a456') # => "$123a456"
101
101
  #
102
- # number_to_currency("123a456", raise: true) # => InvalidNumberError
103
- #
104
102
  # number_to_currency(-0.456789, precision: 0)
105
103
  # # => "$0"
106
104
  # number_to_currency(-1234567890.50, negative_format: '(%u%n)')
@@ -1,10 +1,9 @@
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"
5
4
 
6
5
  module ActiveSupport
7
- class OptionMerger #:nodoc:
6
+ class OptionMerger # :nodoc:
8
7
  instance_methods.each do |method|
9
8
  undef_method(method) unless method.start_with?("__", "instance_eval", "class", "object_id")
10
9
  end
@@ -25,20 +24,9 @@ module ActiveSupport
25
24
  options = @options
26
25
  end
27
26
 
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
27
+ if options
28
+ @context.__send__(method, *arguments, **options, &block)
29
+ else
42
30
  @context.__send__(method, *arguments, &block)
43
31
  end
44
32
  end
@@ -21,7 +21,7 @@ module ActiveSupport
21
21
  #
22
22
  # <tt>ActiveSupport::OrderedHash</tt> is namespaced to prevent conflicts
23
23
  # with other implementations.
24
- class OrderedHash < ::Hash
24
+ class OrderedHash < ::Hash # :nodoc:
25
25
  def to_yaml_type
26
26
  "!tag:yaml.org,2002:omap"
27
27
  end
@@ -16,6 +16,11 @@ module ActiveSupport
16
16
  # ActiveSupport::ParameterFilter.new([:foo, "bar"])
17
17
  # => replaces the value to all keys matching /foo|bar/i with "[FILTERED]"
18
18
  #
19
+ # ActiveSupport::ParameterFilter.new([/\Apin\z/i, /\Apin_/i])
20
+ # => replaces the value for the exact (case-insensitive) key 'pin' and all
21
+ # (case-insensitive) keys beginning with 'pin_', with "[FILTERED]".
22
+ # Does not match keys with 'pin' as a substring, such as 'shipping_id'.
23
+ #
19
24
  # ActiveSupport::ParameterFilter.new(["credit_card.code"])
20
25
  # => replaces { credit_card: {code: "xxxx"} } with "[FILTERED]", does not
21
26
  # change { file: { code: "xxxx"} }
@@ -56,5 +56,6 @@ module ActiveSupport
56
56
 
57
57
  send(name, *args, &block)
58
58
  end
59
+ ruby2_keywords(:method_missing)
59
60
  end
60
61
  end
@@ -9,6 +9,15 @@ module ActiveSupport
9
9
 
10
10
  config.eager_load_namespaces << ActiveSupport
11
11
 
12
+ initializer "active_support.remove_deprecated_time_with_zone_name" do |app|
13
+ config.after_initialize do
14
+ if app.config.active_support.remove_deprecated_time_with_zone_name
15
+ require "active_support/time_with_zone"
16
+ TimeWithZone.singleton_class.remove_method(:name)
17
+ end
18
+ end
19
+ end
20
+
12
21
  initializer "active_support.set_authenticated_message_encryption" do |app|
13
22
  config.after_initialize do
14
23
  unless app.config.active_support.use_authenticated_message_encryption.nil?
@@ -30,16 +39,22 @@ module ActiveSupport
30
39
  end
31
40
 
32
41
  initializer "active_support.deprecation_behavior" do |app|
33
- if deprecation = app.config.active_support.deprecation
34
- ActiveSupport::Deprecation.behavior = deprecation
35
- end
42
+ if app.config.active_support.report_deprecations == false
43
+ ActiveSupport::Deprecation.silenced = true
44
+ ActiveSupport::Deprecation.behavior = :silence
45
+ ActiveSupport::Deprecation.disallowed_behavior = :silence
46
+ else
47
+ if deprecation = app.config.active_support.deprecation
48
+ ActiveSupport::Deprecation.behavior = deprecation
49
+ end
36
50
 
37
- if disallowed_deprecation = app.config.active_support.disallowed_deprecation
38
- ActiveSupport::Deprecation.disallowed_behavior = disallowed_deprecation
39
- end
51
+ if disallowed_deprecation = app.config.active_support.disallowed_deprecation
52
+ ActiveSupport::Deprecation.disallowed_behavior = disallowed_deprecation
53
+ end
40
54
 
41
- if disallowed_warnings = app.config.active_support.disallowed_deprecation_warnings
42
- ActiveSupport::Deprecation.disallowed_warnings = disallowed_warnings
55
+ if disallowed_warnings = app.config.active_support.disallowed_deprecation_warnings
56
+ ActiveSupport::Deprecation.disallowed_warnings = disallowed_warnings
57
+ end
43
58
  end
44
59
  end
45
60
 
@@ -87,10 +102,10 @@ module ActiveSupport
87
102
  if app.config.active_support.use_sha1_digests
88
103
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
89
104
  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.
105
+ be removed from Rails 7.0. Use
106
+ config.active_support.hash_digest_class = OpenSSL::Digest::SHA1 instead.
92
107
  MSG
93
- ActiveSupport::Digest.hash_digest_class = ::Digest::SHA1
108
+ ActiveSupport::Digest.hash_digest_class = OpenSSL::Digest::SHA1
94
109
  end
95
110
 
96
111
  if klass = app.config.active_support.hash_digest_class
@@ -98,5 +113,13 @@ module ActiveSupport
98
113
  end
99
114
  end
100
115
  end
116
+
117
+ initializer "active_support.set_key_generator_hash_digest_class" do |app|
118
+ config.after_initialize do
119
+ if klass = app.config.active_support.key_generator_hash_digest_class
120
+ ActiveSupport::KeyGenerator.hash_digest_class = klass
121
+ end
122
+ end
123
+ end
101
124
  end
102
125
  end