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. `File.dirname(__FILE__)` is
'.'.

`__FILE__` is '(eval at /path/Rakefile:linenumber)' with Ruby >= 3.3.
`File.dirname(__FILE__)` is '(eval at /path'.
  • Loading branch information
philr committed Dec 22, 2023
1 parent 8704e26 commit 84c34f5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 84c34f5

Please sign in to comment.