From d554a55d9b98dc832fe0257f8696dc93b211789d Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 12 Jul 2002 16:40:06 +0000 Subject: import git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/optparse/shellwords.rb | 6 ++++++ lib/optparse/time.rb | 10 ++++++++++ lib/optparse/uri.rb | 15 +++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 lib/optparse/shellwords.rb create mode 100644 lib/optparse/time.rb create mode 100644 lib/optparse/uri.rb (limited to 'lib/optparse') diff --git a/lib/optparse/shellwords.rb b/lib/optparse/shellwords.rb new file mode 100644 index 0000000000..75cb57b72b --- /dev/null +++ b/lib/optparse/shellwords.rb @@ -0,0 +1,6 @@ +# -*- ruby -*- + +require 'shellwords' +require 'optparse' + +OptionParser.accept(Shellwords) {|s| Shellwords.shellwords(s)} diff --git a/lib/optparse/time.rb b/lib/optparse/time.rb new file mode 100644 index 0000000000..5e54b709e0 --- /dev/null +++ b/lib/optparse/time.rb @@ -0,0 +1,10 @@ +require 'optparse' +require 'parsedate' + +OptionParser.accept(Time) do |s| + begin + Time::mktime(*ParseDate::parsedate(s)[0...6]) + rescue + raise OptionParser::InvalidArgument, s + end +end diff --git a/lib/optparse/uri.rb b/lib/optparse/uri.rb new file mode 100644 index 0000000000..bba0db209d --- /dev/null +++ b/lib/optparse/uri.rb @@ -0,0 +1,15 @@ +# -*- ruby -*- + +require 'optparse' +unless defined?(URI) + begin + require 'URI/uri' # Akira Yamada version. + rescue LoadError + require 'uri/uri' # Tomoyuki Kosimizu version. + end +end +if URI.respond_to?(:parse) + OptionParser.accept(URI) {|s| [URI.parse(s)] if s} +else + OptionParser.accept(URI) {|s| [URI.create(s)] if s} +end -- cgit v1.2.3