activesupport 8.0.0.1 → 8.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3c85fb4feaab6bdc90cc10e0605e5933ed3ade33d530f64c2bc2dfa52982e36
4
- data.tar.gz: 9a93c397cc744ef297479159ef3796e821ae64fe36613ca7ccf8466e42cc4838
3
+ metadata.gz: e4fc487978c855f357de44a7915c8d6d21161a4731bfe676294c1a39f91083d8
4
+ data.tar.gz: e0c7577dabe5346cdcaddef70cb94d58d636df12bef5f7b96df8c062f1831d08
5
5
  SHA512:
6
- metadata.gz: 3cd41a33f8623947ba884dc425f416ad44195cd778649223ed37e40d481d9b8b9079d8e8ece0202d3837341e30589676b6b0eba5676724a183e00bd4f03bd5e7
7
- data.tar.gz: '009219b148292ecff2ba70d4d9201ed919dfb445ddbbf752b57adef3ed9b37d2c96b47e8d51f0b3db72dc620702eb7f6817262e389b6d7a3b495ab8655a0babd'
6
+ metadata.gz: 2fc772fb80613c40405114a4cf7a806fe77766ee128c7c308de18eedd73fa6581f95dd072cdf38b13947d91d9df560620b8126b199577b293f2095c4c6d0481e
7
+ data.tar.gz: 8aa7beb41005f500c9d4d1287f2f11724f7178aaa9953c089d4afb5523060136da33771f3ac0ee5edf8dc91afcb9bd31272eaeef650c9238c670c6f0c82b18cb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## Rails 8.0.1 (December 13, 2024) ##
2
+
3
+ * Fix a bug in `ERB::Util.tokenize` that causes incorrect tokenization when ERB tags are preceeded by multibyte characters.
4
+
5
+ *Martin Emde*
6
+
7
+ * Restore the ability to decorate methods generated by `class_attribute`.
8
+
9
+ It always has been complicated to use Module#prepend or an alias method chain
10
+ to decorate methods defined by `class_attribute`, but became even harder in 8.0.
11
+
12
+ This capability is now supported for both reader and writer methods.
13
+
14
+ *Jean Boussier*
15
+
16
+
1
17
  ## Rails 8.0.0.1 (December 10, 2024) ##
2
18
 
3
19
  * No changes.
@@ -933,7 +933,10 @@ module ActiveSupport
933
933
  end
934
934
 
935
935
  def set_callbacks(name, callbacks) # :nodoc:
936
- unless singleton_class.method_defined?(:__callbacks, false)
936
+ # HACK: We're making assumption on how `class_attribute` is implemented
937
+ # to save constantly duping the callback hash. If this desync with class_attribute
938
+ # we'll lose the optimization, but won't cause an actual behavior bug.
939
+ unless singleton_class.private_method_defined?(:__class_attr__callbacks, false)
937
940
  self.__callbacks = __callbacks.dup
938
941
  end
939
942
  self.__callbacks[name.to_sym] = callbacks
@@ -3,23 +3,30 @@
3
3
  module ActiveSupport
4
4
  module ClassAttribute # :nodoc:
5
5
  class << self
6
- def redefine(owner, name, value)
6
+ def redefine(owner, name, namespaced_name, value)
7
7
  if owner.singleton_class?
8
- owner.redefine_method(name) { value }
9
- owner.send(:public, name)
8
+ if owner.attached_object.is_a?(Module)
9
+ redefine_method(owner, namespaced_name, private: true) { value }
10
+ else
11
+ redefine_method(owner, name) { value }
12
+ end
10
13
  end
11
14
 
12
- owner.redefine_singleton_method(name) { value }
13
- owner.singleton_class.send(:public, name)
15
+ redefine_method(owner.singleton_class, namespaced_name, private: true) { value }
14
16
 
15
- owner.redefine_singleton_method("#{name}=") do |new_value|
17
+ redefine_method(owner.singleton_class, "#{namespaced_name}=", private: true) do |new_value|
16
18
  if owner.equal?(self)
17
19
  value = new_value
18
20
  else
19
- ::ActiveSupport::ClassAttribute.redefine(self, name, new_value)
21
+ ::ActiveSupport::ClassAttribute.redefine(self, name, namespaced_name, new_value)
20
22
  end
21
23
  end
22
- owner.singleton_class.send(:public, "#{name}=")
24
+ end
25
+
26
+ def redefine_method(owner, name, private: false, &block)
27
+ owner.silence_redefinition_of_method(name)
28
+ owner.define_method(name, &block)
29
+ owner.send(:private, name) if private
23
30
  end
24
31
  end
25
32
  end
@@ -16,11 +16,11 @@ class Array
16
16
  # ==== Options
17
17
  #
18
18
  # * <tt>:words_connector</tt> - The sign or word used to join all but the last
19
- # element in arrays with three or more elements (default: ", ").
19
+ # element in arrays with three or more elements (default: <tt>", "</tt>).
20
20
  # * <tt>:last_word_connector</tt> - The sign or word used to join the last element
21
- # in arrays with three or more elements (default: ", and ").
21
+ # in arrays with three or more elements (default: <tt>", and "</tt>).
22
22
  # * <tt>:two_words_connector</tt> - The sign or word used to join the elements
23
- # in arrays with two elements (default: " and ").
23
+ # in arrays with two elements (default: <tt>" and "</tt>).
24
24
  # * <tt>:locale</tt> - If +i18n+ is available, you can set a locale and use
25
25
  # the connector options defined on the 'support.array' namespace in the
26
26
  # corresponding dictionary file.
