Skip to content

Commit 1f6f6bc

Browse files
committed
🐛 Fix loading gem specification externally
1 parent b14bb9b commit 1f6f6bc

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77

88
## [Unreleased](https://github.com/panorama-ed/memo_wise/compare/v1.13.0...HEAD)
99

10-
**Gem enhancements:** none
10+
**Gem enhancements:**
11+
12+
- Fixed issue with external tools loading `memo_wise.gemspec` from different directories [[#397]](https://github.com/panorama-ed/memo_wise/pull/397))
1113

1214
_No breaking changes!_
1315

memo_wise.gemspec

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ Gem::Specification.new do |spec|
1414
# because the latter only loads a file once, and so by undefining the
1515
# `VERSION` constant we can make it difficult to access that value again
1616
# later. For more context, see: https://github.com/panorama-ed/memo_wise/pull/370#issuecomment-2560268423
17-
spec.version = Module.new.tap do |mod|
18-
# NOTE: We fully qualify `Kernel` here because Rubygems defines its own
19-
# `load` method, which is used by default when this code is executed by
20-
# `gem build memo_wise.gemspec`. That `load` method does not support the
21-
# optional "wrap" parameter we pass through as `mod`. For more context, see:
22-
# https://github.com/simplecov-ruby/simplecov/issues/557#issuecomment-2630782358
23-
Kernel.load("lib/memo_wise/version.rb", mod)
24-
end::MemoWise::VERSION
17+
# NOTE: We fully qualify `Kernel` here because Rubygems defines its own
18+
# `load` method, which is used by default when this code is executed by
19+
# `gem build memo_wise.gemspec`. That `load` method does not support the
20+
# optional "wrap" parameter we pass through as `mod`. For more context, see:
21+
# https://github.com/simplecov-ruby/simplecov/issues/557#issuecomment-2630782358
22+
spec.version = Module.new.tap { |mod| Kernel.load("#{__dir__}/lib/memo_wise/version.rb", mod) }::MemoWise::VERSION
2523
spec.summary = "The wise choice for Ruby memoization"
2624
spec.homepage = "https://github.com/panorama-ed/memo_wise"
2725
spec.license = "MIT"

0 commit comments

Comments
 (0)