activesupport 7.0.5.1 → 7.0.7

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87d108732dc49cf014c3bc1d0d792dbd3c82a5b64bde2261236a5d28eaccf7c5
4
- data.tar.gz: baae63628a0b21790baa214e29395c3f552f420656f40cef982a45d87cf4bc7a
3
+ metadata.gz: 80a7bd049eb2334eb8d890f9c6e9aa59ac18ad0f389901ab2095325f975c9bf3
4
+ data.tar.gz: 6c81983a51ecab1619501c6408dd72bcda286ac4a8f10f7238d911c88a89a074
5
5
  SHA512:
6
- metadata.gz: 50d31a16339a92e9ac8f77696ec91239831e3ff41ec7db7f156d966b92962b0d80f98295fa72ebd261103a8f7e5cd72c781863b9d0c45bb48f5d8f3a077d9759
7
- data.tar.gz: 2fe143a1e688083b58f993ccd77f7e9be4fc171440140d06f7420cdddd90c9a421b8e6f1db47589722e7b1a0c2cdca6dea26e4cce3ca63df49ec41687a25c841
6
+ metadata.gz: e5dc3de073888174d4cf67504cf410cd40930f91b7a6acc3e2cb070443f0001921500ec12b759dbb1889b03452b006bd9eb1df27f66a7e9453e0ee71d0e28b90
7
+ data.tar.gz: c36cc3363dd654026af0f821737b0775de90111e4d8f4e1e7b1a27f42345d110d254c308080fc0f6c7e8e62a63e0ce7e08c69978609c137fd9d0a49cd348aa09
data/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ ## Rails 7.0.7 (August 09, 2023) ##
2
+
3
+ * Fix `Cache::NullStore` with local caching for repeated reads.
4
+
5
+ *fatkodima*
6
+
7
+ * Fix `to_s` with no arguments not respecting custom `:default` formats
8
+
9
+ *Hartley McGuire*
10
+
11
+ * Fix `ActiveSupport::Inflector.humanize(nil)` raising ``NoMethodError: undefined method `end_with?' for nil:NilClass``.
12
+
13
+ *James Robinson*
14
+
15
+ * Fix `Enumerable#sum` for `Enumerator#lazy`.
16
+
17
+ *fatkodima*, *Matthew Draper*, *Jonathan Hefner*
18
+
19
+ * Improve error message when EventedFileUpdateChecker is used without a
20
+ compatible version of the Listen gem
21
+
22
+ *Hartley McGuire*
23
+
24
+
25
+ ## Rails 7.0.6 (June 29, 2023) ##
26
+
27
+ * Fix `EncryptedConfiguration` returning incorrect values for some `Hash`
28
+ methods
29
+
30
+ *Hartley McGuire*
31
+
32
+ * Fix arguments being destructed `Enumerable#many?` with block.
33
+
34
+ *Andrew Novoselac*
35
+
36
+ * Fix humanize for strings ending with id.
37
+
38
+ *fatkodima*
39
+
40
+
1
41
  ## Rails 7.0.5.1 (June 26, 2023) ##
2
42
 
3
43
  * No changes.
data/README.rdoc CHANGED
@@ -13,7 +13,7 @@ The latest version of Active Support can be installed with RubyGems:
13
13
 
14
14
  $ gem install activesupport
15
15
 
16
- Source code can be downloaded as part of the Rails project on GitHub:
16
+ Source code can be downloaded as part of the \Rails project on GitHub:
17
17
 
18
18
  * https://github.com/rails/rails/tree/main/activesupport
19
19
 
@@ -31,7 +31,7 @@ API documentation is at:
31
31
 
32
32
  * https://api.rubyonrails.org
33
33
 
34
- Bug reports for the Ruby on Rails project can be filed here:
34
+ Bug reports for the Ruby on \Rails project can be filed here:
35
35
 
36
36
  * https://github.com/rails/rails/issues
37
37
 
@@ -124,7 +124,7 @@ module ActiveSupport
124
124
 
125
125
  local_entries = local_cache.read_multi_entries(keys)
126
126
  local_entries.transform_values! do |payload|
