Skip to content

Commit 5f4146a

Browse files
committed
🧑‍💻 Improved loading of version.rb
- panorama-ed/memo_wise#370 (comment)
1 parent 9bd13dc commit 5f4146a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

version_gem.gemspec

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# frozen_string_literal: true
22

3-
# Get the GEMFILE_VERSION without *require* "my_gem/version", for code coverage accuracy
4-
# See: https://github.com/simplecov-ruby/simplecov/issues/557#issuecomment-2630782358
5-
# Kernel.load because load is overloaded in RubyGems during gemspec evaluation
6-
Kernel.load("lib/version_gem/version.rb")
7-
gem_version = VersionGem::Version::VERSION
8-
VersionGem::Version.send(:remove_const, :VERSION)
9-
103
Gem::Specification.new do |spec|
114
# Linux distros may package ruby gems differently,
125
# and securely certify them independently via alternate package management systems.
@@ -26,6 +19,9 @@ Gem::Specification.new do |spec|
2619

2720
spec.name = "version_gem"
2821
spec.version = gem_version
22+
# Loading version into an anonymous module allows version.rb to get code coverage from SimpleCov!
23+
# See: https://github.com/simplecov-ruby/simplecov/issues/557#issuecomment-2630782358
24+
spec.version = Module.new.tap { |mod| Kernel.load("lib/version_gem/version.rb", mod) }::VersionGem::Version::VERSION
2925
spec.authors = ["Peter Boling"]
3026
3127

0 commit comments

Comments
 (0)