diff options
Diffstat (limited to 'trunk/lib/optparse')
-rw-r--r-- | trunk/lib/optparse/date.rb | 17 | ||||
-rw-r--r-- | trunk/lib/optparse/shellwords.rb | 6 | ||||
-rw-r--r-- | trunk/lib/optparse/time.rb | 10 | ||||
-rw-r--r-- | trunk/lib/optparse/uri.rb | 6 | ||||
-rw-r--r-- | trunk/lib/optparse/version.rb | 70 |
5 files changed, 0 insertions, 109 deletions
diff --git a/trunk/lib/optparse/date.rb b/trunk/lib/optparse/date.rb deleted file mode 100644 index d680559f37..0000000000 --- a/trunk/lib/optparse/date.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'optparse' -require 'date' - -OptionParser.accept(DateTime) do |s,| - begin - DateTime.parse(s) if s - rescue ArgumentError - raise OptionParser::InvalidArgument, s - end -end -OptionParser.accept(Date) do |s,| - begin - Date.parse(s) if s - rescue ArgumentError - raise OptionParser::InvalidArgument, s - end -end diff --git a/trunk/lib/optparse/shellwords.rb b/trunk/lib/optparse/shellwords.rb deleted file mode 100644 index 0422d7c887..0000000000 --- a/trunk/lib/optparse/shellwords.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- ruby -*- - -require 'shellwords' -require 'optparse' - -OptionParser.accept(Shellwords) {|s,| Shellwords.shellwords(s)} diff --git a/trunk/lib/optparse/time.rb b/trunk/lib/optparse/time.rb deleted file mode 100644 index 402cadcf16..0000000000 --- a/trunk/lib/optparse/time.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'optparse' -require 'time' - -OptionParser.accept(Time) do |s,| - begin - (Time.httpdate(s) rescue Time.parse(s)) if s - rescue - raise OptionParser::InvalidArgument, s - end -end diff --git a/trunk/lib/optparse/uri.rb b/trunk/lib/optparse/uri.rb deleted file mode 100644 index 024dc69eac..0000000000 --- a/trunk/lib/optparse/uri.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- ruby -*- - -require 'optparse' -require 'uri' - -OptionParser.accept(URI) {|s,| URI.parse(s) if s} diff --git a/trunk/lib/optparse/version.rb b/trunk/lib/optparse/version.rb deleted file mode 100644 index 558d9d710b..0000000000 --- a/trunk/lib/optparse/version.rb +++ /dev/null @@ -1,70 +0,0 @@ -# OptionParser internal utility - -class << OptionParser - def show_version(*pkg) - progname = ARGV.options.program_name - result = false - show = proc do |klass, cname, version| - str = "#{progname}" - unless klass == ::Object and cname == :VERSION - version = version.join(".") if Array === version - str << ": #{klass}" unless klass == Object - str << " version #{version}" - end - [:Release, :RELEASE].find do |rel| - if klass.const_defined?(rel) - str << " (#{klass.const_get(rel)})" - end - end - puts str - result = true - end - if pkg.size == 1 and pkg[0] == "all" - self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version| - unless cname[1] == ?e and klass.const_defined?(:Version) - show.call(klass, cname.intern, version) - end - end - else - pkg.each do |pkg| - begin - pkg = pkg.split(/::|\//).inject(::Object) {|m, c| m.const_get(c)} - v = case - when pkg.const_defined?(:Version) - pkg.const_get(n = :Version) - when pkg.const_defined?(:VERSION) - pkg.const_get(n = :VERSION) - else - n = nil - "unknown" - end - show.call(pkg, n, v) - rescue NameError - end - end - end - result - end - - def each_const(path, klass = ::Object) - path.split(/::|\//).inject(klass) do |klass, name| - raise NameError, path unless Module === klass - klass.constants.grep(/#{name}/i) do |c| - klass.const_defined?(c) or next - c = klass.const_get(c) - end - end - end - - def search_const(klass, name) - klasses = [klass] - while klass = klasses.shift - klass.constants.each do |cname| - klass.const_defined?(cname) or next - const = klass.const_get(cname) - yield klass, cname, const if name === cname - klasses << const if Module === const and const != ::Object - end - end - end -end |