127
- deserialize_entry(payload).value
127
+ deserialize_entry(payload)&.value
128
128
  end
129
129
  missed_keys = keys - local_entries.keys
130
130
 
@@ -15,7 +15,18 @@ class Date
15
15
  strftime(formatter)
16
16
  end
17
17
  elsif format == NOT_SET
18
- to_default_s
18
+ if formatter = DATE_FORMATS[:default]
19
+ ActiveSupport::Deprecation.warn(
20
+ "Using a :default format for Date#to_s is deprecated. Please use Date#to_fs instead."
21
+ )
22
+ if formatter.respond_to?(:call)
23
+ formatter.call(self).to_s
24
+ else
25
+ strftime(formatter)
26
+ end
27
+ else
28
+ to_default_s
29
+ end
19
30
  else
20
31
  ActiveSupport::Deprecation.warn(
21
32
  "Date#to_s(#{format.inspect}) is deprecated. Please use Date#to_fs(#{format.inspect}) instead."
@@ -11,7 +11,18 @@ class DateTime
11
11
  )
12
12
  formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
13
13
  elsif format == NOT_SET
14
- to_default_s
14
+ if formatter = ::Time::DATE_FORMATS[:default]
15
+ ActiveSupport::Deprecation.warn(
16
+ "Using a :default format for DateTime#to_s is deprecated. Please use DateTime#to_fs instead."
17
+ )
18
+ if formatter.respond_to?(:call)
19
+ formatter.call(self).to_s
20
+ else
21
+ strftime(formatter)
22
+ end
23
+ else
24
+ to_default_s
25
+ end
15
26
  else
16
27
  ActiveSupport::Deprecation.warn(
17
28
  "DateTime#to_s(#{format.inspect}) is deprecated. Please use DateTime#to_fs(#{format.inspect}) instead."
@@ -76,19 +76,24 @@ module Enumerable
76
76
  _original_sum_with_required_identity(identity, &block)
77
77
  elsif block_given?
78
78
  map(&block).sum
79
- # we check `first(1) == []` to check if we have an
80
- # empty Enumerable; checking `empty?` would return
81
- # true for `[nil]`, which we want to deprecate to
82
- # keep consistent with Ruby
83
- elsif first.is_a?(Numeric) || first(1) == [] || first.respond_to?(:coerce)
84
- identity ||= 0
85
- _original_sum_with_required_identity(identity, &block)
86
79
  else
87
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
88
- Rails 7.0 has deprecated Enumerable.sum in favor of Ruby's native implementation available since 2.4.
89
- Sum of non-numeric elements requires an initial argument.
90
- MSG
91
- inject(:+) || 0
80
+ first = true
81
+
82
+ reduce(nil) do |sum, value|
83
+ if first
84
+ first = false
85
+
86
+ unless value.is_a?(Numeric) || value.respond_to?(:coerce)
87
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
88
+ Rails 7.0 has deprecated Enumerable.sum in favor of Ruby's native implementation available since 2.4.
89
+ Sum of non-numeric elements requires an initial argument.
90
+ MSG
91
+ end
92
+ value
93
+ else
94
+ sum + value
95
+ end
96
+ end || 0
92
97
  end
93
98
  end
94
99
 
@@ -144,8 +149,8 @@ module Enumerable
144
149
  def many?
145
150
  cnt = 0
146
151
  if block_given?
147
- any? do |element, *args|
148
- cnt += 1 if yield element, *args
152
+ any? do |*args|
153
+ cnt += 1 if yield(*args)
149
154
  cnt > 1
150
155
  end
151
156
  else
@@ -245,7 +250,7 @@ module Enumerable
245
250
  # If the +series+ include keys that have no corresponding element in the Enumerable, these are ignored.
246
251
  # If the Enumerable has additional elements that aren't named in the +series+, these are not included in the result.
247
252
  def in_order_of(key, series)
248
- group_by(&key).values_at(*series).flatten.compact
253
+ group_by(&key).values_at(*series).flatten(1).compact
249
254
  end
250
255
 
251
256
  # Returns the sole item in the enumerable. If there are no items, or more
@@ -72,8 +72,6 @@ class Hash
72
72
  #
73
73
  # The string pairs "key=value" that conform the query string
74
74
  # are sorted lexicographically in ascending order.
75
- #
76
- # This method is also aliased as +to_param+.
77
75
  def to_query(namespace = nil)
78
76
  query = filter_map do |key, value|
79
77
  unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
@@ -10,7 +10,14 @@ module ActiveSupport
10
10
  )
