[Bps-public-commit] Path-Dispatcher branch, default-sequence, created. 64dc08a83deef91c60f846068931b0b4baca09b2

sartak at bestpractical.com sartak at bestpractical.com
Tue Mar 16 09:11:05 EDT 2010


The branch, default-sequence has been created
        at  64dc08a83deef91c60f846068931b0b4baca09b2 (commit)

- Log -----------------------------------------------------------------
commit 5e4d3668999b95ec42bd7d005c595eabff7c5f39
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 16 08:51:46 2010 -0400

    Add matcher for '' just in case

diff --git a/lib/Path/Dispatcher/Builder.pm b/lib/Path/Dispatcher/Builder.pm
index 3ffdab3..fda4276 100644
--- a/lib/Path/Dispatcher/Builder.pm
+++ b/lib/Path/Dispatcher/Builder.pm
@@ -188,6 +188,15 @@ sub rule_creators {
                 $block ? (block => $block) : (),
             ),
         },
+        # plain string
+        '' => sub {
+            my ($self, $string, $block) = @_;
+            Path::Dispatcher::Rule::Eq->new(
+                string         => $string,
+                case_sensitive => $self->case_sensitive_tokens,
+                $block ? (block => $block) : (),
+            ),
+        },
     };
 }
 

commit 64dc08a83deef91c60f846068931b0b4baca09b2
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 16 08:51:56 2010 -0400

    Top-level [] creates a Sequence now

diff --git a/lib/Path/Dispatcher/Builder.pm b/lib/Path/Dispatcher/Builder.pm
index fda4276..f46c6aa 100644
--- a/lib/Path/Dispatcher/Builder.pm
+++ b/lib/Path/Dispatcher/Builder.pm
@@ -139,17 +139,31 @@ sub redispatch_to {
     $self->_add_rule($redispatch);
 }
 
+our $INSIDE_SEQUENCE = 0;
 sub rule_creators {
     return {
         ARRAY => sub {
             my ($self, $tokens, $block) = @_;
 
-            Path::Dispatcher::Rule::Tokens->new(
-                tokens => $tokens,
+            if ($INSIDE_SEQUENCE) {
+                return Path::Dispatcher::Rule::Tokens->new(
+                    tokens => $tokens,
+                    case_sensitive => $self->case_sensitive_tokens,
+                    delimiter => $self->token_delimiter,
+                    $block ? (block => $block) : (),
+                );
+            }
+
+            my @rules = do {
+                local $INSIDE_SEQUENCE = 1;
+                map { $self->_create_rule($_) } @$tokens;
+            };
+
+            Path::Dispatcher::Rule::Sequence->new(
+                rules => \@rules,
                 delimiter => $self->token_delimiter,
-                case_sensitive => $self->case_sensitive_tokens,
                 $block ? (block => $block) : (),
-            ),
+            );
         },
         HASH => sub {
             my ($self, $metadata_matchers, $block) = @_;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list