activesupport 6.1.0.rc1 → 6.1.2.1

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: 7e3b1535797c76aeec9ce935c778ef87ef0607bf156916734c1b9ad789f4666d
4
- data.tar.gz: aaa132d9325b4dcefabe7e4b379a8709cc7cfcdbca7e0a663b63d75e213353c5
3
+ metadata.gz: 97774e161cff3d918beb8ca21c3107ca7214b3004464d277094f28a9a558f573
4
+ data.tar.gz: baf4a4759c102fcd296366307d4f9ddbd8997d0de8214b48935d0a66d8d57caa
5
5
  SHA512:
6
- metadata.gz: 400e5ad4e88a2c8a82c1514b5c5ac9c30edd0e4fed6b22348ec11ab408db5478dad0dfdc1711e3f70b1a98343071583de1d4ad98cdce1bd7860008c229676d8a
7
- data.tar.gz: 2481dadc58812a57876a1d2ed559adeaaba012d144a8e2f7f3076cb51ad7ec2da63224f334d7fdfac8e3dd00fab2c6b8bff8f25efd3622f67a6bcb2f9cd9c674
6
+ metadata.gz: 2f25f2d48e2a1a190567b30dcb34aa420b935322bde9b4c2ce91441955c3b356a3ca9d8780ed33e3079878e3711c5df787bb3a6066febda23251b568f706a85d
7
+ data.tar.gz: 0fae256e4975bff42a8795b55f1f3625ab0f9c69f632bf9db6e686e306bc4009307c2803643de3c21562116454bfb8494ae804de556a01489bada03c3e36c08e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,57 @@
1
- ## Rails 6.1.0.rc1 (November 02, 2020) ##
1
+ ## Rails 6.1.2.1 (February 10, 2021) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 6.1.2 (February 09, 2021) ##
7
+
8
+ * `ActiveSupport::Cache::MemCacheStore` now accepts an explicit `nil` for its `addresses` argument.
9
+
10
+ ```ruby
11
+ config.cache_store = :mem_cache_store, nil
12
+
13
+ # is now equivalent to
14
+
15
+ config.cache_store = :mem_cache_store
16
+
17
+ # and is also equivalent to
18
+
19
+ config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
20
+
21
+ # which is the fallback behavior of Dalli
22
+ ```
23
+
24
+ This helps those migrating from `:dalli_store`, where an explicit `nil` was permitted.
25
+
26
+ *Michael Overmeyer*
27
+
28
+
29
+ ## Rails 6.1.1 (January 07, 2021) ##
30
+
31
+ * Change `IPAddr#to_json` to match the behavior of the json gem returning the string representation
32
+ instead of the instance variables of the object.
33
+
34
+ Before:
35
+
36
+ ```ruby
37
+ IPAddr.new("127.0.0.1").to_json
38
+ # => "{\"addr\":2130706433,\"family\":2,\"mask_addr\":4294967295}"
39
+ ```
40
+
41
+ After:
42
+
43
+ ```ruby
44
+ IPAddr.new("127.0.0.1").to_json
45
+ # => "\"127.0.0.1\""
46
+ ```
47
+
48
+
49
+ ## Rails 6.1.0 (December 09, 2020) ##
50
+
51
+ * Ensure `MemoryStore` disables compression by default. Reverts behavior of
52
+ `MemoryStore` to its prior rails `5.1` behavior.
53
+
54
+ *Max Gurewitz*
2
55
 
3
56
  * Calling `iso8601` on negative durations retains the negative sign on individual
4
57
  digits instead of prepending it.
data/README.rdoc CHANGED
@@ -15,7 +15,7 @@ The latest version of Active Support can be installed with RubyGems:
15
15
 
16
16
  Source code can be downloaded as part of the Rails project on GitHub:
17
17
 
18
- * https://github.com/rails/rails/tree/master/activesupport
18
+ * https://github.com/rails/rails/tree/main/activesupport
19
19
 
20
20
 
21
21
  == License
@@ -324,7 +324,7 @@ module ActiveSupport
324
324
 
325
325
  entry = nil
326
326
  instrument(:read, name, options) do |payload|
327
- cached_entry = read_entry(key, **options) unless options[:force]
327
+ cached_entry = read_entry(key, **options, event: payload) unless options[:force]
328
328
  entry = handle_expired_entry(cached_entry, key, options)
329
329
  entry = nil if entry && entry.mismatched?(normalize_version(name, options))
330
330
  payload[:super_operation] = :fetch if payload
@@ -358,7 +358,7 @@ module ActiveSupport
358
358
  version = normalize_version(name, options)
359
359
 
360
360
  instrument(:read, name, options) do |payload|
361
- entry = read_entry(key, **options)
361
+ entry = read_entry(key, **options, event: payload)
362
362
 
363
363
  if entry
364
364
  if entry.expired?