11
11
  formatter.call(first, last)
12
12
  elsif format == NOT_SET
13
- super()
13
+ if formatter = RangeWithFormat::RANGE_FORMATS[:default]
14
+ ActiveSupport::Deprecation.warn(
15
+ "Using a :default format for Range#to_s is deprecated. Please use Range#to_fs instead."
16
+ )
17
+ formatter.call(first, last)
18
+ else
19
+ super()
20
+ end
14
21
  else
15
22
  ActiveSupport::Deprecation.warn(
16
23
  "Range#to_s(#{format.inspect}) is deprecated. Please use Range#to_fs(#{format.inspect}) instead."
@@ -97,8 +97,6 @@ class String
97
97
  # 'active_record/errors'.camelize # => "ActiveRecord::Errors"
98
98
  # 'active_record/errors'.camelize(:lower) # => "activeRecord::Errors"
99
99
  #
100
- # +camelize+ is also aliased as +camelcase+.
101
- #
102
100
  # See ActiveSupport::Inflector.camelize.
103
101
  def camelize(first_letter = :upper)
104
102
  case first_letter
@@ -124,8 +122,6 @@ class String
124
122
  # 'x-men: the last stand'.titleize # => "X Men: The Last Stand"
125
123
  # 'string_ending_with_id'.titleize(keep_id_suffix: true) # => "String Ending With Id"
126
124
  #
127
- # +titleize+ is also aliased as +titlecase+.
128
- #
129
125
  # See ActiveSupport::Inflector.titleize.
130
126
  def titleize(keep_id_suffix: false)
131
127
  ActiveSupport::Inflector.titleize(self, keep_id_suffix: keep_id_suffix)
@@ -11,7 +11,18 @@ class Time
11
11
  )
12
12
  formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
13
13
  elsif format == NOT_SET
14
- to_default_s
14
+ if formatter = ::Time::DATE_FORMATS[:default]
15
+ ActiveSupport::Deprecation.warn(
16
+ "Using a :default format for Time#to_s is deprecated. Please use Time#to_fs instead."
17
+ )
18
+ if formatter.respond_to?(:call)
19
+ formatter.call(self).to_s
20
+ else
21
+ strftime(formatter)
22
+ end
23
+ else
24
+ to_default_s
25
+ end
15
26
  else
