From 22bb1debf99c168cd2248bb62f76bf6137bf1ce8 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 8 Sep 2003 11:00:17 +0000 Subject: [PATCH] * 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 --- ChangeLog | 11 ++++++++--- lib/optparse.rb | 4 ++-- lib/optparse/version.rb | 23 +++++++++++++++++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d467857bda..ff8e5f9ce0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 8 20:00:12 2003 Nobuyoshi Nakada + + * lib/optparse.rb, lib/optparse/version.rb: search also all + capital versions. + Mon Sep 8 19:26:33 2003 GOTOU Yuuzou * ext/openssl/ossl.h: include openssl/conf.h and openssl/conf_api.h. @@ -15,7 +20,7 @@ Mon Sep 8 19:26:33 2003 GOTOU Yuuzou * ext/openssl/ossl_x509ext.c (ossl_x509_set_config): add for config=. - * ext/openssl/ossl_x509ext.c (Xossl_x509extfactory_initialize): + * ext/openssl/ossl_x509ext.c (Xossl_x509extfactory_initialize): add attr readers: issuer_certificate, subject_certificate, subject_request, crl and config. @@ -28,7 +33,7 @@ Mon Sep 8 18:26:41 2003 GOTOU Yuuzou * lib/webrick/httpservlet/filehandler.rb (FileHandler#dir_list): ditto. - * lib/webrick/config.rb: :Listen option never be used. + * lib/webrick/config.rb: :Listen option never be used. * lib/webrick/server.rb (GenericServer#initialize): don't use :Listen option and add warning message. @@ -54,7 +59,7 @@ Sat Sep 6 18:45:46 2003 Mauricio Fernandez Sat Sep 6 17:40:41 2003 GOTOU Yuuzou - * ext/openssl/ruby_missing.c: rid of unnecessary backward + * ext/openssl/ruby_missing.c: rid of unnecessary backward compatibility stuff. and remove DEFINE_ALLOC_WRAPPER from all sources. diff --git a/lib/optparse.rb b/lib/optparse.rb index d17bf75404..38958c3f8d 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -786,11 +786,11 @@ Default options, which never appear in option summary. attr_writer :version, :release def version - @version || (defined?(::Version) && ::Version) + @version || (defined?(::Version) && ::Version) || (defined?(::VERSION) && ::VERSION) end def release - @release || (defined?(::Release) && ::Release) + @release || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE) end def ver 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