activesupport 7.2.0.beta1 → 7.2.0.beta3

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: e43bd2e8809b8fdeeb3e6235678e3791be3fb235c8afbb2ff0bd6c265120931e
4
- data.tar.gz: d1db0dcc3e5c4c4f9e7b6662b6d6a9cd5e107dd26a8becfb6a29617f185486f0
3
+ metadata.gz: ebee3f86f1ae5a137af35d239383bd331c70684d4f6ab9635d7c5801906e9f93
4
+ data.tar.gz: 0a455dc9c538504271019964e3172493cede9f99dd554cc2265bc73c99eccc74
5
5
  SHA512:
6
- metadata.gz: fa5134053c7d9e38e4aed9f149f8c988487a0d482119070cd99edcca242f4701387d2a8370b60efb09d1d50cca85e57d8950685c49d83a6d12988f3f9d4d0c5e
7
- data.tar.gz: 519b1b079064c4ffce15664002efc7b240b035569a5356dbabd5e6ca799624598ba908db03a6108043bcdade5947262e3becc243925ba64848d40e29426d0bc6
6
+ metadata.gz: d6c7cc205859ceaa853b4a235c242e93cfd857a1325a4a9b0e90bdf8af2490e3b3875ae77d1f3cb75bcf0ac60c1aeb159f1195b667715d1e3a940bf014cad339
7
+ data.tar.gz: 59da4cf50826bebca6bdfaca2a1c00f053fa3c3bcb12017ff4acb16fcfcfdc7b94afa07ef761644d1dfe56fc5bc6dd147b808ed5d40ec2ec46f9c208eda48ee2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## Rails 7.2.0.beta3 (July 11, 2024) ##
2
+
3
+ * Add `logger` as a dependency since it is a bundled gem candidate for Ruby 3.5
4
+
5
+ *Earlopain*
6
+
7
+ ## Rails 7.2.0.beta2 (June 04, 2024) ##
8
+
9
+ * Define `Digest::UUID.nil_uuid`, which returns the so-called nil UUID.
10
+
11
+ *Xavier Noria*
12
+
1
13
  ## Rails 7.2.0.beta1 (May 29, 2024) ##
2
14
 
3
15
  * Support `duration` type in `ActiveSupport::XmlMini`.
@@ -122,18 +134,6 @@
122
134
 
123
135
  *Sean Doyle*
124
136
 
125
- * Remove deprecated support for the pre-Ruby 2.4 behavior of `to_time` returning a `Time` object with local timezone.
126
-
127
- *Rafael Mendonça França*
128
-
129
- * Deprecate `config.active_support.to_time_preserves_timezone`.
130
-
131
- *Rafael Mendonça França*
132
-
133
- * Deprecate `DateAndTime::Compatibility.preserve_timezone`.
134
-
135
- *Rafael Mendonça França*
136
-
137
137
  * Yield instance to `Object#with` block.
138
138
 