@@ -390,7 +390,7 @@ module ActiveSupport
390
390
  options = merged_options(options)
391
391
 
392
392
  instrument :read_multi, names, options do |payload|
393
- read_multi_entries(names, **options).tap do |results|
393
+ read_multi_entries(names, **options, event: payload).tap do |results|
394
394
  payload[:hits] = results.keys
395
395
  end
396
396
  end
@@ -500,8 +500,8 @@ module ActiveSupport
500
500
  def exist?(name, options = nil)
501
501
  options = merged_options(options)
502
502
 
503
- instrument(:exist?, name) do
504
- entry = read_entry(normalize_key(name, options), **options)
503
+ instrument(:exist?, name) do |payload|
504
+ entry = read_entry(normalize_key(name, options), **options, event: payload)
505
505
  (entry && !entry.expired? && !entry.mismatched?(normalize_version(name, options))) || false
506
506
  end
507
507
  end
@@ -64,7 +64,7 @@ module ActiveSupport
64
64
  def self.build_mem_cache(*addresses) # :nodoc:
65
65
  addresses = addresses.flatten
66
66
  options = addresses.extract_options!
67
- addresses = nil if addresses.empty?
67
+ addresses = nil if addresses.compact.empty?
68
68
  pool_options = retrieve_pool_options(options)
69
69
 
70
70
  if pool_options.empty?
@@ -185,10 +185,14 @@ module ActiveSupport
185
185
  # before applying the regular expression to ensure we are escaping all
186
186
  # characters properly.
187
187
  def normalize_key(key, options)
188
- key = super.dup
189
- key = key.force_encoding(Encoding::ASCII_8BIT)
190
- key = key.gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
191
- key = "#{key[0, 213]}:md5:#{ActiveSupport::Digest.hexdigest(key)}" if key.size > 250
188
+ key = super
189
+
190
+ if key
191
+ key = key.dup.force_encoding(Encoding::ASCII_8BIT)
192
+ key = key.gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
193
+ key = "#{key[0, 213]}:md5:#{ActiveSupport::Digest.hexdigest(key)}" if key.size > 250
194
+ end
195
+
192
196
  key
193
197
  end
194
198
 
@@ -16,6 +16,12 @@ module ActiveSupport
16
16
  # a cleanup will occur which tries to prune the cache down to three quarters
17
17
  # of the maximum size by removing the least recently used entries.
18
18
  #
19
+ # Unlike other Cache store implementations, MemoryStore does not compress
20
+ # values by default. MemoryStore does not benefit from compression as much
21
+ # as other Store implementations, as it does not send data over a network.
22
+ # However, when compression is enabled, it still pays the full cost of
23
+ # compression in terms of cpu use.
24
+ #
19
25
  # MemoryStore is thread-safe.
20
26
  class MemoryStore < Store
21
27
  module DupCoder # :nodoc:
@@ -37,6 +43,8 @@ module ActiveSupport
37
43
 
38
44
  def initialize(options = nil)
39
45
  options ||= {}
46
+ # Disable compression by default.
47
+ options[:compress] ||= false
40
48
  super(options)
41
49
  @data = {}
42
50
  @max_size = options[:size] || 32.megabytes
@@ -130,7 +130,13 @@ module ActiveSupport
130
130
  private
131
131
  def read_entry(key, **options)
132
132
  if cache = local_cache
133
- cache.fetch_entry(key) { super }
133
+ hit = true
134
+ value = cache.fetch_entry(key) do
135
+ hit = false
136
+ super
137
+ end
138
+ options[:event][:store] = cache.class.name if hit && options[:event]
139
+ value
134
140
  else
135
141
  super
136
142
  end
@@ -102,11 +102,11 @@ module ActiveSupport
102
102
  #
103
103
  # === Prepending concerns
104
104
  #
105
- # Just like `include`, concerns also support `prepend` with a corresponding
106
- # `prepended do` callback. `module ClassMethods` or `class_methods do` are
105
+ # Just like <tt>include</tt>, concerns also support <tt>prepend</tt> with a corresponding
106
+ # <tt>prepended do</tt> callback. <tt>module ClassMethods</tt> or <tt>class_methods do</tt> are
107
107
  # prepended as well.
108
108
  #
109
- # `prepend` is also used for any dependencies.
109
+ # <tt>prepend</tt> is also used for any dependencies.
110
110
  module Concern
111
111
  class MultipleIncludedBlocks < StandardError #:nodoc:
112
112
  def initialize
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Dir.glob(File.expand_path("core_ext/*.rb", __dir__)).each do |path|
3
+ Dir.glob(File.expand_path("core_ext/*.rb", __dir__)).sort.each do |path|
4
4
  require path
5
5
  end
@@ -105,10 +105,10 @@ class Module
105
105
  # * clean up monolithic junk-drawer classes by separating their concerns, and
