summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-29 00:31:52 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-30 19:03:18 +0900
commitb2d96abb42abbe2e01f010ffc9ac51f0f9a50002 (patch)
tree57791da8a71280c335109916376e13f5e0c63af3
parentcfbae7dae052180e5dde05a27948ae8d779eccab (diff)
Extract version number from the source
"requiring version.rb" strategy has some issues. - cannot work when cross-compiling - often introduces wrong namespace - must know the superclasses - costs at each runtime than at build-time etc.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3375
-rw-r--r--lib/cgi.rb1
-rw-r--r--lib/cgi/cgi.gemspec15
-rw-r--r--lib/cgi/version.rb3
-rw-r--r--lib/delegate.rb2
-rw-r--r--lib/delegate/delegate.gemspec15
-rw-r--r--lib/delegate/version.rb3
-rw-r--r--lib/forwardable.rb5
-rw-r--r--lib/forwardable/forwardable.gemspec16
-rw-r--r--lib/forwardable/version.rb5
-rw-r--r--lib/getoptlong.rb3
-rw-r--r--lib/getoptlong/getoptlong.gemspec15
-rw-r--r--lib/getoptlong/version.rb3
-rw-r--r--lib/net/ftp/net-ftp.gemspec9
-rw-r--r--lib/net/http.rb1
-rw-r--r--lib/net/http/net-http.gemspec15
-rw-r--r--lib/net/http/version.rb5
-rw-r--r--lib/net/imap.rb2
-rw-r--r--lib/net/imap/net-imap.gemspec15
-rw-r--r--lib/net/imap/version.rb5
-rw-r--r--lib/net/pop.rb5
-rw-r--r--lib/net/pop/net-pop.gemspec15
-rw-r--r--lib/net/pop/version.rb6
-rw-r--r--lib/net/protocol.rb2
-rw-r--r--lib/net/protocol/net-protocol.gemspec15
-rw-r--r--lib/net/protocol/version.rb5
-rw-r--r--lib/net/smtp.rb1
-rw-r--r--lib/net/smtp/net-smtp.gemspec15
-rw-r--r--lib/net/smtp/version.rb6
-rw-r--r--lib/observer.rb1
-rw-r--r--lib/observer/observer.gemspec15
-rw-r--r--lib/observer/version.rb3
-rw-r--r--lib/open3.rb1
-rw-r--r--lib/open3/open3.gemspec15
-rw-r--r--lib/open3/version.rb3
-rw-r--r--lib/optparse/optparse.gemspec7
-rw-r--r--lib/ostruct.rb3
-rw-r--r--lib/ostruct/ostruct.gemspec14
-rw-r--r--lib/ostruct/version.rb5
-rw-r--r--lib/pstore.rb2
-rw-r--r--lib/pstore/pstore.gemspec15
-rw-r--r--lib/pstore/version.rb3
-rw-r--r--lib/singleton.rb2
-rw-r--r--lib/singleton/singleton.gemspec15
-rw-r--r--lib/singleton/version.rb3
-rw-r--r--lib/timeout.rb2
-rw-r--r--lib/timeout/timeout.gemspec15
-rw-r--r--lib/timeout/version.rb3
-rw-r--r--lib/tracer.rb1
-rw-r--r--lib/tracer/tracer.gemspec16
-rw-r--r--lib/tracer/version.rb5
-rw-r--r--lib/weakref.rb1
-rw-r--r--lib/weakref/version.rb3
-rw-r--r--lib/weakref/weakref.gemspec15
53 files changed, 190 insertions, 186 deletions
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 4f16f309da5..a125eef4039 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -288,6 +288,7 @@
#
class CGI
+ VERSION = "0.1.0"
end
require 'cgi/core'
diff --git a/lib/cgi/cgi.gemspec b/lib/cgi/cgi.gemspec
index 58bd77027d4..57dd346db5d 100644
--- a/lib/cgi/cgi.gemspec
+++ b/lib/cgi/cgi.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/cgi/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "cgi"
- spec.version = CGI::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/cgi/version.rb b/lib/cgi/version.rb
deleted file mode 100644
index 9d17c91b954..00000000000
--- a/lib/cgi/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class CGI
- VERSION = "0.1.0"
-end
diff --git a/lib/delegate.rb b/lib/delegate.rb
index a1fded6425c..cf8d39a9823 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -39,6 +39,8 @@
# Be advised, RDoc will not detect delegated methods.
#
class Delegator < BasicObject
+ VERSION = "0.1.0"
+
kernel = ::Kernel.dup
kernel.class_eval do
alias __raise__ raise
diff --git a/lib/delegate/delegate.gemspec b/lib/delegate/delegate.gemspec
index 63b00c58948..bf7dd6600d2 100644
--- a/lib/delegate/delegate.gemspec
+++ b/lib/delegate/delegate.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/delegate/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "delegate"
- spec.version = Delegator::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/delegate/version.rb b/lib/delegate/version.rb
deleted file mode 100644
index 1f0b4e08633..00000000000
--- a/lib/delegate/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Delegator < BasicObject
- VERSION = "0.1.0"
-end
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 4cfade470ad..d0f49f73091 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -110,7 +110,10 @@
#
module Forwardable
require 'forwardable/impl'
- require "forwardable/version"
+
+ # Version of +forwardable.rb+
+ VERSION = "1.3.1"
+ FORWARDABLE_VERSION = VERSION
@debug = nil
class << self
diff --git a/lib/forwardable/forwardable.gemspec b/lib/forwardable/forwardable.gemspec
index 2a3e637e260..54e54f4c3cf 100644
--- a/lib/forwardable/forwardable.gemspec
+++ b/lib/forwardable/forwardable.gemspec
@@ -1,13 +1,15 @@
-begin
- require_relative "lib/forwardable/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "forwardable"
- spec.version = Forwardable::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Keiju ISHITSUKA"]
spec.email = ["keiju@ruby-lang.org"]
diff --git a/lib/forwardable/version.rb b/lib/forwardable/version.rb
deleted file mode 100644
index 8f3e1f510ef..00000000000
--- a/lib/forwardable/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module Forwardable
- # Version of +forwardable.rb+
- VERSION = "1.3.1"
- FORWARDABLE_VERSION = VERSION
-end
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb
index ff7674f1cba..6d4922ec9d3 100644
--- a/lib/getoptlong.rb
+++ b/lib/getoptlong.rb
@@ -85,6 +85,9 @@
# hello -n 6 --name -- /tmp
#
class GetoptLong
+ # Version.
+ VERSION = "0.1.0"
+
#
# Orderings.
#
diff --git a/lib/getoptlong/getoptlong.gemspec b/lib/getoptlong/getoptlong.gemspec
index 5e218b8e937..123977c1f38 100644
--- a/lib/getoptlong/getoptlong.gemspec
+++ b/lib/getoptlong/getoptlong.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/getoptlong/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "getoptlong"
- spec.version = GetoptLong::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/getoptlong/version.rb b/lib/getoptlong/version.rb
deleted file mode 100644
index 6375fb8ad13..00000000000
--- a/lib/getoptlong/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class GetoptLong
- VERSION = "0.1.0"
-end
diff --git a/lib/net/ftp/net-ftp.gemspec b/lib/net/ftp/net-ftp.gemspec
index 6031ce7ccf9..893305cfb8b 100644
--- a/lib/net/ftp/net-ftp.gemspec
+++ b/lib/net/ftp/net-ftp.gemspec
@@ -1,13 +1,14 @@
+# frozen_string_literal: true
+
name = File.basename(__FILE__, ".gemspec")
-version = nil
-["lib", "../.."].find do |dir|
- version = File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "net-ftp"
+ spec.name = name
spec.version = version
spec.authors = ["Shugo Maeda"]
spec.email = ["shugo@ruby-lang.org"]
diff --git a/lib/net/http.rb b/lib/net/http.rb
index fe237dcf665..fe856ac877b 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -388,6 +388,7 @@ module Net #:nodoc:
class HTTP < Protocol
# :stopdoc:
+ VERSION = "0.1.0"
Revision = %q$Revision$.split[1]
HTTPVersion = '1.1'
begin
diff --git a/lib/net/http/net-http.gemspec b/lib/net/http/net-http.gemspec
index cf3c5bd6a48..c6952c3c1bc 100644
--- a/lib/net/http/net-http.gemspec
+++ b/lib/net/http/net-http.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/net/http/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "net-http"
- spec.version = Net::Http::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["NARUSE, Yui"]
spec.email = ["naruse@airemix.jp"]
diff --git a/lib/net/http/version.rb b/lib/net/http/version.rb
deleted file mode 100644
index 832d5971116..00000000000
--- a/lib/net/http/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module Net
- module Http
- VERSION = "0.1.0"
- end
-end
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 704fdef382a..de13d0807c9 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -201,6 +201,8 @@ module Net
# Unicode", RFC 2152, May 1997.
#
class IMAP < Protocol
+ VERSION = "0.1.0"
+
include MonitorMixin
if defined?(OpenSSL::SSL)
include OpenSSL
diff --git a/lib/net/imap/net-imap.gemspec b/lib/net/imap/net-imap.gemspec
index 696ec79ae72..2426e0932df 100644
--- a/lib/net/imap/net-imap.gemspec
+++ b/lib/net/imap/net-imap.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative 'lib/net/imap/version'
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "net-imap"
- spec.version = Net::Imap::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Shugo Maeda"]
spec.email = ["shugo@ruby-lang.org"]
diff --git a/lib/net/imap/version.rb b/lib/net/imap/version.rb
deleted file mode 100644
index 47d3de471ff..00000000000
--- a/lib/net/imap/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module Net
- module Imap
- VERSION = "0.1.0"
- end
-end
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 30161105f92..ed1963975b8 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -194,9 +194,8 @@ module Net
# String. Normally the unique-id is a hash of the message.
#
class POP3 < Protocol
-
- # svn revision of this library
- Revision = %q$Revision$.split[1]
+ # version of this library
+ VERSION = "0.1.0"
#
# Class Parameters
diff --git a/lib/net/pop/net-pop.gemspec b/lib/net/pop/net-pop.gemspec
index c1b0ffbd2b4..90d594f14aa 100644
--- a/lib/net/pop/net-pop.gemspec
+++ b/lib/net/pop/net-pop.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/net/pop/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "net-pop"
- spec.version = Net::POP3::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/net/pop/version.rb b/lib/net/pop/version.rb
deleted file mode 100644
index ef5c295cc3e..00000000000
--- a/lib/net/pop/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Net
- class Protocol; end
- class POP3 < Protocol
- VERSION = "0.1.0"
- end
-end
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 07fbc6a21ff..cba92613c70 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -26,6 +26,8 @@ require 'io/wait'
module Net # :nodoc:
class Protocol #:nodoc: internal use only
+ VERSION = "0.1.0"
+
private
def Protocol.protocol_param(name, val)
module_eval(<<-End, __FILE__, __LINE__ + 1)
diff --git a/lib/net/protocol/net-protocol.gemspec b/lib/net/protocol/net-protocol.gemspec
index 2bfd2e29dde..a277c301d53 100644
--- a/lib/net/protocol/net-protocol.gemspec
+++ b/lib/net/protocol/net-protocol.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/net/protocol/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "net-protocol"
- spec.version = Net::Protocol::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/net/protocol/version.rb b/lib/net/protocol/version.rb
deleted file mode 100644
index ec51a4c4ef9..00000000000
--- a/lib/net/protocol/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module Net
- class Protocol
- VERSION = "0.1.0"
- end
-end
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 801f662d01c..f8121cd44f9 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -168,6 +168,7 @@ module Net
# 'Your Account', 'Your Password', :cram_md5)
#
class SMTP < Protocol
+ VERSION = "0.1.0"
Revision = %q$Revision$.split[1]
diff --git a/lib/net/smtp/net-smtp.gemspec b/lib/net/smtp/net-smtp.gemspec
index f0aae585de1..4c8c07810bd 100644
--- a/lib/net/smtp/net-smtp.gemspec
+++ b/lib/net/smtp/net-smtp.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/net/smtp/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "net-smtp"
- spec.version = Net::SMTP::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/net/smtp/version.rb b/lib/net/smtp/version.rb
deleted file mode 100644
index 7f5aaaa6db9..00000000000
--- a/lib/net/smtp/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Net
- class Protocol; end
- class SMTP < Protocol
- VERSION = "0.1.0"
- end
-end
diff --git a/lib/observer.rb b/lib/observer.rb
index 0078d81449a..f242cddc24a 100644
--- a/lib/observer.rb
+++ b/lib/observer.rb
@@ -136,6 +136,7 @@
# ticker.add_observer(warner, :call)
# ticker.run
module Observable
+ VERSION = "0.1.0"
#
# Add +observer+ as an observer on this object. So that it will receive
diff --git a/lib/observer/observer.gemspec b/lib/observer/observer.gemspec
index 188c6bae767..f438f174376 100644
--- a/lib/observer/observer.gemspec
+++ b/lib/observer/observer.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/observer/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "observer"
- spec.version = Observer::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/observer/version.rb b/lib/observer/version.rb
deleted file mode 100644
index 92b50987740..00000000000
--- a/lib/observer/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Observer
- VERSION = "0.1.0"
-end
diff --git a/lib/open3.rb b/lib/open3.rb
index 3ee81c30ace..98213c97883 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -30,6 +30,7 @@
#
module Open3
+ VERSION = "0.1.0"
# Open stdin, stdout, and stderr streams and start external executable.
# In addition, a thread to wait for the started process is created.
diff --git a/lib/open3/open3.gemspec b/lib/open3/open3.gemspec
index 543416e4274..b029c04ee8f 100644
--- a/lib/open3/open3.gemspec
+++ b/lib/open3/open3.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/open3/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "open3"
- spec.version = Open3::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/open3/version.rb b/lib/open3/version.rb
deleted file mode 100644
index c670b79ebc4..00000000000
--- a/lib/open3/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Open3
- VERSION = "0.1.0"
-end
diff --git a/lib/optparse/optparse.gemspec b/lib/optparse/optparse.gemspec
index 25f81c08bb2..3de0c07f437 100644
--- a/lib/optparse/optparse.gemspec
+++ b/lib/optparse/optparse.gemspec
@@ -1,7 +1,8 @@
+# frozen_string_literal: true
+
name = File.basename(__FILE__, ".gemspec")
-version = nil
-["lib", ".."].find do |dir|
- version = File.foreach(File.join(__dir__, dir, "#{name}.rb")) do |line|
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
/^\s*OptionParser::Version\s*=\s*"(.*)"/ =~ line and break $1
end rescue nil
end
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index a151fc0bed1..e062fbdc9c8 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -9,8 +9,6 @@
# See OpenStruct for an example.
#
-require_relative 'ostruct/version'
-
#
# An OpenStruct is a data structure, similar to a Hash, that allows the
# definition of arbitrary attributes with their accompanying values. This is
@@ -75,6 +73,7 @@ require_relative 'ostruct/version'
# of these properties compared to using a Hash or a Struct.
#
class OpenStruct
+ VERSION = "0.2.0"
#
# Creates a new OpenStruct object. By default, the resulting OpenStruct
diff --git a/lib/ostruct/ostruct.gemspec b/lib/ostruct/ostruct.gemspec
index 4f8507045ee..a070e296c04 100644
--- a/lib/ostruct/ostruct.gemspec
+++ b/lib/ostruct/ostruct.gemspec
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-begin
- require_relative "lib/ostruct/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "ostruct"
- spec.version = OpenStruct::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Marc-Andre Lafortune"]
spec.email = ["ruby-core@marc-andre.ca"]
diff --git a/lib/ostruct/version.rb b/lib/ostruct/version.rb
deleted file mode 100644
index 91a40440941..00000000000
--- a/lib/ostruct/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-class OpenStruct
- VERSION = "0.2.0"
-end
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 1180fd50a0a..f4e6e12c266 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -92,6 +92,8 @@ require "digest"
# Needless to say, if you're storing valuable data with PStore, then you should
# backup the PStore files from time to time.
class PStore
+ VERSION = "0.1.0"
+
RDWR_ACCESS = {mode: IO::RDWR | IO::CREAT | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
RD_ACCESS = {mode: IO::RDONLY | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
WR_ACCESS = {mode: IO::WRONLY | IO::CREAT | IO::TRUNC | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
diff --git a/lib/pstore/pstore.gemspec b/lib/pstore/pstore.gemspec
index e781c770433..d04fddcb0a5 100644
--- a/lib/pstore/pstore.gemspec
+++ b/lib/pstore/pstore.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/pstore/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "pstore"
- spec.version = PStore::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/pstore/version.rb b/lib/pstore/version.rb
deleted file mode 100644
index 0e7a3fbd156..00000000000
--- a/lib/pstore/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class PStore
- VERSION = "0.1.0"
-end
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 32be573a78c..8d53323ad42 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -92,6 +92,8 @@
# p a.strip # => nil
#
module Singleton
+ VERSION = "0.1.0"
+
# Raises a TypeError to prevent cloning.
def clone
raise TypeError, "can't clone instance of singleton #{self.class}"
diff --git a/lib/singleton/singleton.gemspec b/lib/singleton/singleton.gemspec
index c6a273a8392..2f23233ccfd 100644
--- a/lib/singleton/singleton.gemspec
+++ b/lib/singleton/singleton.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/singleton/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "singleton"
- spec.version = Singleton::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/singleton/version.rb b/lib/singleton/version.rb
deleted file mode 100644
index 01ab1eb5fa5..00000000000
--- a/lib/singleton/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Singleton
- VERSION = "0.1.0"
-end
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 62a35169a4b..cbe0bc7cdf9 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -23,6 +23,8 @@
# Copyright:: (C) 2000 Information-technology Promotion Agency, Japan
module Timeout
+ VERSION = "0.1.0"
+
# Raised by Timeout.timeout when the block times out.
class Error < RuntimeError
attr_reader :thread
diff --git a/lib/timeout/timeout.gemspec b/lib/timeout/timeout.gemspec
index 7b650bdc315..12ac062b6dd 100644
--- a/lib/timeout/timeout.gemspec
+++ b/lib/timeout/timeout.gemspec
@@ -1,12 +1,15 @@
-begin
- require_relative "lib/timeout/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "timeout"
- spec.version = Timeout::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/lib/timeout/version.rb b/lib/timeout/version.rb
deleted file mode 100644
index 39fc6eec5fb..00000000000
--- a/lib/timeout/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Timeout
- VERSION = "0.1.0"
-end
diff --git a/lib/tracer.rb b/lib/tracer.rb
index c1540b8d233..81bda189c26 100644
--- a/lib/tracer.rb
+++ b/lib/tracer.rb
@@ -60,6 +60,7 @@
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
class Tracer
+ VERSION = "0.1.0"
class << self
# display additional debug information (defaults to false)
diff --git a/lib/tracer/tracer.gemspec b/lib/tracer/tracer.gemspec
index 9eab333f798..63e845cf844 100644
--- a/lib/tracer/tracer.gemspec
+++ b/lib/tracer/tracer.gemspec
@@ -1,13 +1,15 @@
-begin
- require_relative "lib/tracer/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
end
Gem::Specification.new do |spec|
- spec.name = "tracer"
- spec.version = Tracer::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Keiju ISHITSUKA"]
spec.email = ["keiju@ruby-lang.org"]
diff --git a/lib/tracer/version.rb b/lib/tracer/version.rb
deleted file mode 100644
index f1b6dcd0941..00000000000
--- a/lib/tracer/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-class Tracer
- VERSION = "0.1.0"
-end
diff --git a/lib/weakref.rb b/lib/weakref.rb
index 824d4016e18..3b681a529c6 100644
--- a/lib/weakref.rb
+++ b/lib/weakref.rb
@@ -17,6 +17,7 @@ require "delegate"
#
class WeakRef < Delegator
+ VERSION = "0.1.0"
##
# RefError is raised when a referenced object has been recycled by the
diff --git a/lib/weakref/version.rb b/lib/weakref/version.rb
deleted file mode 100644
index 893da807534..00000000000
--- a/lib/weakref/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Weakref
- VERSION = "0.1.0"
-end
diff --git a/lib/weakref/weakref.gemspec b/lib/weakref/weakref.gemspec
index 886ae13d9f2..a7c83a53e70 100644
--- a/lib/weakref/weakref.gemspec
+++ b/lib/weakref/weakref.gemspec
@@ -1,10 +1,15 @@
-lib = File.expand_path("lib", __dir__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require "weakref/version"
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
Gem::Specification.new do |spec|
- spec.name = "weakref"
- spec.version = Weakref::VERSION
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]