activesupport 8.0.0 → 8.0.1

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: 8d43c6938627c736f544a0a9f0af6f8a538e8dd6c147ff51e368946c4d57d7c4
4
- data.tar.gz: 6e57c37c1735b475cb5a2d96c0af1ed0f6f2f2d41a776743bc97cc0b61e4b778
3
+ metadata.gz: e4fc487978c855f357de44a7915c8d6d21161a4731bfe676294c1a39f91083d8
4
+ data.tar.gz: e0c7577dabe5346cdcaddef70cb94d58d636df12bef5f7b96df8c062f1831d08
5
5
  SHA512:
6
- metadata.gz: c01d045e73ab8eb2c3a3494180490bb5fa39a082343d5445593bd591333cd95cca84ad0d79668afe6603389ac675c8cbe3f98a0bb5612bfb5a3ec8d77fa26d9b
7
- data.tar.gz: b5a92add8986b7bb4f73a5e7c4ff82525dfcfb4a1ca0bcedb6364a338f88cb5b411595c1704d508d68ad0ed2df850788132a2270e4f1421d672b1394c49e8306
6
+ metadata.gz: 2fc772fb80613c40405114a4cf7a806fe77766ee128c7c308de18eedd73fa6581f95dd072cdf38b13947d91d9df560620b8126b199577b293f2095c4c6d0481e
7
+ data.tar.gz: 8aa7beb41005f500c9d4d1287f2f11724f7178aaa9953c089d4afb5523060136da33771f3ac0ee5edf8dc91afcb9bd31272eaeef650c9238c670c6f0c82b18cb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
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
+
17
+ ## Rails 8.0.0.1 (December 10, 2024) ##
18
+
19
+ * No changes.
20
+
21
+
1
22
  ## Rails 8.0.0 (November 07, 2024) ##
2
23
 
3
24
  * 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,7 +9,7 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 8
11
11
  MINOR = 0
12
- TINY = 0
12
+ TINY = 1
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -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
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-11-07 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/activesupport/CHANGELOG.md
499
- documentation_uri: https://api.rubyonrails.org/v8.0.0/
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/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: