summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-05-24 03:58:59 +0900
committerYusuke Endoh <mame@ruby-lang.org>2020-05-24 04:01:20 +0900
commitf27e0d90c865a19d42c222a82e13ee4c40352bf7 (patch)
tree1d2cacf5a8904b36e506cff8ab7f543bc6b2a52b /ext
parentc15cddd1d515c5bd8dfe8fb2725e3f723aec63b8 (diff)
downloadruby-f27e0d90c865a19d42c222a82e13ee4c40352bf7.tar.gz
ext/fiddle/fiddle.gemspec: avoid require lib/fiddle/version.rb
It loads `ext/fiddle/lib/fiddle/version.rb`, which causes constant redefinition warning: http://rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200523T153003Z.log.html.gz ``` [ 6317/20193] TestDefaultGems#test_validate_gemspec/home/chkbuild/chkbuild/tmp/build/20200523T153003Z/ruby/ext/fiddle/lib/fiddle/version.rb:2: warning: already initialized constant Fiddle::VERSION /home/chkbuild/chkbuild/tmp/build/20200523T153003Z/ruby/.ext/common/fiddle/version.rb:2: warning: previous definition of VERSION was here = 0.16 s ``` This changeset read the version by manual parsing hack which is also used in stringio and zlib.
Diffstat (limited to 'ext')
-rw-r--r--ext/fiddle/fiddle.gemspec15
1 files changed, 9 insertions, 6 deletions
diff --git a/ext/fiddle/fiddle.gemspec b/ext/fiddle/fiddle.gemspec
index 0229d3e166..befa7aeff5 100644
--- a/ext/fiddle/fiddle.gemspec
+++ b/ext/fiddle/fiddle.gemspec
@@ -1,15 +1,18 @@
# frozen_string_literal: true
-begin
- require_relative "lib/fiddle/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
+source_version = ["", "ext/fiddle/"].find do |dir|
+ begin
+ break File.open(File.join(__dir__, "#{dir}lib/fiddle/version.rb")) {|f|
+ f.gets("\n VERSION = ")
+ f.gets[/\s*"(.+)"/, 1]
+ }
+ rescue Errno::ENOENT
+ end
end
Gem::Specification.new do |spec|
spec.name = "fiddle"
- spec.version = Fiddle::VERSION
+ spec.version = source_version
spec.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
spec.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org"]