[#30589] [Bug #3391] Use single exclamation mark instead of double exclamation mark for IRB — Diego Viola <redmine@...>

Bug #3391: Use single exclamation mark instead of double exclamation mark for IRB

10 messages 2010/06/04

[#30672] [Bug #3411] Time.local 1916,5,1 #=> 1916-04-30 23:00:00 +0100 — Benoit Daloze <redmine@...>

Bug #3411: Time.local 1916,5,1 #=> 1916-04-30 23:00:00 +0100

12 messages 2010/06/08

[#30699] [Bug #3419] 1.9.2-preview3 possible bug with Rails 3 active_record sqlite_adapter — Joe Sak <redmine@...>

Bug #3419: 1.9.2-preview3 possible bug with Rails 3 active_record sqlite_adapter

9 messages 2010/06/09

[#30734] [Bug #3428] ri outputs ansi escape sequences even when stdout is not a tty — caleb clausen <redmine@...>

Bug #3428: ri outputs ansi escape sequences even when stdout is not a tty

11 messages 2010/06/11

[#30756] [Feature #3436] Spawn the timer thread lazily — Maximilian Gass <redmine@...>

Feature #3436: Spawn the timer thread lazily

15 messages 2010/06/13
[#32686] [Ruby 1.9-Feature#3436] Spawn the timer thread lazily — Mark Somerville <redmine@...> 2010/10/04

Issue #3436 has been updated by Mark Somerville.

[ruby-core:30961] [Feature #3506] Kernel::URI with optional parser

From: Marc-Andre Lafortune <redmine@...>
Date: 2010-06-29 20:43:45 UTC
List: ruby-core #30961
Feature #3506: Kernel::URI with optional parser
http://redmine.ruby-lang.org/issues/show/3506

Author: Marc-Andre Lafortune
Status: Open, Priority: Low
Assigned to: akira yamada, Category: lib, Target version: 1.9.x

Kernel::URI could accept an optional parameter to specify a parser.

It could then be used in a couple of places in the library itself.

Patch follows:


diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index bda6718..f9f0a6a 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -185,14 +185,7 @@ module URI
     end
 
     def join(*uris)
-      case uris[0]
-      when Generic
-      when String
-        uris[0] = self.parse(uris[0])
-      else
-        raise ArgumentError,
-          "bad argument(expected URI object or URI string)"
-      end
+      uris[0] = URI(uris[0], self)
       uris.inject :merge
     end
 
@@ -845,12 +838,12 @@ module Kernel
   #
   # Returns +uri+ converted to a URI object.
   #
-  def URI(uri)
+  def URI(uri, parser = URI::DEFAULT_PARSER)
     case uri
     when URI::Generic
       uri
     when String
-      URI.parse(uri)
+      parser.parse(uri)
     else
       raise ArgumentError,
         "bad argument (expected URI object or URI string)"
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 4fdfd14..4084b56 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -783,14 +783,7 @@ module URI
     # 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 +847,7 @@ module URI
     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 +951,7 @@ module URI
     #   #=> #<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
 
     #


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next