@@ -84,8 +84,8 @@ class Class
84
84
  #
85
85
  # class_attribute :settings, default: {}
86
86
  def class_attribute(*attrs, instance_accessor: true,
87
- instance_reader: instance_accessor, instance_writer: instance_accessor, instance_predicate: true, default: nil)
88
-
87
+ instance_reader: instance_accessor, instance_writer: instance_accessor, instance_predicate: true, default: nil
88
+ )
89
89
  class_methods, methods = [], []
90
90
  attrs.each do |name|
91
91
  unless name.is_a?(Symbol) || name.is_a?(String)
@@ -93,12 +93,25 @@ class Class
93
93
  end
94
94
 
95
95
  name = name.to_sym
96
- ::ActiveSupport::ClassAttribute.redefine(self, name, default)
96
+ namespaced_name = :"__class_attr_#{name}"
97
+ ::ActiveSupport::ClassAttribute.redefine(self, name, namespaced_name, default)
98
+
99
+ delegators = [
100
+ "def #{name}; #{namespaced_name}; end",
101
+ "def #{name}=(value); self.#{namespaced_name} = value; end",
102
+ ]
97
103
 
98
- unless singleton_class?
104
+ class_methods.concat(delegators)
105
+ if singleton_class?
106
+ methods.concat(delegators)
107
+ else
99
108
  methods << <<~RUBY if instance_reader
100
109
  silence_redefinition_of_method def #{name}
101
- defined?(@#{name}) ? @#{name} : self.class.#{name}
110
+ if defined?(@#{name})
111
+ @#{name}
112
+ else
113
+ self.class.#{name}
114
+ end
102
115
  end
103
116
  RUBY
104
117
  end
@@ -174,7 +174,7 @@ class ERB
174
174
 
175
175
  case source.matched
176
176
  when start_re
177
- tokens << [:TEXT, source.string[pos, len]] if len > 0
177
+ tokens << [:TEXT, source.string.byteslice(pos, len)] if len > 0
178
178
  tokens << [:OPEN, source.matched]
179
179
  if source.scan(/(.*?)(?=#{finish_re}|\z)/m)
180
180
  tokens << [:CODE, source.matched] unless source.matched.empty?
@@ -183,7 +183,7 @@ class ERB
183
183
  raise NotImplementedError
184
184
  end
185
185
  when finish_re
186
- tokens << [:CODE, source.string[pos, len]] if len > 0
186
+ tokens << [:CODE, source.string.byteslice(pos, len)] if len > 0
187
187
  tokens << [:CLOSE, source.matched]
188
188
  else
189
189
  raise NotImplementedError, source.matched
@@ -16,8 +16,18 @@ module SecureRandom
16
16
  #
17
17
  # p SecureRandom.base58 # => "4kUgL2pdQMSCQtjE"
18
18
  # p SecureRandom.base58(24) # => "77TMHrHJFvFDwodq8w7Ev2m7"
19
- def self.base58(n = 16)
20
- SecureRandom.alphanumeric(n, chars: BASE58_ALPHABET)
19
+ if SecureRandom.method(:alphanumeric).parameters.size == 2 # Remove check when Ruby 3.3 is the minimum supported version
20
+ def self.base58(n = 16)
21
+ 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
21
31
  end
22
32
 
23
33
  # SecureRandom.base36 generates a random base36 string in lowercase.
@@ -31,11 +41,17 @@ module SecureRandom
31
41
  #
32
42
  # p SecureRandom.base36 # => "4kugl2pdqmscqtje"
33
43
  # p SecureRandom.base36(24) # => "77tmhrhjfvfdwodq8w7ev2m7"
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
44
+ if SecureRandom.method(:alphanumeric).parameters.size == 2 # Remove check when Ruby 3.3 is the minimum supported version
45
+ def self.base36(n = 16)
46
+ 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
40
56
  end
41
57
  end
@@ -9,8 +9,8 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 8
11
11
  MINOR = 0
12
- TINY = 0
13
- PRE = "1"
12
+ TINY = 1
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -136,7 +136,7 @@ module ActiveSupport
136
136
 
137
137
  # Returns a string of the object's date, time, zone, and offset from UTC.
138
138
  #
139
- # Time.zone.now.inspect # => "Thu, 04 Dec 2014 11:00:25.624541392 EST -05:00"
139
+ # Time.zone.now.inspect # => "2024-11-13 07:00:10.528054960 UTC +00:00"
140
140
  def inspect
141
141
  "#{time.strftime('%F %H:%M:%S.%9N')} #{zone} #{formatted_offset}"
142
142
  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: 8.0.0.1
4
+ version: 8.0.1
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-12-10 00:00:00.000000000 Z
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -495,10 +495,10 @@ licenses:
495
495
  - MIT
496
496
  metadata:
497
497
  bug_tracker_uri: https://github.com/rails/rails/issues
498
- changelog_uri: https://github.com/rails/rails/blob/v8.0.0.1/activesupport/CHANGELOG.md
499
- documentation_uri: https://api.rubyonrails.org/v8.0.0.1/
498
+ changelog_uri: https://github.com/rails/rails/blob/v8.0.1/activesupport/CHANGELOG.md
499
+ documentation_uri: https://api.rubyonrails.org/v8.0.1/
500
500
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
501
- source_code_uri: https://github.com/rails/rails/tree/v8.0.0.1/activesupport
501
+ source_code_uri: https://github.com/rails/rails/tree/v8.0.1/activesupport
502
502
  rubygems_mfa_required: 'true'
503
503
  post_install_message:
504
504
  rdoc_options: