summaryrefslogtreecommitdiff
path: root/lib/optparse
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-08 11:00:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-08 11:00:17 +0000
commit22bb1debf99c168cd2248bb62f76bf6137bf1ce8 (patch)
treef04fd540e1e682d78b3a7b11522dcc6fde53b731 /lib/optparse
parent78ff3833fb67c8005a9b851037e74b3eea940aa3 (diff)
* lib/optparse.rb, lib/optparse/version.rb: search also all
capital versions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/optparse')
-rw-r--r--lib/optparse/version.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/optparse/version.rb b/lib/optparse/version.rb
index 8a1efcdf8c..8e99836878 100644
--- a/lib/optparse/version.rb
+++ b/lib/optparse/version.rb
@@ -8,19 +8,34 @@ class << OptionParser
str = "#{progname}"
str << ": #{klass}" unless klass == Object
str << " version #{version}"
- if klass.const_defined?(:Release)
+ case
+ when klass.const_defined?(:Release)
+ str << " (#{klass.const_get(:Release)})"
+ when klass.const_defined?(:RELEASE)
str << " (#{klass.const_get(:Release)})"
end
puts str
end
if pkg.size == 1 and pkg[0] == "all"
- self.search_const(::Object, "Version", &show)
+ self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version|
+ unless cname[1] == ?e and klass.const_defined?(:Version)
+ show.call(klass, version)
+ end
+ end
else
pkg.each do |pkg|
/\A[A-Z]\w*((::|\/)[A-Z]\w*)*\z/ni =~ pkg or next
begin
pkg = eval(pkg)
- show.call(pkg, pkg.const_defined?(:Version) ? pkg.const_get(:Version) : "unknown")
+ v = case
+ when pkg.const_defined?(:Version)
+ pkg.const_get(:Version)
+ when pkg.const_defined?(:VERSION)
+ pkg.const_get(:VERSION)
+ else
+ "unknown"
+ end
+ show.call(pkg, v)
rescue NameError
puts "#{progname}: #$!"
end
@@ -45,7 +60,7 @@ class << OptionParser
klass.constants.each do |cname|
klass.const_defined?(cname) or next
const = klass.const_get(cname)
- yield klass, const if cname == name
+ yield klass, cname, const if name === cname
klasses << const if Module === const and const != ::Object
end
end