ruby-changes:61353
From: Yusuke <ko1@a...>
Date: Sun, 24 May 2020 04:01:47 +0900 (JST)
Subject: [ruby-changes:61353] f27e0d90c8 (master): ext/fiddle/fiddle.gemspec: avoid require lib/fiddle/version.rb
https://git.ruby-lang.org/ruby.git/commit/?id=f27e0d90c8 From f27e0d90c865a19d42c222a82e13ee4c40352bf7 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sun, 24 May 2020 03:58:59 +0900 Subject: 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. diff --git a/ext/fiddle/fiddle.gemspec b/ext/fiddle/fiddle.gemspec index 0229d3e..befa7ae 100644 --- a/ext/fiddle/fiddle.gemspec +++ b/ext/fiddle/fiddle.gemspec @@ -1,15 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/fiddle.gemspec#L1 # 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@t...", "hsbt@r..."] -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/