[前][次][番号順一覧][スレッド一覧]

ruby-changes:20511

From: marcandre <ko1@a...>
Date: Sat, 16 Jul 2011 06:28:39 +0900 (JST)
Subject: [ruby-changes:20511] marcandRe: r32559 (trunk): * lib/uri/common.rb (module): Remove optional parser argument to Kernel#URI

marcandre	2011-07-16 06:28:10 +0900 (Sat, 16 Jul 2011)

  New Revision: 32559

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32559

  Log:
    * lib/uri/common.rb (module): Remove optional parser argument to Kernel#URI
      [ruby-core:38061]
    
    * lib/uri/generic.rb (module): ditto

  Modified files:
    trunk/ChangeLog
    trunk/lib/uri/common.rb
    trunk/lib/uri/generic.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32558)
+++ ChangeLog	(revision 32559)
@@ -1,3 +1,11 @@
+Sat Jul 16 06:27:51 2011  Marc-Andre Lafortune  <ruby-core@m...>
+
+	* lib/uri/common.rb (module): Remove optional parser argument to
+	  Kernel#URI
+	  [ruby-core:38061]
+	
+	* lib/uri/generic.rb (module): ditto
+
 Sat Jul 16 03:19:45 2011  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (is_socket, is_console): add prototypes to fix compile
Index: lib/uri/common.rb
===================================================================
--- lib/uri/common.rb	(revision 32558)
+++ lib/uri/common.rb	(revision 32559)
@@ -233,7 +233,7 @@
     # Attempts to parse and merge a set of URIs
     #
     def join(*uris)
-      uris[0] = URI(uris[0], self)
+      uris[0] = convert_to_uri(uris[0])
       uris.inject :merge
     end
 
@@ -527,6 +527,18 @@
 
       ret
     end
+
+    def convert_to_uri(uri)
+      if uri.is_a?(URI::Generic)
+        uri
+      elsif uri = String.try_convert(uri)
+        parse(uri)
+      else
+        raise ArgumentError,
+          "bad argument (expected URI object or URI string)"
+      end
+    end
+
   end # class Parser
 
   # URI::Parser.new
@@ -988,11 +1000,11 @@
   #
   # Returns +uri+ converted to a URI object.
   #
-  def URI(uri, parser = URI::DEFAULT_PARSER)
+  def URI(uri)
     if uri.is_a?(URI::Generic)
       uri
     elsif uri = String.try_convert(uri)
-      parser.parse(uri)
+      URI.parse(uri)
     else
       raise ArgumentError,
         "bad argument (expected URI object or URI string)"
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 32558)
+++ lib/uri/generic.rb	(revision 32559)
@@ -1239,7 +1239,7 @@
     # return base and rel.
     # you can modify `base', but can not `rel'.
     def merge0(oth)
-      oth = URI(oth, parser)
+      oth = parser.send(:convert_to_uri, oth)
 
       if self.relative? && oth.relative?
         raise BadURIError,
@@ -1302,7 +1302,7 @@
 
     # :stopdoc:
     def route_from0(oth)
-      oth = URI(oth, parser)
+      oth = parser.send(:convert_to_uri, oth)
       if self.relative?
         raise BadURIError,
           "relative URI: #{self}"
@@ -1410,7 +1410,7 @@
     #   #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1>
     #
     def route_to(oth)
-      URI(oth, parser).route_from(self)
+      parser.send(:convert_to_uri, oth).route_from(self)
     end
 
     #

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]