activesupport 7.2.0.beta3 → 7.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebee3f86f1ae5a137af35d239383bd331c70684d4f6ab9635d7c5801906e9f93
4
- data.tar.gz: 0a455dc9c538504271019964e3172493cede9f99dd554cc2265bc73c99eccc74
3
+ metadata.gz: 2aaa473f08555b8cff31f1badf96b6db12166e0d598ce8b686ed9eb47c25ff16
4
+ data.tar.gz: f184db8c521f40286828664b6aadf74823179b793a4f02edb447e181810a71f9
5
5
  SHA512:
6
- metadata.gz: d6c7cc205859ceaa853b4a235c242e93cfd857a1325a4a9b0e90bdf8af2490e3b3875ae77d1f3cb75bcf0ac60c1aeb159f1195b667715d1e3a940bf014cad339
7
- data.tar.gz: 59da4cf50826bebca6bdfaca2a1c00f053fa3c3bcb12017ff4acb16fcfcfdc7b94afa07ef761644d1dfe56fc5bc6dd147b808ed5d40ec2ec46f9c208eda48ee2
6
+ metadata.gz: fcd73b0e3c374fd484e6cf12240ce61910b889ebfcf8715db0307f30db54778aa9cbf309411a4246b1c092ea41935f8c3c93f5b597b36375441f9ecf9d497efc
7
+ data.tar.gz: 6206ed420d950a2051a7c60a3c98b30813f6fd85c1a63c85f2cd4432b8a8bed9473ee85468f0ebe580f3ec4d4aae08a4cee6dde571ba04638735ca604af9f5f4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## Rails 7.2.0.rc1 (August 06, 2024) ##
2
+
3
+ * Fix `delegate_missing_to allow_nil: true` when called with implict self
4
+
5
+ ```ruby
6
+ class Person
7
+ delegate_missing_to :address, allow_nil: true
8
+
9
+ def address
10
+ nil
11
+ end
12
+
13
+ def berliner?
14
+ city == "Berlin"
15
+ end
16
+ end
17
+
18
+ Person.new.city # => nil
19
+ Person.new.berliner? # undefined local variable or method `city' for an instance of Person (NameError)
20
+ ```
21
+
22
+ *Jean Boussier*
23
+
1
24
  ## Rails 7.2.0.beta3 (July 11, 2024) ##
2
25
 
3
26
  * Add `logger` as a dependency since it is a bundled gem candidate for Ruby 3.5
@@ -16,18 +16,8 @@ module SecureRandom
16
16
  #
17
17
  # p SecureRandom.base58 # => "4kUgL2pdQMSCQtjE"
18
18
  # p SecureRandom.base58(24) # => "77TMHrHJFvFDwodq8w7Ev2m7"
19
- if RUBY_VERSION >= "3.3"
20
- def self.base58(n = 16)
21
- SecureRandom.alphanumeric(n, chars: BASE58_ALPHABET)
22
- end
23
- else
24
- def self.base58(n = 16)
25
- SecureRandom.random_bytes(n).unpack("C*").map do |byte|
26
- idx = byte % 64
27
- idx = SecureRandom.random_number(58) if idx >= 58
28
- BASE58_ALPHABET[idx]
29
- end.join
30
- end
19
+ def self.base58(n = 16)
20
+ SecureRandom.alphanumeric(n, chars: BASE58_ALPHABET)
31
21
  end
32
22
 
33
23
  # SecureRandom.base36 generates a random base36 string in lowercase.
@@ -41,17 +31,11 @@ module SecureRandom
41
31
  #
42
32
  # p SecureRandom.base36 # => "4kugl2pdqmscqtje"
43
33
  # p SecureRandom.base36(24) # => "77tmhrhjfvfdwodq8w7ev2m7"
44
- if RUBY_VERSION >= "3.3"
45
- def self.base36(n = 16)
46
- SecureRandom.alphanumeric(n, chars: BASE36_ALPHABET)
47
- end
48
- else
49
- def self.base36(n = 16)
50
- SecureRandom.random_bytes(n).unpack("C*").map do |byte|
51
- idx = byte % 64
52
- idx = SecureRandom.random_number(36) if idx >= 36
53
- BASE36_ALPHABET[idx]
54
- end.join
55
- end
34
+ def self.base36(n = 16)
35
+ SecureRandom.random_bytes(n).unpack("C*").map do |byte|
36
+ idx = byte % 64
37
+ idx = SecureRandom.random_number(36) if idx >= 36
38
+ BASE36_ALPHABET[idx]
39
+ end.join
56
40
  end
57
41
  end
@@ -151,37 +151,51 @@ module ActiveSupport
151
151
 
152
152
  def generate_method_missing(owner, target, allow_nil: nil)
153
153
  target = target.to_s
154
- target = "self.#{target}" if RESERVED_METHOD_NAMES.include?(target)
154
+ target = "self.#{target}" if RESERVED_METHOD_NAMES.include?(target) || target == "__target"
155
155
 
156
- owner.module_eval <<-RUBY, __FILE__, __LINE__ + 1
157
- def respond_to_missing?(name, include_private = false)
158
- # It may look like an oversight, but we deliberately do not pass
159
- # +include_private+, because they do not get delegated.
156
+ if allow_nil
157
+ owner.module_eval <<~RUBY, __FILE__, __LINE__ + 1
158
+ def respond_to_missing?(name, include_private = false)
159
+ # It may look like an oversight, but we deliberately do not pass
160
+ # +include_private+, because they do not get delegated.
160
161
 
161
- return false if name == :marshal_dump || name == :_dump
162
- #{target}.respond_to?(name) || super
163
- end
162
+ return false if name == :marshal_dump || name == :_dump
163
+ #{target}.respond_to?(name) || super
164
+ end
164
165
 
165
- def method_missing(method, ...)
166
- if #{target}.respond_to?(method)
167
- #{target}.public_send(method, ...)
168
- else
169
- begin
166
+ def method_missing(method, ...)
167
+ __target = #{target}
168
+ if __target.nil? && !nil.respond_to?(method)
169
+ nil
170
+ elsif __target.respond_to?(method)
171
+ __target.public_send(method, ...)
172
+ else
170
173
  super
171
- rescue NoMethodError
172
- if #{target}.nil?
173
- if #{allow_nil == true}
174
- nil
175
- else
176
- raise ::ActiveSupport::DelegationError.nil_target(method, :'#{target}')
177
- end
178
- else
179
- raise
180
- end
181
174
  end
182
175
  end
183
- end
184
- RUBY
176
+ RUBY
177
+ else
178
+ owner.module_eval <<~RUBY, __FILE__, __LINE__ + 1
179
+ def respond_to_missing?(name, include_private = false)
180
+ # It may look like an oversight, but we deliberately do not pass
181
+ # +include_private+, because they do not get delegated.
182
+
183
+ return false if name == :marshal_dump || name == :_dump
184
+ #{target}.respond_to?(name) || super
185
+ end
186
+
187
+ def method_missing(method, ...)
188
+ __target = #{target}
189
+ if __target.nil? && !nil.respond_to?(method)
190
+ raise ::ActiveSupport::DelegationError.nil_target(method, :'#{target}')
191
+ elsif __target.respond_to?(method)
192
+ __target.public_send(method, ...)
193
+ else
194
+ super
195
+ end
196
+ end
197
+ RUBY
198
+ end
185
199
  end
186
200
  end
187
201
  end
@@ -2,28 +2,6 @@
2
2
 
3
3
  module ActiveSupport
4
4
  class Deprecation
5
- # DeprecatedConstantAccessor transforms a constant into a deprecated one by
6
- # hooking +const_missing+.
7
- #
8
- # It takes the names of an old (deprecated) constant and of a new constant
9
- # (both in string form) and a deprecator.
10
- #
11
- # The deprecated constant now returns the same object as the new one rather
12
- # than a proxy object, so it can be used transparently in +rescue+ blocks
13
- # etc.
14
- #
15
- # PLANETS = %w(mercury venus earth mars jupiter saturn uranus neptune pluto)
16
- #
17
- # # (In a later update, the original implementation of `PLANETS` has been removed.)
18
- #
19
- # PLANETS_POST_2006 = %w(mercury venus earth mars jupiter saturn uranus neptune)
20
- # include ActiveSupport::Deprecation::DeprecatedConstantAccessor
21
- # deprecate_constant 'PLANETS', 'PLANETS_POST_2006', deprecator: ActiveSupport::Deprecation.new
22
- #
23
- # PLANETS.map { |planet| planet.capitalize }
24
- # # => DEPRECATION WARNING: PLANETS is deprecated! Use PLANETS_POST_2006 instead.
25
- # (Backtrace information…)
26
- # ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
27
5
  module DeprecatedConstantAccessor
28
6
  def self.included(base)
29
7
  require "active_support/inflector/methods"
@@ -39,9 +17,54 @@ module ActiveSupport
39
17
  super
40
18
  end
41
19
 
42
- def deprecate_constant(const_name, new_constant, deprecator:, message: nil)
20
+ # Provides a way to rename constants with a deprecation cycle in which
21
+ # both the old and new names work, but using the old one prints a
22
+ # deprecation message.
23
+ #
24
+ # In order to rename <tt>A::B</tt> to <tt>C::D</tt>, you need to delete the
25
+ # definition of <tt>A::B</tt> and declare the deprecation in +A+:
26
+ #
27
+ # require "active_support/deprecation"
28
+ #
29
+ # module A
30
+ # include ActiveSupport::Deprecation::DeprecatedConstantAccessor
31
+ #
32
+ # deprecate_constant "B", "C::D", deprecator: ActiveSupport::Deprecation.new
33
+ # end
34
+ #
35
+ # The first argument is a constant name (no colons). It is the name of
36
+ # the constant you want to deprecate in the enclosing class or module.
37
+ #
38
+ # The second argument is the constant path of the replacement. That
39
+ # has to be a full path even if the replacement is defined in the same
40
+ # namespace as the deprecated one was.
41
+ #
42
+ # In both cases, strings and symbols are supported.
43
+ #
44
+ # The +deprecator+ keyword argument is the object that will print the
45
+ # deprecation message, an instance of ActiveSupport::Deprecation.
46
+ #
47
+ # With that in place, references to <tt>A::B</tt> still work, they
48
+ # evaluate to <tt>C::D</tt> now, and trigger a deprecation warning:
49
+ #
50
+ # DEPRECATION WARNING: A::B is deprecated! Use C::D instead.
51
+ # (called from ...)
52
+ #
53
+ # The message can be customized with the optional +message+ keyword
54
+ # argument.
55
+ #
56
+ # For this to work, a +const_missing+ hook is installed. When client
57
+ # code references the deprecated constant, the callback prints the
58
+ # message and constantizes the replacement.
59
+ #
60
+ # Caveat: If the deprecated constant name is reachable in a different
61
+ # namespace and Ruby constant lookup finds it, the hook won't be
62
+ # called and the deprecation won't work as intended. This may happen,
63
+ # for example, if an ancestor of the enclosing namespace has a
64
+ # constant with the same name. This is an unsupported edge case.
65
+ def deprecate_constant(old_constant_name, new_constant_path, deprecator:, message: nil)
43
66
  class_variable_set(:@@_deprecated_constants, {}) unless class_variable_defined?(:@@_deprecated_constants)
44
- class_variable_get(:@@_deprecated_constants)[const_name.to_s] = { new: new_constant, message: message, deprecator: deprecator }
67
+ class_variable_get(:@@_deprecated_constants)[old_constant_name.to_s] = { new: new_constant_path, message: message, deprecator: deprecator }
45
68
  end
46
69
  end
47
70
  base.singleton_class.prepend extension
@@ -10,7 +10,7 @@ module ActiveSupport
10
10
  MAJOR = 7
11
11
  MINOR = 2
12
12
  TINY = 0
13
- PRE = "beta3"
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.0.beta3
4
+ version: 7.2.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-11 00:00:00.000000000 Z
11
+ date: 2024-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -154,6 +154,20 @@ dependencies:
154
154
  - - ">="
155
155
  - !ruby/object:Gem::Version
156
156
  version: 1.4.2
157
+ - !ruby/object:Gem::Dependency
158
+ name: securerandom
159
+ requirement: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0.3'
164
+ type: :runtime
165
+ prerelease: false
166
+ version_requirements: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0.3'
157
171
  description: A toolkit of support libraries and Ruby core extensions extracted from
158
172
  the Rails framework. Rich support for multibyte strings, internationalization, time
159
173
  zones, and testing.
@@ -452,10 +466,10 @@ licenses:
452
466
  - MIT
453
467
  metadata:
454
468
  bug_tracker_uri: https://github.com/rails/rails/issues
455
- changelog_uri: https://github.com/rails/rails/blob/v7.2.0.beta3/activesupport/CHANGELOG.md
456
- documentation_uri: https://api.rubyonrails.org/v7.2.0.beta3/
469
+ changelog_uri: https://github.com/rails/rails/blob/v7.2.0.rc1/activesupport/CHANGELOG.md
470
+ documentation_uri: https://api.rubyonrails.org/v7.2.0.rc1/
457
471
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
458
- source_code_uri: https://github.com/rails/rails/tree/v7.2.0.beta3/activesupport
472
+ source_code_uri: https://github.com/rails/rails/tree/v7.2.0.rc1/activesupport
459
473
  rubygems_mfa_required: 'true'
460
474
  post_install_message:
461
475
  rdoc_options: