summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 86bb9892d3..bd2464c2ed 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 175ef97304..f5772084e2 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 1e1a40d115..a159901ea6 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