Skip to content

Commit 4c0021b

Browse files
committed
Define OptionParser::Version
1 parent d44bb5c commit 4c0021b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/optparse.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@
419419
# have any questions, file a ticket at http://bugs.ruby-lang.org.
420420
#
421421
class OptionParser
422+
OptionParser::Version = "0.1.0"
423+
422424
# :stopdoc:
423425
NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
424426
RequiredArgument = [REQUIRED_ARGUMENT = :REQUIRED, true].freeze

optparse.gemspec

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
name = File.basename(__FILE__, ".gemspec")
2+
version = nil
3+
["lib", ".."].find do |dir|
4+
version = File.foreach(File.join(__dir__, dir, "#{name}.rb")) do |line|
5+
/^\s*OptionParser::Version\s*=\s*"(.*)"/ =~ line and break $1
6+
end rescue nil
7+
end
8+
19
Gem::Specification.new do |spec|
2-
spec.name = "optparse"
3-
spec.version = "0.1.0"
10+
spec.name = name
11+
spec.version = version
412
spec.authors = ["Nobu Nakada"]
513
spec.email = ["nobu@ruby-lang.org"]
614

0 commit comments

Comments
 (0)