summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-05 14:06:10 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-05 14:06:10 +0000
commitc9e950b2396427eab7859b0ddd8415e43f86e739 (patch)
treeb163552044e56809cc6293571bf02447775c1b32
parent856c6f1b7e068220800e9d5d502beb6e41e00a19 (diff)
downloadruby-c9e950b2396427eab7859b0ddd8415e43f86e739.tar.gz
ruby-c9e950b2396427eab7859b0ddd8415e43f86e739.tar.xz
ruby-c9e950b2396427eab7859b0ddd8415e43f86e739.zip
* lib/uri/common.rb (Kernel#URI): new global method for parsing URIs.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--lib/uri/common.rb10
-rw-r--r--test/uri/test_common.rb7
3 files changed, 21 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 85de4df6b..a88ce52f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Jul 5 22:54:39 2004 Tanaka Akira <akr@m17n.org>
+
+ * lib/uri/common.rb (Kernel#URI): new global method for parsing URIs.
+
Mon Jul 5 09:02:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_thread_yield, rb_f_catch): 4th argument to rb_yield_0()
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index 175ef9730..f5772084e 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -595,3 +595,13 @@ module URI
end
end
+
+module Kernel
+ # alias for URI.parse.
+ #
+ # This method is introduced at 1.8.2.
+ def URI(uri_str) # :doc:
+ URI.parse(uri_str)
+ end
+ module_function :URI
+end
diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb
index 1e1a40d11..a159901ea 100644
--- a/test/uri/test_common.rb
+++ b/test/uri/test_common.rb
@@ -43,6 +43,13 @@ class TestCommon < Test::Unit::TestCase
assert_equal nil, ':'.slice(URI.regexp)
assert_equal 'From:', 'From:'.slice(URI.regexp)
end
+
+ def test_kernel_uri
+ expected = URI.parse("http://www.ruby-lang.org/")
+ assert_equal(expected, URI("http://www.ruby-lang.org/"))
+ assert_equal(expected, Kernel::URI("http://www.ruby-lang.org/"))
+ assert_raise(NoMethodError) { Object.new.URI("http://www.ruby-lang.org/") }
+ end
end