ruby-changes:20512
From: marcandre <ko1@a...>
Date: Sat, 16 Jul 2011 06:36:33 +0900 (JST)
Subject: [ruby-changes:20512] marcandRe: r32560 (ruby_1_9_3): * Backport of r32559 from trunk
marcandre 2011-07-16 06:32:02 +0900 (Sat, 16 Jul 2011) New Revision: 32560 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32560 Log: * Backport of r32559 from trunk * lib/uri/common.rb (module): Remove optional parser argument to Kernel#URI [ruby-core:38061] * lib/uri/generic.rb (module): ditto Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/lib/uri/common.rb branches/ruby_1_9_3/lib/uri/generic.rb Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 32559) +++ ruby_1_9_3/ChangeLog (revision 32560) @@ -1,3 +1,11 @@ +Sat Jul 16 06:31:23 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 01:15:53 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * time.c (time_dup): used rb_obj_class() instead of CLASS_OF(). Index: ruby_1_9_3/lib/uri/common.rb =================================================================== --- ruby_1_9_3/lib/uri/common.rb (revision 32559) +++ ruby_1_9_3/lib/uri/common.rb (revision 32560) @@ -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: ruby_1_9_3/lib/uri/generic.rb =================================================================== --- ruby_1_9_3/lib/uri/generic.rb (revision 32559) +++ ruby_1_9_3/lib/uri/generic.rb (revision 32560) @@ -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/