<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/rack/router/parsing.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -19,4 +19,9 @@ Some points for discussion:
   Currently with env['rack_router.route']
 * Should I allow an arbitrary hash to be set on the route (so that you
   can track any information).
-* How should multiple request objects be handled in context of mounting.
\ No newline at end of file
+* How should multiple request objects be handled in context of mounting.
+
+
+
+
+* Be able to provide route paths using the internal array / string / symbol representation
\ No newline at end of file</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -28,6 +28,7 @@ module Rack
     autoload :Route,         'rack/router/route'
     autoload :Condition,     'rack/router/condition'
     autoload :PathCondition, 'rack/router/condition'
+    autoload :Parsing,       'rack/router/parsing'
     autoload :Builder,       'rack/router/builders'
     autoload :Utils,         'rack/router/utils'
     </diff>
      <filename>lib/rack/router.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,12 +19,19 @@ class Rack::Router::Builder
     
     def map(*args)
       options = args.last.is_a?(Hash) ? args.pop : {}
-      
+
       path   = args[0]
       method = args[1]
       
-      conditions                  = options[:conditions] || {}
-      conditions[:path_info]      = path if path
+      conditions = options[:conditions] || {}
+      conditions.each { |k,v| conditions[k] = v.to_s unless v.is_a?(Regexp) }
+      
+      if path
+        conditions[:path_info] = Rack::Router::Parsing.parse(path) do |segment_name, delimiter|
+          conditions[segment_name] = /.+/ if delimiter == '*'
+        end
+      end
+      
       conditions[:request_method] = upcase_method(method) if method
       
       route = Rack::Router::Route.new(options[:to], options[:at], conditions.reject { |k,v| k == :id }, conditions.dup, options[:with] || {}, !options[:anchor])</diff>
      <filename>lib/rack/router/builders/simple.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,5 @@
 class Rack::Router
-  SEGMENT_REGEXP          = /(?:(:|\*)([a-z](?:_?[a-z0-9])*))/i
-  OPTIONAL_SEGMENT_REGEXP = /^(?:|.*?[^\\])(?:\\\\)*([\(\)])/ 
-  ESCAPED_REGEXP          = /(?:^|[^\\])\\(?:\\\\)*$/
-  SEGMENT_CHARACTERS      = &quot;[^\/.,;?]&quot;.freeze
+  SEGMENT_CHARACTERS = &quot;[^\/.,;?]&quot;.freeze
   
   class Condition
     def self.register(type)
@@ -17,21 +14,22 @@ class Rack::Router
     attr_reader :segments, :captures
 
     def initialize(method_name, pattern, conditions, anchored)
-      @method_name = method_name
-      @segments    = {}
-      @captures    = {}
-      @conditions  = conditions.dup
-      @anchored    = anchored
+      @method_name  = method_name
+      @segments     = {}
+      @captures     = {}
+      @conditions   = conditions.dup
+      @anchored     = anchored
 
       @conditions.default = /#{SEGMENT_CHARACTERS}+/
-
-      case pattern
-      when String
-        @segments = parse_segments_with_optionals(pattern.dup)
+      
+      if pattern.is_a?(Array) || pattern.is_a?(String)
+        @segments = pattern.is_a?(Array) ? pattern : [pattern]
         @pattern  = Regexp.new(anchor(compile(@segments)))
         @captures = captures_for(@segments)
+      elsif pattern.is_a?(Regexp)
+        @pattern = pattern
       else
-        @pattern = convert_to_regexp(pattern)
+        raise ArgumentError, &quot;the condition pattern must be an Array (tokens), String, or Regexp&quot;
       end
     end
 
@@ -40,6 +38,10 @@ class Rack::Router
         return data[0], extract_captures(data)
       end
     end
+    
+    def generatable?
+      !@segments.nil?
+    end
 
     def generate(params, defaults = {})
       raise &quot;Condition cannot be generated&quot; unless @segments
@@ -52,58 +54,6 @@ class Rack::Router
 
   private
 
