ruby-changes:16703
From: marcandre <ko1@a...>
Date: Wed, 21 Jul 2010 13:38:55 +0900 (JST)
Subject: [ruby-changes:16703] Ruby:r28699 (trunk): * lib/uri/common.rb: Have URI#route_to, URI#route_from accept
marcandre 2010-07-21 13:38:40 +0900 (Wed, 21 Jul 2010) New Revision: 28699 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28699 Log: * lib/uri/common.rb: Have URI#route_to, URI#route_from accept string-like arguments [ruby-core:30961] * lib/uri/generic.rb: ditto for URI.join, URI#merge Modified files: trunk/ChangeLog trunk/lib/uri/common.rb trunk/lib/uri/generic.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 28698) +++ ChangeLog (revision 28699) @@ -1,3 +1,10 @@ +Wed Jul 21 13:37:35 2010 Marc-Andre Lafortune <ruby-core@m...> + + * lib/uri/common.rb: Have URI#route_to, URI#route_from accept + string-like arguments [ruby-core:30961] + + * lib/uri/generic.rb: ditto for URI.join, URI#merge + Wed Jul 21 12:39:15 2010 Yusuke Endoh <mame@t...> * lib/cmath.rb (CMath#cbrt): cbrt should accept a negative real Index: lib/uri/common.rb =================================================================== --- lib/uri/common.rb (revision 28698) +++ lib/uri/common.rb (revision 28699) @@ -185,13 +185,7 @@ end def join(*uris) - if uris[0].is_a?(URI::Generic) - elsif uri = String.try_convert(uris[0]) - uris[0] = self.parse(uri) - else - raise ArgumentError, - "bad argument(expected URI object or URI string)" - end + uris[0] = URI(uris[0], self) uris.inject :merge end @@ -844,11 +838,11 @@ # # Returns +uri+ converted to a URI object. # - def URI(uri) + def URI(uri, parser = URI::DEFAULT_PARSER) if uri.is_a?(URI::Generic) uri elsif uri = String.try_convert(uri) - URI.parse(uri) + parser.parse(uri) else raise ArgumentError, "bad argument (expected URI object or URI string)" Index: lib/uri/generic.rb =================================================================== --- lib/uri/generic.rb (revision 28698) +++ lib/uri/generic.rb (revision 28699) @@ -1,3 +1,4 @@ + # # = uri/generic.rb # @@ -783,14 +784,7 @@ # return base and rel. # you can modify `base', but can not `rel'. def merge0(oth) - case oth - when Generic - when String - oth = parser.parse(oth) - else - raise ArgumentError, - "bad argument(expected URI object or URI string)" - end + oth = URI(oth, parser) if self.relative? && oth.relative? raise BadURIError, @@ -854,15 +848,7 @@ private :route_from_path def route_from0(oth) - case oth - when Generic - when String - oth = parser.parse(oth) - else - raise ArgumentError, - "bad argument(expected URI object or URI string)" - end - + oth = URI(oth, parser) if self.relative? raise BadURIError, "relative URI: #{self}" @@ -966,16 +952,7 @@ # #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1> # def route_to(oth) - case oth - when Generic - when String - oth = parser.parse(oth) - else - raise ArgumentError, - "bad argument(expected URI object or URI string)" - end - - oth.route_from(self) + URI(oth, parser).route_from(self) end # -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/