From 84c34f5cfd2ce7ccb0878ae41448824cdf447fcb Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Fri, 22 Dec 2023 20:15:52 +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. `File.dirname(__FILE__)` is '.'. `__FILE__` is '(eval at /path/Rakefile:linenumber)' with Ruby >= 3.3. `File.dirname(__FILE__)` is '(eval at /path'. --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 0215ce1..1af4c40 100644 --- a/Rakefile +++ b/Rakefile @@ -16,6 +16,8 @@ LIB_DIR = File.join(BASE_DIR, 'lib') BUILD_TZ_MODULES_DIR = File.join(BASE_DIR, '.build_tz_modules') DATA_OUTPUT_DIR = File.join(BASE_DIR, 'lib', 'tzinfo', 'data') +GEMSPEC_PATH = File.join(BASE_DIR, 'tzinfo-data.gemspec') + TZDB_DIR = 'tzdb' TZDB_GPG_KEYRING = 'gpg.keyring' TZDB_GPG_KEYRING_PATH = File.join(TZDB_DIR, TZDB_GPG_KEYRING) @@ -98,7 +100,7 @@ end task :default => [:test] -spec = eval(File.read('tzinfo-data.gemspec')) +spec = TOPLEVEL_BINDING.eval(File.read(GEMSPEC_PATH), GEMSPEC_PATH) class TZInfoPackageTask < Gem::PackageTask alias_method :orig_sh, :sh