-    # TODO: Handle escaped characters (parenthesis, colon, etc..)
-    def parse_segments_with_optionals(pattern, nest_level = 0)
-      segments = []
-
-      # Extract all the segments at this parenthesis level
-      while segment = pattern.slice!(OPTIONAL_SEGMENT_REGEXP)
-        # Append the segments that we came across so far
-        # at this level
-        segments.concat parse_segments(segment[0..-2]) if segment.length &gt; 1
-        # If the parenthesis that we came across is an opening
-        # then we need to jump to the higher level
-        if segment[-1, 1] == '('
-          segments &lt;&lt; parse_segments_with_optionals(pattern, nest_level + 1)
-        else
-          # Throw an error if we can't actually go back down (aka syntax error)
-          raise ArgumentError, &quot;There are too many closing parentheses&quot; if nest_level == 0
-          return segments
-        end
-      end
-
-      # Save any last bit of the string that didn't match the original regex
-      segments.concat parse_segments(pattern) unless pattern.empty?
-
-      # Throw an error if the string should not actually be done (aka syntax error)
-      raise ArgumentError, &quot;You have too many opening parentheses&quot; unless nest_level == 0
-
-      segments
-    end
-
-    def parse_segments(path)
-      segments = []
-
-      while match = (path.match(SEGMENT_REGEXP))
-        segment_name = match[2].to_sym
-        
-        # Handle false-positives due to escaped special characters
-        if match.pre_match =~ ESCAPED_REGEXP
-          segments &lt;&lt; &quot;#{match.pre_match[0..-2]}#{match[0]}&quot;
-        else
-          segments &lt;&lt; match.pre_match unless match.pre_match.empty?
-          segments &lt;&lt; segment_name
-        
-          @conditions[segment_name] = /.+/ if match[1] == '*'
-        end
-        
-        path = match.post_match
-      end
-
-      segments &lt;&lt; path unless path.empty?
-      segments
-    end
-
     def compile(segments)
       compiled = segments.map do |segment|
         case segment</diff>
      <filename>lib/rack/router/condition.rb</filename>
    </modified>
    <modified>
      <diff>@@ -53,7 +53,7 @@ describe &quot;When generating URLs&quot; do
   describe &quot;a router with an informal protocol&quot; do
     
     before(:each) do
-      pending
+      pending &quot;I'm not sure that this is thought out as well as it could be&quot;
     end
     
     it &quot;just works&quot; do</diff>
      <filename>spec/generation/dependencies_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -63,9 +63,9 @@ describe &quot;When recognizing requests&quot; do
       route_for(&quot;&quot;, :method =&gt; &quot;get&quot;).should be_missing
     end
     
-    it &quot;combines Array elements using OR&quot; do
+    it &quot;can use a regular expression to specify OR&quot; do
       prepare do |r|
-        r.map nil, [:get, :post], :to =&gt; HelloApp, :with =&gt; { :action =&gt; &quot;index&quot; }
+        r.map nil, /get|post/i, :to =&gt; HelloApp, :with =&gt; { :action =&gt; &quot;index&quot; }
       end
       
       route_for('/anything', :method =&gt; &quot;get&quot;).should    have_route(HelloApp, :action =&gt; &quot;index&quot;)
@@ -74,18 +74,6 @@ describe &quot;When recognizing requests&quot; do
       route_for('/anything', :method =&gt; &quot;delete&quot;).should be_missing
     end
     
-    it &quot;handles Regexps inside of condition arrays&quot; do
-      prepare do |r|
-        r.map nil, [/^g[aeiou]?t$/i, :post], :to =&gt; HelloApp
-      end
-      
-      route_for('/anything', :method =&gt; &quot;get&quot;).should    have_route(HelloApp)
-      route_for('/anything', :method =&gt; &quot;got&quot;).should    have_route(HelloApp)
-      route_for('/anything', :method =&gt; &quot;post&quot;).should   have_route(HelloApp)
-      route_for('/anything', :method =&gt; &quot;put&quot;).should    be_missing
-      route_for('/anything', :method =&gt; &quot;delete&quot;).should be_missing
-    end
-    
     it &quot;ignores nil values&quot; do
       prepare do |r|
         r.map &quot;/hello&quot;, :method =&gt; nil, :to =&gt; HelloApp
@@ -116,9 +104,9 @@ describe &quot;When recognizing requests&quot; do
         route_for(&quot;/foo&quot;, :scheme =&gt; &quot;https&quot;).should be_missing
       end
 
-      it &quot;combines Array elements using OR&quot; do
+      it &quot;can use regular expressions&quot; do
         prepare do |r|
-          r.map &quot;/hello&quot;, [:get, :post], :to =&gt; HelloApp
+          r.map &quot;/hello&quot;, /get|post/i, :to =&gt; HelloApp
         end
 
         route_for(&quot;/hello&quot;,   :method =&gt; &quot;get&quot;).should    have_route(HelloApp)</diff>
      <filename>spec/recognition/conditions_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8bafbe4b772678214f7f818897d76f31a81580dd</id>
    </parent>
  </parents>
  <author>
    <name>Carl Lerche</name>
    <email>carllerche@mac.com</email>
  </author>
  <url>http://github.com/carllerche/rack-router/commit/459f83d5d6829e8ac4808ef831602c54db10346c</url>
  <id>459f83d5d6829e8ac4808ef831602c54db10346c</id>
  <committed-date>2009-04-13T20:22:54-07:00</committed-date>
  <authored-date>2009-04-13T20:22:54-07:00</authored-date>
  <message>Refactored the plugin API to accept a simple token representation of a condition that allows generation</message>
  <tree>554455c1023c9ec0091b47e2b892fbbe266de844</tree>
  <committer>
    <name>Carl Lerche</name>
    <email>carllerche@mac.com</email>
  </committer>
</commit>