106
106
  # * stop leaning on protected/private for crude "this is internal stuff" modularity.
107
107
  #
108
- # === Prepending `concerning`
108
+ # === Prepending concerning
109
109
  #
110
- # `concerning` supports a `prepend: true` argument which will `prepend` the
111
- # concern instead of using `include` for it.
110
+ # <tt>concerning</tt> supports a <tt>prepend: true</tt> argument which will <tt>prepend</tt> the
111
+ # concern instead of using <tt>include</tt> for it.
112
112
  module Concerning
113
113
  # Define a new concern and mix it in.
114
114
  def concerning(topic, prepend: false, &block)
@@ -3,6 +3,7 @@
3
3
  # Hack to load json gem first so we can overwrite its to_json.
4
4
  require "json"
5
5
  require "bigdecimal"
6
+ require "ipaddr"
6
7
  require "uri/generic"
7
8
  require "pathname"
8
9
  require "active_support/core_ext/big_decimal/conversions" # for #to_s
@@ -219,6 +220,12 @@ class Pathname #:nodoc:
219
220
  end
220
221
  end
221
222
 
223
+ class IPAddr # :nodoc:
224
+ def as_json(options = nil)
225
+ to_s
226
+ end
227
+ end
228
+
222
229
  class Process::Status #:nodoc:
223
230
  def as_json(options = nil)
224
231
  { exitstatus: exitstatus, pid: pid }
@@ -1,6 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Regexp #:nodoc:
3
+ class Regexp
4
+ # Returns +true+ if the regexp has the multiline flag set.
5
+ #
6
+ # (/./).multiline? # => false
7
+ # (/./m).multiline? # => true
8
+ #
9
+ # Regexp.new(".").multiline? # => false
10
+ # Regexp.new(".", Regexp::MULTILINE).multiline? # => true
4
11
  def multiline?
5
12
  options & MULTILINE == MULTILINE
6
13
  end
@@ -18,6 +18,7 @@ class String
18
18
  # "2012-12-13T06:12".to_time # => 2012-12-13 06:12:00 +0100
19
19
  # "2012-12-13T06:12".to_time(:utc) # => 2012-12-13 06:12:00 UTC
20
20
  # "12/13/2012".to_time # => ArgumentError: argument out of range
21
+ # "1604326192".to_time # => ArgumentError: argument out of range
21
22
  def to_time(form = :local)
22
23
  parts = Date._parse(self, false)
23
24
  used_keys = %i(year mon mday hour min sec sec_fraction offset)
@@ -84,7 +84,7 @@ class ERB
84
84
  # use inside HTML attributes.
85
85
  #
86
86
  # If your JSON is being used downstream for insertion into the DOM, be aware of
87
- # whether or not it is being inserted via +html()+. Most jQuery plugins do this.
87
+ # whether or not it is being inserted via <tt>html()</tt>. Most jQuery plugins do this.
88
88
  # If that is the case, be sure to +html_escape+ or +sanitize+ any user-generated
89
89
  # content returned by your JSON.
90
90
  #
@@ -134,7 +134,7 @@ module ActiveSupport #:nodoc:
134
134
  class SafeBuffer < String
135
135
  UNSAFE_STRING_METHODS = %w(
136
136
  capitalize chomp chop delete delete_prefix delete_suffix
137
- downcase lstrip next reverse rstrip slice squeeze strip
137
+ downcase lstrip next reverse rstrip scrub slice squeeze strip
138
138
  succ swapcase tr tr_s unicode_normalize upcase
139
139
  )
140
140
 
@@ -152,12 +152,12 @@ module ActiveSupport #:nodoc:
152
152
 
153
153
  def [](*args)
154
154
  if html_safe?
155
- new_safe_buffer = super
155
+ new_string = super
156
156
 
157
- if new_safe_buffer
158
- new_safe_buffer.instance_variable_set :@html_safe, true
159
- end
157
+ return unless new_string
160
158
 
159
+ new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
160
+ new_safe_buffer.instance_variable_set :@html_safe, true
161
161
  new_safe_buffer
162
162
  else
163
163
  to_str[*args]
@@ -213,7 +213,8 @@ module ActiveSupport #:nodoc:
213
213
  end
214
214
 
215
215
  def *(*)
216
- new_safe_buffer = super
216
+ new_string = super
217
+ new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
217
218
  new_safe_buffer.instance_variable_set(:@html_safe, @html_safe)
218
219
  new_safe_buffer
219
220
  end
@@ -42,8 +42,14 @@ class Time
42
42
 
43
43
  # Layers additional behavior on Time.at so that ActiveSupport::TimeWithZone and DateTime
44
44
  # instances can be used when called with a single argument
