[Bps-public-commit] Path-Dispatcher-Debugger branch, master, updated. 8956bdce394c13228184ad83f55d2e15ab409ef2

sartak at bestpractical.com sartak at bestpractical.com
Wed Dec 23 14:55:28 EST 2009


The branch, master has been updated
       via  8956bdce394c13228184ad83f55d2e15ab409ef2 (commit)
       via  b08cefb82e1132537d9d69e754c21b80b9623f6e (commit)
      from  de77e52e45800e2c3a4df237370c44a823e51beb (commit)

Summary of changes:
 lib/Path/Dispatcher/Debugger/View.pm |   41 +++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit b08cefb82e1132537d9d69e754c21b80b9623f6e
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Dec 23 14:54:48 2009 -0500

    Allow including extra information in display_rule

diff --git a/lib/Path/Dispatcher/Debugger/View.pm b/lib/Path/Dispatcher/Debugger/View.pm
index ea5ab52..8b549b5 100644
--- a/lib/Path/Dispatcher/Debugger/View.pm
+++ b/lib/Path/Dispatcher/Debugger/View.pm
@@ -110,6 +110,9 @@ sub display_rules {
 
 sub display_rule {
     my ($rule) = @_;
+    my $extra;
+
+    ($rule, $extra) = @$rule if ref($rule) eq 'ARRAY';
 
     if ($rule->isa('Path::Dispatcher::Rule::Tokens')) {
         tt { $rule->readable_attributes };
@@ -125,8 +128,10 @@ sub display_rule {
         outs '/';
     }
     else {
-        blessed($rule);
+        outs blessed($rule);
     }
+
+    span { $extra } if defined $extra;
 }
 
 1;

commit 8956bdce394c13228184ad83f55d2e15ab409ef2
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Dec 23 14:54:57 2009 -0500

    Implement completion testing

diff --git a/lib/Path/Dispatcher/Debugger/View.pm b/lib/Path/Dispatcher/Debugger/View.pm
index 8b549b5..cd034c8 100644
--- a/lib/Path/Dispatcher/Debugger/View.pm
+++ b/lib/Path/Dispatcher/Debugger/View.pm
@@ -81,20 +81,46 @@ template testing_form => sub {
 
 template matching_rules => sub {
     my ($self, $request, $debugger) = @_;
+
     my $path = $request->param('test_path');
     $path = '' if !defined($path);
 
+    my $type = $request->param('dispatch_type') || 'dispatch';
+
     div {
         attr {
             id => 'matching_rules',
         };
         h3 { "Matching: $path" };
 
-        my $dispatch = $debugger->dispatcher->dispatch($path);
-        my %seen = map { $_ => 1 } map { $_->rule } $dispatch->matches;
+        if ($type eq 'completion') {
+            my @matches;
+            my @not_matches;
+
+            for my $rule ($debugger->dispatcher->rules) {
+                my @completions = $rule->complete($path);
+                if (@completions) {
+                    push @matches, [$rule, join ', ', @completions];
+                }
+                else {
+                    push @not_matches, $rule;
+                }
+            }
 
-        display_rules(grep {  $seen{$_} } $debugger->dispatcher->rules);
-        display_rules(grep { !$seen{$_} } $debugger->dispatcher->rules);
+            h5 { "Matched Rules" };
+            display_rules(@matches);
+            h5 { "Unmatched Rules" };
+            display_rules(@not_matches);
+        }
+        else {
+            my $dispatch = $debugger->dispatcher->dispatch($path);
+            my %seen = map { $_ => 1 } map { $_->rule } $dispatch->matches;
+
+            h5 { "Matched Rules" };
+            display_rules(grep {  $seen{$_} } $debugger->dispatcher->rules);
+            h5 { "Unmatched Rules" };
+            display_rules(grep { !$seen{$_} } $debugger->dispatcher->rules);
+        }
     };
 };
 

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



More information about the Bps-public-commit mailing list