diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-07-12 16:40:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-07-12 16:40:06 +0000 |
commit | a27f6b1cfe2d56ffeab3683332588f77f594f10f (patch) | |
tree | a46ae9b2032a5ca69ad0364f273a636627d1eaad | |
parent | 40dc118c98e12b9881bf0ae812f97b33e8012060 (diff) | |
download | ruby-a27f6b1cfe2d56ffeab3683332588f77f594f10f.tar.gz ruby-a27f6b1cfe2d56ffeab3683332588f77f594f10f.tar.xz ruby-a27f6b1cfe2d56ffeab3683332588f77f594f10f.zip |
import
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/optparse/shellwords.rb | 6 | ||||
-rw-r--r-- | lib/optparse/time.rb | 10 | ||||
-rw-r--r-- | lib/optparse/uri.rb | 15 |
3 files changed, 31 insertions, 0 deletions
diff --git a/lib/optparse/shellwords.rb b/lib/optparse/shellwords.rb new file mode 100644 index 000000000..75cb57b72 --- /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 000000000..5e54b709e --- /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 000000000..bba0db209 --- /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 |