From e1949234a208881cbe07c6d99a3f26935f9b129c Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Sat, 16 Dec 2023 19:59:34 +0000 Subject: [PATCH] Fix loading the gemspec file from rake with Ruby 3.3. Calculating the current directory name from within the gemspec would fail. `__FILE__` was '(eval)' with Ruby < 3.3 and '(eval at /path/Rakefile:linenumber)' with Ruby >= 3.3. '(eval)' is treated as the current directory ('.') by File.dirname, etc. '(eval at /path/Rakefile:linenumber)' is treated as '(eval at /path'. --- Rakefile | 4 ++-- putty-key.gemspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 439a877..420c0ac 100644 --- a/Rakefile +++ b/Rakefile @@ -4,11 +4,11 @@ require 'rubygems/package_task' require 'rake/testtask' BASE_DIR = File.expand_path(File.dirname(__FILE__)) +GEMSPEC_PATH = File.join(BASE_DIR, 'putty-key.gemspec') +spec = TOPLEVEL_BINDING.eval(File.read(GEMSPEC_PATH), GEMSPEC_PATH) task :default => :test -spec = eval(File.read('putty-key.gemspec')) - # Attempt to find the private key and return a spec with added options for # signing the gem if found. def add_signing_key(spec) diff --git a/putty-key.gemspec b/putty-key.gemspec index d046a6e..eac9165 100644 --- a/putty-key.gemspec +++ b/putty-key.gemspec @@ -1,4 +1,4 @@ -require File.expand_path(File.join('..', 'lib', 'putty', 'key', 'version'), __FILE__) +require_relative 'lib/putty/key/version' Gem::Specification.new do |s| s.name = 'putty-key'