Skip to content

Commit

Permalink
🔀 Merge pull request #304 from ruby/fix-ruby-2.7-warnings
Browse files Browse the repository at this point in the history
🔇 Fix ruby 2.7 warnings
  • Loading branch information
nevans authored Jun 22, 2024
2 parents 958e872 + c921580 commit f1762fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions lib/net/imap/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Config
def self.default; @default end

# The global config object. Also available from Net::IMAP.config.
def self.global; @global end
def self.global; @global if defined?(@global) end

# A hash of hard-coded configurations, indexed by version number.
def self.version_defaults; @version_defaults end
Expand All @@ -149,12 +149,11 @@ def self.version_defaults; @version_defaults end
#
# Given a config, returns that same config.
def self.[](config)
if config.is_a?(Config) || config.nil? && global.nil?
config
elsif config.respond_to?(:to_hash)
new(global, **config).freeze
if config.is_a?(Config) then config
elsif config.nil? && global.nil? then nil
elsif config.respond_to?(:to_hash) then new(global, **config).freeze
else
version_defaults.fetch(config) {
version_defaults.fetch(config) do
case config
when Numeric
raise RangeError, "unknown config version: %p" % [config]
Expand All @@ -165,7 +164,7 @@ def self.[](config)
config.class, Config
]
end
}
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/net/imap/test_deprecated_client_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InitializeTests < DeprecatedClientOptionsTest

test "Convert obsolete options hash to keywords" do
run_fake_server_in_thread do |server|
with_client(server.host, {port: server.port, ssl: false}) do |client|
with_client(server.host, {port: server.port, ssl: false}, **{}) do |client|
assert_equal server.host, client.host
assert_equal server.port, client.port
assert_equal false, client.ssl_ctx_params
Expand Down
2 changes: 1 addition & 1 deletion test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def tcp_socket(host, port)
t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
}
#super
s = Socket.tcp(host, port, :connect_timeout => @open_timeout)
s = Socket.tcp(host, port)
@@h[:in_tcp_socket_2] = {
s: s.inspect,
local_address: s.local_address,
Expand Down

0 comments on commit f1762fd

Please sign in to comment.