mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
c15cddd1d5
commit
f27e0d90c8
1 changed files with 9 additions and 6 deletions
|
@ -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"]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue