summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-23 01:08:06 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-23 10:57:33 +0900
commitf120e6520063913229a659741d96187eb2f7dd82 (patch)
tree9be4b62b694c4485f2b737a9ed39dba33ee362eb
parentcd429e68d2ab19aa7deabd2433dc43b374271414 (diff)
[ruby/optparse] Define OptionParser::Version
https://github.com/ruby/optparse/commit/4c0021b5b2
-rw-r--r--lib/optparse.rb2
-rw-r--r--lib/optparse/optparse.gemspec12
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 614ebc3eae..82582f61cb 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -419,6 +419,8 @@
# have any questions, file a ticket at http://bugs.ruby-lang.org.
#
class OptionParser
+ OptionParser::Version = "0.1.0"
+
# :stopdoc:
NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
RequiredArgument = [REQUIRED_ARGUMENT = :REQUIRED, true].freeze
diff --git a/lib/optparse/optparse.gemspec b/lib/optparse/optparse.gemspec
index 2ec715cf28..d67060a63f 100644
--- a/lib/optparse/optparse.gemspec
+++ b/lib/optparse/optparse.gemspec
@@ -1,6 +1,14 @@
+name = File.basename(__FILE__, ".gemspec")
+version = nil
+["lib", ".."].find do |dir|
+ version = File.foreach(File.join(__dir__, dir, "#{name}.rb")) do |line|
+ /^\s*OptionParser::Version\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "optparse"
- spec.version = "0.1.0"
+ spec.name = name
+ spec.version = version
spec.authors = ["Nobu Nakada"]
spec.email = ["nobu@ruby-lang.org"]