From 24088498f8754cf8a2d527e7a90df60908cf8403 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sat, 24 Oct 2026 07:41:54 -0700 Subject: [PATCH] Drop support for Ruby < 2.7 Ruby 2.4, 2.5, and 2.6 reached end of life between 2020 and 2022. - Set required_ruby_version to >= 2.7 so Bundler won't resolve the gem on older Rubies - Remove 2.4, 2.5, and 2.6 from the Docker and Podman CI matrices - Call URI.open directly in Image.import. The Kernel#open fallback was only needed before URI.open existed (Ruby 2.5) Signed-off-by: Tim Smith --- .github/workflows/unit_test.yml | 6 ------ TESTING.md | 2 +- docker-api.gemspec | 1 + lib/docker/image.rb | 9 +-------- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 7a0a5f18..2529341c 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -22,9 +22,6 @@ jobs: - 3.1 - '3.0' - 2.7 - - 2.6 - - 2.5 - - 2.4 docker_version: - ':28.' - ':29.' @@ -80,9 +77,6 @@ jobs: - 3.1 - '3.0' - 2.7 - - 2.6 - - 2.5 - - 2.4 fail-fast: false steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/TESTING.md b/TESTING.md index 4ea91c20..3d49ef65 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,6 +1,6 @@ # Prerequisites To develop on this gem, you must the following installed: -* a Ruby 2.4+ environment with `bundler` +* a Ruby 2.7+ environment with `bundler` ```shell $ gem install bundler ``` diff --git a/docker-api.gemspec b/docker-api.gemspec index 3c3385fb..9ce7f3b8 100644 --- a/docker-api.gemspec +++ b/docker-api.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |gem| 'source_code_uri' => 'https://github.com/upserve/docker-api', 'rubygems_mfa_required' => 'true' } + gem.required_ruby_version = '>= 2.7' gem.add_dependency 'excon', '>= 0.64.0' # base64 stopped being a default gem in Ruby 3.4, so `require 'base64'` in # lib/docker.rb raises LoadError under Bundler unless it is declared. diff --git a/lib/docker/image.rb b/lib/docker/image.rb index 8acadbc2..dbb06f0e 100644 --- a/lib/docker/image.rb +++ b/lib/docker/image.rb @@ -240,14 +240,7 @@ def search(query = {}, connection = Docker.connection, creds = nil) def import(imp, opts = {}, conn = Docker.connection) require 'open-uri' - # This differs after Ruby 2.4 - if URI.public_methods.include?(:open) - munged_open = URI.method(:open) - else - munged_open = self.method(:open) - end - - munged_open.call(imp) do |io| + URI.open(imp) do |io| import_stream(opts, conn) do io.read(Excon.defaults[:chunk_size]).to_s end