Skip to content

Commit

Permalink
Fix loading the gemspec file from rake with Ruby 3.3.
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
philr committed Dec 16, 2023
1 parent f0f0a17 commit e194923
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion putty-key.gemspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit e194923

Please sign in to comment.