139
139
  ```ruby
@@ -229,6 +229,7 @@ module ActiveSupport
229
229
  private
230
230
  def dispatch(&block)
231
231
  @broadcasts.each { |logger| block.call(logger) }
232
+ true
232
233
  end
233
234
 
234
235
  def method_missing(name, ...)
@@ -9,16 +9,19 @@ module ActiveSupport
9
9
  @cache = METHOD_CACHES[namespace]
10
10
  @sources = []
11
11
  @methods = {}
12
+ @canonical_methods = {}
12
13
  end
13
14
 
14
- def define_cached_method(name, as: name)
15
- name = name.to_sym
16
- as = as.to_sym
17
- @methods.fetch(name) do
18
- unless @cache.method_defined?(as)
15
+ def define_cached_method(canonical_name, as: nil)
16
+ canonical_name = canonical_name.to_sym
17
+ as = (as || canonical_name).to_sym
18
+
19
+ @methods.fetch(as) do
20
+ unless @cache.method_defined?(canonical_name) || @canonical_methods[canonical_name]
19
21
  yield @sources
20
22
  end
21
- @methods[name] = as
23
+ @canonical_methods[canonical_name] = true
24
+ @methods[as] = canonical_name
22
25
  end
23
26
  end
24
27
 
@@ -26,8 +29,10 @@ module ActiveSupport
26
29
  unless @sources.empty?
27
30
  @cache.module_eval("# frozen_string_literal: true\n" + @sources.join(";"), path, line)
28
31
  end
29
- @methods.each do |name, as|
30
- owner.define_method(name, @cache.instance_method(as))
32
+ @canonical_methods.clear
33
+
34
+ @methods.each do |as, canonical_name|
35
+ owner.define_method(as, @cache.instance_method(canonical_name))
31
36
  end
32
37
  end
33
38
  end
@@ -52,8 +57,8 @@ module ActiveSupport
52
57
  @namespaces = Hash.new { |h, k| h[k] = MethodSet.new(k) }
53
58
  end
54
59
 
55
- def define_cached_method(name, namespace:, as: name, &block)
56
- @namespaces[namespace].define_cached_method(name, as: as, &block)
60
+ def define_cached_method(canonical_name, namespace:, as: nil, &block)
61
+ @namespaces[namespace].define_cached_method(canonical_name, as: as, &block)
57
62
  end
58
63
 
59
64
  def execute
@@ -1,9 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/core_ext/module/attribute_accessors"
4
+ require "active_support/core_ext/module/redefine_method"
4
5
 
5
6
  module DateAndTime
6
7
  module Compatibility
8
+ # If true, +to_time+ preserves the timezone offset of receiver.
9
+ #
10
+ # NOTE: With Ruby 2.4+ the default for +to_time+ changed from
11
+ # converting to the local system time, to preserving the offset
12
+ # of the receiver. For backwards compatibility we're overriding
13
+ # this behavior, but new apps will have an initializer that sets
14
+ # this to true, because the new behavior is preferred.
15
+ mattr_accessor :preserve_timezone, instance_accessor: false, default: nil
16
+
17
+ singleton_class.silence_redefinition_of_method :preserve_timezone
18
+
19
+ #--
20
+ # This re-implements the behaviour of the mattr_reader, instead
21
+ # of prepending on to it, to avoid overcomplicating a module that
22
+ # is in turn included in several places. This will all go away in
23
+ # Rails 8.0 anyway.
24
+ def self.preserve_timezone # :nodoc:
25
+ if @@preserve_timezone.nil?
26
+ # Only warn once, the first time the value is used (which should
27
+ # be the first time #to_time is called).
28
+ ActiveSupport.deprecator.warn(
29
+ "to_time will always preserve the timezone offset of the receiver in Rails 8.0. " \
30
+ "To opt in to the new behavior, set `ActiveSupport.to_time_preserves_timezone = true`."
31
+ )
32
+
33
+ @@preserve_timezone = false
34
+ end
35
+
36
+ @@preserve_timezone
37
+ end
38
+
39
+ def preserve_timezone # :nodoc:
40
+ Compatibility.preserve_timezone
41
+ end
42
+
7
43
  # Change the output of <tt>ActiveSupport::TimeZone.utc_to_local</tt>.
8
44
  #
9
45
  # When +true+, it returns local times with a UTC offset, with +false+ local
@@ -18,17 +54,5 @@ module DateAndTime
18
54
  # # With `utc_to_local_returns_utc_offset_times = true`, local time is returned with UTC offset:
19
55
  # zone.utc_to_local(Time.utc(2000, 1)) # => 1999-12-31 19:00:00 -0500
20
56
  mattr_accessor :utc_to_local_returns_utc_offset_times, instance_writer: false, default: false
21
-
22
- def self.preserve_timezone
23
- ActiveSupport.deprecator.warn(
24
- "`DateAndTime::Compatibility.preserve_timezone` has been deprecated and will be removed in Rails 7.3."
25
- )
26
- end
27
-
28
- def self.preserve_timezone=(value)
29
- ActiveSupport.deprecator.warn(
30
- "`DateAndTime::Compatibility.preserve_timezone=` has been deprecated and will be removed in Rails 7.3."
31
- )
32
- end
33
57
  end
34
58
  end
@@ -8,9 +8,11 @@ class DateTime
8
8
 
9
9
  silence_redefinition_of_method :to_time
10
10
 
11
- # Return an instance of +Time+ with the same UTC offset
12
- # as +self+.
11
+ # Either return an instance of +Time+ with the same UTC offset
12
+ # as +self+ or an instance of +Time+ representing the same time
13
+ # in the local system timezone depending on the setting of
14
+ # on the setting of +ActiveSupport.to_time_preserves_timezone+.
13
15
  def to_time
14
- getlocal(utc_offset)
16
+ preserve_timezone ? getlocal(utc_offset) : getlocal
15
17
  end
16
18
  end
@@ -53,6 +53,12 @@ module Digest
53
53
  SecureRandom.uuid
54
54
  end
55
55
 
56
+ # Returns the nil UUID. This is a special form of UUID that is specified to
57
+ # have all 128 bits set to zero.
58
+ def self.nil_uuid
59
+ "00000000-0000-0000-0000-000000000000"
60
+ end
61
+
56
62
  def self.pack_uuid_namespace(namespace)
57
63
  if [DNS_NAMESPACE, OID_NAMESPACE, URL_NAMESPACE, X500_NAMESPACE].include?(namespace)
58
64
  namespace
@@ -25,7 +25,7 @@ class Module
25
25
  def attr_internal_naming_format=(format)
26
26
  if format.start_with?("@")
27
27
  ActiveSupport.deprecator.warn <<~MESSAGE
28
- Setting `attr_internal_naming_format` with a `@` prefix is deprecated and will be removed in Rails 7.3.
28
+ Setting `attr_internal_naming_format` with a `@` prefix is deprecated and will be removed in Rails 8.0.
29
29
 
30
30
  You can simply replace #{format.inspect} by #{format.delete_prefix("@").inspect}.
31
31
  MESSAGE
@@ -319,7 +319,12 @@ class Time
319
319
  if other.class == Time
320
320
  compare_without_coercion(other)
321
321
  elsif other.is_a?(Time)
322
- compare_without_coercion(other.to_time)
322
+ # also avoid ActiveSupport::TimeWithZone#to_time before Rails 8.0
323
+ if other.respond_to?(:comparable_time)
324
+ compare_without_coercion(other.comparable_time)
325
+ else
326
+ compare_without_coercion(other.to_time)
327
+ end
323
328
  else
324
329
  to_datetime <=> other
325
330
  end
@@ -8,8 +8,25 @@ class Time
8
8
 
9
9
  silence_redefinition_of_method :to_time
10
10
 
11
- # Returns +self+.
11
+ # Either return +self+ or the time in the local system timezone depending
12
+ # on the setting of +ActiveSupport.to_time_preserves_timezone+.
12
13
  def to_time
13
- self
14
+ preserve_timezone ? self : getlocal
14
15
  end
16
+
17
+ def preserve_timezone # :nodoc:
18
+ active_support_local_zone == zone || super
19
+ end
20
+
21
+ private
22
+ @@active_support_local_tz = nil
23
+
24
+ def active_support_local_zone
25
+ @@active_support_local_zone = nil if @@active_support_local_tz != ENV["TZ"]
26
+ @@active_support_local_zone ||=
27
+ begin
28
+ @@active_support_local_tz = ENV["TZ"]
29
+ Time.new.zone
30
+ end
31
+ end
15
32
  end
@@ -152,7 +152,7 @@ module ActiveSupport
152
152
 
153
153
  def _extract_callstack(callstack)
154
154
  ActiveSupport.deprecator.warn(<<~MESSAGE)
155
- Passing the result of `caller` to ActiveSupport::Deprecation#warn is deprecated and will be removed in Rails 7.3.
155
+ Passing the result of `caller` to ActiveSupport::Deprecation#warn is deprecated and will be removed in Rails 8.0.
156
156
 
157
157
  Please pass the result of `caller_locations` instead.
158
158
  MESSAGE
@@ -68,7 +68,7 @@ module ActiveSupport
68
68
  # and the second is a library name.
69
69
  #
70
70
  # ActiveSupport::Deprecation.new('2.0', 'MyLibrary')
71
- def initialize(deprecation_horizon = "7.3", gem_name = "Rails")
71
+ def initialize(deprecation_horizon = "8.0", gem_name = "Rails")
72
72
  self.gem_name = gem_name
73
73
  self.deprecation_horizon = deprecation_horizon
74
74
  # By default, warnings are not silenced and debugging is off.
@@ -10,7 +10,7 @@ module ActiveSupport
10
10
  MAJOR = 7
11
11
  MINOR = 2
12
12
  TINY = 0
13
- PRE = "beta1"
13
+ PRE = "beta3"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -7,14 +7,6 @@ module ActiveSupport
7
7
  module LoggerThreadSafeLevel # :nodoc:
8
8
  extend ActiveSupport::Concern
9
9
 
10
- Logger::Severity.constants.each do |severity|
11
- class_eval(<<-EOT, __FILE__, __LINE__ + 1)
12
- def #{severity.downcase}? # def debug?
13
- Logger::#{severity} >= level # DEBUG >= level
14
- end # end
15
- EOT
16
- end
17
-
18
10
  def local_level
19
11
  IsolatedExecutionState[local_level_key]
20
12
  end
@@ -30,6 +30,18 @@ module ActiveSupport
30
30
  # self.current_user = User.find(id)
31
31
  # end
32
32
  #
33
+ # === Signing is not encryption
34
+ #
35
+ # The signed messages are not encrypted. The payload is merely encoded (Base64 by default) and can be decoded by
36
+ # anyone. The signature is just assuring that the message wasn't tampered with. For example:
37
+ #
38
+ # message = Rails.application.message_verifier('my_purpose').generate('never put secrets here')
39
+ # # => "BAhJIhtuZXZlciBwdXQgc2VjcmV0cyBoZXJlBjoGRVQ=--a0c1c0827919da5e949e989c971249355735e140"
40
+ # Base64.decode64(message.split("--").first) # no key needed
41
+ # # => 'never put secrets here'
42
+ #
43
+ # If you also need to encrypt the contents, you must use ActiveSupport::MessageEncryptor instead.
44
+ #
33
45
  # === Confine messages to a specific purpose
34
46
  #
35
47
  # It's not recommended to use the same verifier for different purposes in your application.
@@ -12,7 +12,7 @@ module ActiveSupport
12
12
 
13
13
  def self.inherited(_subclass)
14
14
  ::ActiveSupport.deprecator.warn(<<~MSG)
15
- ActiveSupport::ProxyObject is deprecated and will be removed in Rails 7.3.
15
+ ActiveSupport::ProxyObject is deprecated and will be removed in Rails 8.0.
16
16
  Use Ruby's built-in BasicObject instead.
17
17
  MSG
18
18
  end
@@ -45,7 +45,7 @@ module ActiveSupport
45
45
 
46
46
  private
47
47
  def parse_message_for_trace
48
- if source_location_eval?
48
+ if __getobj__.to_s.start_with?("(eval")
49
49
  # If the exception is coming from a call to eval, we need to keep
50
50
  # the path of the file in which eval was called to ensure we can
51
51
  # return the right source fragment to show the location of the
@@ -56,15 +56,5 @@ module ActiveSupport
56
56
  __getobj__.to_s.split("\n")
57
57
  end
58
58
  end
59
-
60
- if SyntaxError.method_defined?(:path) # Ruby 3.3+
61
- def source_location_eval?
62
- __getobj__.path.start_with?("(eval")
63
- end
64
- else # 3.2 and older versions of Ruby
65
- def source_location_eval?
66
- __getobj__.to_s.start_with?("(eval")
67
- end
68
- end
69
59
  end
70
60
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "active_support/core_ext/module/delegation"
4
4
  require "active_support/core_ext/object/blank"
5
- require "logger"
6
5
  require "active_support/logger"
7
6
 
8
7
  module ActiveSupport
@@ -163,10 +163,10 @@ module ActiveSupport
163
163
  now = date_or_time.midnight.to_time
164
164
  elsif date_or_time.is_a?(String)
165
165
  now = Time.zone.parse(date_or_time)
166
- elsif with_usec
167
- now = date_or_time.to_time
168
166
  else
169
- now = date_or_time.to_time.change(usec: 0)
167
+ now = date_or_time
168
+ now = now.to_time unless now.is_a?(Time)
169
+ now = now.change(usec: 0) unless with_usec
170
170
  end
171
171
 
172
172
  # +now+ must be in local system timezone, because +Time.at(now)+
@@ -332,7 +332,7 @@ module ActiveSupport
332
332
  #
333
333
  def -(other)
334
334
  if other.acts_like?(:time)
335
- to_time - other.to_time
335
+ getutc - other.getutc
336
336
  elsif duration_of_variable_length?(other)
337
337
  method_missing(:-, other)
338
338
  else
@@ -479,10 +479,15 @@ module ActiveSupport
479
479
  @to_datetime ||= utc.to_datetime.new_offset(Rational(utc_offset, 86_400))
480
480
  end
481
481
 
482
- # Returns an instance of +Time+ with the same UTC offset
483
- # as +self+.
482
+ # Returns an instance of +Time+, either with the same UTC offset
483
+ # as +self+ or in the local system timezone depending on the setting
484
+ # of +ActiveSupport.to_time_preserves_timezone+.
484
485
  def to_time
485
- @to_time_with_instance_offset ||= getlocal(utc_offset)
486
+ if preserve_timezone
487
+ @to_time_with_instance_offset ||= getlocal(utc_offset)
488
+ else
489
+ @to_time_with_system_offset ||= getlocal
490
+ end
486
491
  end
487
492
 
488
493
  # So that +self+ <tt>acts_like?(:time)</tt>.
@@ -111,15 +111,17 @@ module ActiveSupport
111
111
  end
112
112
 
113
113
  def self.to_time_preserves_timezone
114
- ActiveSupport.deprecator.warn(
115
- "`config.active_support.to_time_preserves_timezone` has been deprecated and will be removed in Rails 7.3."
116
- )
114
+ DateAndTime::Compatibility.preserve_timezone
117
115
  end
118
116
 
119
117
  def self.to_time_preserves_timezone=(value)
120
- ActiveSupport.deprecator.warn(
121
- "`config.active_support.to_time_preserves_timezone` has been deprecated and will be removed in Rails 7.3."
122
- )
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
+
124
+ DateAndTime::Compatibility.preserve_timezone = value
123
125
  end
124
126
 
125
127
  def self.utc_to_local_returns_utc_offset_times
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.beta1
4
+ version: 7.2.0.beta3
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-05-29 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -140,6 +140,20 @@ dependencies:
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: logger
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: 1.4.2
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: 1.4.2
143
157
  description: A toolkit of support libraries and Ruby core extensions extracted from
144
158
  the Rails framework. Rich support for multibyte strings, internationalization, time
145
159
  zones, and testing.
@@ -438,10 +452,10 @@ licenses:
438
452
  - MIT
439
453
  metadata:
440
454
  bug_tracker_uri: https://github.com/rails/rails/issues
441
- changelog_uri: https://github.com/rails/rails/blob/v7.2.0.beta1/activesupport/CHANGELOG.md
442
- documentation_uri: https://api.rubyonrails.org/v7.2.0.beta1/
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/
443
457
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
444
- source_code_uri: https://github.com/rails/rails/tree/v7.2.0.beta1/activesupport
458
+ source_code_uri: https://github.com/rails/rails/tree/v7.2.0.beta3/activesupport
445
459
  rubygems_mfa_required: 'true'
446
460
  post_install_message:
447
461
  rdoc_options:
@@ -460,7 +474,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
460
474
  - !ruby/object:Gem::Version
461
475
  version: '0'
462
476
  requirements: []
463
- rubygems_version: 3.5.10
477
+ rubygems_version: 3.5.11
464
478
  signing_key:
465
479
  specification_version: 4
466
480
  summary: A toolkit of support libraries and Ruby core extensions extracted from the