From cf258bbb719f1c8dca4ad73a2eabb130f4c88864 Mon Sep 17 00:00:00 2001 From: Robert Haines Date: Tue, 11 Jan 2022 22:01:49 +0000 Subject: [PATCH] Move to ruby 2.5 as the earliest supported version. 2.4 is nearly two years beyond EOL now. Closes #484. --- .github/workflows/lint.yml | 2 +- .github/workflows/tests.yml | 6 +++--- .rubocop.yml | 2 +- .simplecov | 2 +- lib/zip/file.rb | 12 +++++------- rubyzip.gemspec | 2 +- test/filesystem/file_nonmutating_test.rb | 2 +- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dccec7f..66c262f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: - name: Install and set up ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 2.4 + ruby-version: '2.5' bundler-cache: true - name: Rubocop diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d9e6147..49fa1a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,12 +8,12 @@ jobs: fail-fast: false matrix: os: [ubuntu] - ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1', head, jruby, jruby-head, truffleruby, truffleruby-head] + ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', head, jruby, jruby-head, truffleruby, truffleruby-head] include: - os: macos - ruby: 2.4 + ruby: '2.5' - os: windows - ruby: 2.4 + ruby: '2.5' runs-on: ${{ matrix.os }}-latest continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.os == 'windows' }} steps: diff --git a/.rubocop.yml b/.rubocop.yml index c6d2a51..1997fe3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,7 +7,7 @@ inherit_from: .rubocop_todo.yml # Set this to the minimum supported ruby in the gemspec. Otherwise # we get errors if our ruby version doesn't match. AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.5 NewCops: enable # Allow this in this file because adding the extra lines is pointless. diff --git a/.simplecov b/.simplecov index 611a952..91415df 100644 --- a/.simplecov +++ b/.simplecov @@ -17,6 +17,6 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new( ) SimpleCov.start do - # enable_coverage :branch <-- Re-enable this when we move to ruby ~> 2.5. + enable_coverage :branch add_filter ['/test/', '/samples/'] end diff --git a/lib/zip/file.rb b/lib/zip/file.rb index ddb5e73..661609b 100644 --- a/lib/zip/file.rb +++ b/lib/zip/file.rb @@ -406,14 +406,12 @@ module Zip def on_success_replace dirname, basename = ::File.split(name) ::Dir::Tmpname.create(basename, dirname) do |tmp_filename| - begin - if yield tmp_filename - ::File.rename(tmp_filename, name) - ::File.chmod(@file_permissions, name) unless @create - end - ensure - ::File.unlink(tmp_filename) if ::File.exist?(tmp_filename) + if yield tmp_filename + ::File.rename(tmp_filename, name) + ::File.chmod(@file_permissions, name) unless @create end + ensure + ::File.unlink(tmp_filename) if ::File.exist?(tmp_filename) end end end diff --git a/rubyzip.gemspec b/rubyzip.gemspec index 1a913c0..5287d0c 100644 --- a/rubyzip.gemspec +++ b/rubyzip.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |s| 'wiki_uri' => 'https://github.com/rubyzip/rubyzip/wiki' } - s.required_ruby_version = '>= 2.4' + s.required_ruby_version = '>= 2.5' s.add_development_dependency 'minitest', '~> 5.4' s.add_development_dependency 'rake', '~> 12.3.3' diff --git a/test/filesystem/file_nonmutating_test.rb b/test/filesystem/file_nonmutating_test.rb index d4007e6..0e93b64 100644 --- a/test/filesystem/file_nonmutating_test.rb +++ b/test/filesystem/file_nonmutating_test.rb @@ -445,7 +445,7 @@ class FileNonmutatingTest < MiniTest::Test '*/foo/**/*.txt' => ['globTest/foo/bar/baz/foo.txt'] }.each do |spec, expected_results| results = zf.glob(spec) - assert(results.all? { |entry| entry.kind_of? ::Zip::Entry }) + assert(results.all?(::Zip::Entry)) result_strings = results.map(&:to_s) missing_matches = expected_results - result_strings