Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔇 Fix ruby 2.7 warnings #304

Merged
merged 3 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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