From e2b341a94a6d12e72b1e5fe557c7163fc59dc853 Mon Sep 17 00:00:00 2001 From: nick evans Date: Fri, 21 Jun 2024 20:39:37 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20ruby=202.7=20compatibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ruby 2.7 didn't have: * Hash#except. * pattern matching statements: "foo => a | b | c" --- lib/net/imap/config.rb | 6 ++++-- test/net/imap/test_config.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/net/imap/config.rb b/lib/net/imap/config.rb index 33e81c89..87898e6f 100644 --- a/lib/net/imap/config.rb +++ b/lib/net/imap/config.rb @@ -281,7 +281,9 @@ def with(**attrs) def load_defaults(version) [Numeric, Symbol, String].any? { _1 === version } or raise ArgumentError, "expected number or symbol, got %p" % [version] - update(**Config[version].to_h.except(*DEFAULT_TO_INHERIT)) + config = Config[version] + defaults = config.to_h.reject {|k,v| DEFAULT_TO_INHERIT.include?(k) } + update(**defaults) end # :call-seq: to_h -> hash @@ -300,7 +302,7 @@ def to_h; data.members.to_h { [_1, send(_1)] } end @global = default.new version_defaults[0.4] = Config[ - default.to_h.except(*DEFAULT_TO_INHERIT) + default.to_h.reject {|k,v| DEFAULT_TO_INHERIT.include?(k) } ] version_defaults[0] = Config[0.4].dup.update( diff --git a/test/net/imap/test_config.rb b/test/net/imap/test_config.rb index df88f56d..403270f8 100644 --- a/test/net/imap/test_config.rb +++ b/test/net/imap/test_config.rb @@ -137,7 +137,7 @@ class ConfigTest < Test::Unit::TestCase test ".version_defaults are all frozen, and inherit debug from global" do Config.version_defaults.each do |name, config| - name => 0 | Float | Symbol + assert [0, Float, Symbol].any? { _1 === name } assert_kind_of Config, config assert config.frozen?, "#{name} isn't frozen" assert config.inherited?(:debug), "#{name} doesn't inherit debug"