45
- def at_with_coercion(*args)
46
- return at_without_coercion(*args) if args.size != 1
45
+ def at_with_coercion(*args, **kwargs)
46
+ if args.size != 1
47
+ if kwargs.empty?
48
+ return at_without_coercion(*args)
49
+ else
50
+ return at_without_coercion(*args, **kwargs)
51
+ end
52
+ end
47
53
 
48
54
  # Time.at can be called with a time or numerical value
49
55
  time_or_number = args.first
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "time"
3
4
  require "active_support/inflector/methods"
4
5
  require "active_support/values/time_zone"
5
6
 
@@ -6,8 +6,8 @@ module ActiveSupport::CurrentAttributes::TestHelper # :nodoc:
6
6
  super
7
7
  end
8
8
 
9
- def before_teardown
10
- ActiveSupport::CurrentAttributes.reset_all
9
+ def after_teardown
11
10
  super
11
+ ActiveSupport::CurrentAttributes.reset_all
12
12
  end
13
13
  end
@@ -375,7 +375,12 @@ module ActiveSupport #:nodoc:
375
375
  require_or_load(path || file_name)
376
376
  rescue LoadError => load_error
377
377
  if file_name = load_error.message[/ -- (.*?)(\.rb)?$/, 1]
378
- load_error.message.replace(message % file_name)
378
+ load_error_message = if load_error.respond_to?(:original_message)
379
+ load_error.original_message
380
+ else
381
+ load_error.message
382
+ end
383
+ load_error_message.replace(message % file_name)
379
384
  load_error.copy_blame!(load_error)
380
385
  end
381
386
  raise
@@ -20,7 +20,11 @@ module ActiveSupport
20
20
 
21
21
  module CoreExtPrivate
22
22
  include CoreExt
23
- private :fork
23
+
24
+ private
25
+ def fork(*)
26
+ super
27
+ end
24
28
  end
25
29
 
26
30
  @pid = Process.pid
@@ -9,8 +9,8 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 1
12
- TINY = 0
13
- PRE = "rc1"
12
+ TINY = 2
13
+ PRE = "1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -363,8 +363,14 @@ module ActiveSupport
363
363
  end
364
364
 
365
365
  private
366
- def convert_key(key)
367
- key.kind_of?(Symbol) ? key.to_s : key
366
+ if Symbol.method_defined?(:name)
367
+ def convert_key(key)
368
+ key.kind_of?(Symbol) ? key.name : key
369
+ end
370
+ else
371
+ def convert_key(key)
372
+ key.kind_of?(Symbol) ? key.to_s : key
373
+ end
368
374
  end
369
375
 
370
376
  def convert_value(value, conversion: nil)
@@ -14,12 +14,12 @@ module ActiveSupport
14
14
  end
15
15
 
16
16
  module ClassMethods
17
- # Rescue exceptions raised in controller actions.
17
+ # Registers exception classes with a handler to be called by <tt>rescue_with_handler</tt>.
18
18
  #
19
19
  # <tt>rescue_from</tt> receives a series of exception classes or class
20
- # names, and a trailing <tt>:with</tt> option with the name of a method
21
- # or a Proc object to be called to handle them. Alternatively a block can
22
- # be given.
20
+ # names, and an exception handler specified by a trailing <tt>:with</tt>
21
+ # option containing the name of a method or a Proc object. Alternatively, a block
22
+ # can be given as the handler.
23
23
  #
24
24
  # Handlers that take one argument will be called with the exception, so
25
25
  # that the exception can be inspected when dealing with it.
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: 6.1.0.rc1
4
+ version: 6.1.2.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: 2020-11-02 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -357,10 +357,10 @@ licenses:
357
357
  - MIT
358
358
  metadata:
359
359
  bug_tracker_uri: https://github.com/rails/rails/issues
360
- changelog_uri: https://github.com/rails/rails/blob/v6.1.0.rc1/activesupport/CHANGELOG.md
361
- documentation_uri: https://api.rubyonrails.org/v6.1.0.rc1/
360
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.2.1/activesupport/CHANGELOG.md
361
+ documentation_uri: https://api.rubyonrails.org/v6.1.2.1/
362
362
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
363
- source_code_uri: https://github.com/rails/rails/tree/v6.1.0.rc1/activesupport
363
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.2.1/activesupport
364
364
  post_install_message:
365
365
  rdoc_options:
366
366
  - "--encoding"
@@ -374,11 +374,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
374
374
  version: 2.5.0
375
375
  required_rubygems_version: !ruby/object:Gem::Requirement
376
376
  requirements:
377
- - - ">"
377
+ - - ">="
378
378
  - !ruby/object:Gem::Version
379
- version: 1.3.1
379
+ version: '0'
380
380
  requirements: []
381
- rubygems_version: 3.1.4
381
+ rubygems_version: 3.0.3
382
382
  signing_key:
383
383
  specification_version: 4
384
384
  summary: A toolkit of support libraries and Ruby core extensions extracted from the