16
27
  ActiveSupport::Deprecation.warn(
17
28
  "Time#to_s(#{format.inspect}) is deprecated. Please use Time#to_fs(#{format.inspect}) instead."
@@ -76,7 +76,7 @@ module ActiveSupport
76
76
  end
77
77
 
78
78
  def options
79
- @options ||= ActiveSupport::InheritableOptions.new(deep_transform(config))
79
+ @options ||= deep_transform(config)
80
80
  end
81
81
 
82
82
  def deserialize(config)
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ gem "listen", "~> 3.5"
4
+ require "listen"
5
+
3
6
  require "set"
4
7
  require "pathname"
5
8
  require "concurrent/atomic/atomic_boolean"
6
- require "listen"
7
9
  require "active_support/fork_tracker"
8
10
 
9
11
  module ActiveSupport
@@ -43,6 +45,10 @@ module ActiveSupport
43
45
  ObjectSpace.define_finalizer(self, @core.finalizer)
44
46
  end
45
47
 
48
+ def inspect
49
+ "#<ActiveSupport::EventedFileUpdateChecker:#{object_id} @files=#{@core.files.to_a.inspect}"
50
+ end
51
+
46
52
  def updated?
47
53
  if @core.restart?
48
54
  @core.thread_safely(&:restart)
@@ -66,7 +72,7 @@ module ActiveSupport
66
72
  end
67
73
 
68
74
  class Core
69
- attr_reader :updated
75
+ attr_reader :updated, :files
70
76
 
71
77
  def initialize(files, dirs)
72
78
  @files = files.map { |file| Pathname(file).expand_path }.to_set
@@ -84,6 +90,10 @@ module ActiveSupport
84
90
  @mutex = Mutex.new
85
91
 
86
92
  start
93
+ # inotify / FSEvents file descriptors are inherited on fork, so
94
+ # we need to reopen them otherwise only the parent or the child
95
+ # will be notified.
96
+ # FIXME: this callback is keeping a reference on the instance
87
97
  @after_fork = ActiveSupport::ForkTracker.after_fork { start }
88
98
  end
89
99
 
@@ -105,6 +115,11 @@ module ActiveSupport
105
115
  @dtw, @missing = [*@dtw, *@missing].partition(&:exist?)
106
116
  @listener = @dtw.any? ? Listen.to(*@dtw, &method(:changed)) : nil
107
117
  @listener&.start
118
+
119
+ # Wait for the listener to be ready to avoid race conditions
120
+ # Unfortunately this isn't quite enough on macOS because the Darwin backend
121
+ # has an extra private thread we can't wait on.
122
+ @listener&.wait_for_state(:processing_events)
108
123
  end
109
124
 
110
125
  def stop
@@ -9,8 +9,8 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
- TINY = 5
13
- PRE = "1"
12
+ TINY = 7
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
  result.tr!("_", " ")
138
138
  result.lstrip!
139
- unless keep_id_suffix
139
+ if !keep_id_suffix && lower_case_and_underscored_word&.end_with?("_id")
140
140
  result.delete_suffix!(" id")
141
141
  end
142
142
 
@@ -172,8 +172,6 @@ module ActiveSupport
172
172
  # optional parameter +keep_id_suffix+ to true.
173
173
  # By default, this parameter is false.
174
174
  #
175
- # +titleize+ is also aliased as +titlecase+.
176
- #
177
175
  # titleize('man from the boondocks') # => "Man From The Boondocks"
178
176
  # titleize('x-men: the last stand') # => "X Men: The Last Stand"
179
177
  # titleize('TheManWithoutAPast') # => "The Man Without A Past"
@@ -221,7 +221,14 @@ module ActiveSupport
221
221
  )
222
222
  formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
223
223
  elsif format == NOT_SET
224
- "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby Time#to_s format
224
+ if formatter = ::Time::DATE_FORMATS[:default]
225
+ ActiveSupport::Deprecation.warn(
226
+ "Using a :default format for TimeWithZone#to_s is deprecated. Please use TimeWithZone#to_fs instead."
227
+ )
228
+ formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
229
+ else
230
+ "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby Time#to_s format
231
+ end
225
232
  else
226
233
  ActiveSupport::Deprecation.warn(
227
234
  "TimeWithZone#to_s(#{format.inspect}) is deprecated. Please use TimeWithZone#to_fs(#{format.inspect}) instead."
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.0.5.1
4
+ version: 7.0.7
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: 2023-06-26 00:00:00.000000000 Z
11
+ date: 2023-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -359,10 +359,10 @@ licenses:
359
359
  - MIT
360
360
  metadata:
361
361
  bug_tracker_uri: https://github.com/rails/rails/issues
362
- changelog_uri: https://github.com/rails/rails/blob/v7.0.5.1/activesupport/CHANGELOG.md
363
- documentation_uri: https://api.rubyonrails.org/v7.0.5.1/
362
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.7/activesupport/CHANGELOG.md
363
+ documentation_uri: https://api.rubyonrails.org/v7.0.7/
364
364
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
365
- source_code_uri: https://github.com/rails/rails/tree/v7.0.5.1/activesupport
365
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.7/activesupport
366
366
  rubygems_mfa_required: 'true'
367
367
  post_install_message:
368
368
  rdoc_options:
@@ -381,7 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
381
381
  - !ruby/object:Gem::Version
382
382
  version: '0'
383
383
  requirements: []
384
- rubygems_version: 3.3.3
384
+ rubygems_version: 3.4.10
385
385
  signing_key:
386
386
  specification_version: 4
387
387
  summary: A toolkit of support libraries and Ruby core extensions extracted from the