[Bps-public-commit] Path-Dispatcher branch, complete, updated. cd6e2c20ccb9e7e2f5e931fcb7665be02e063a9f
sartak at bestpractical.com
sartak at bestpractical.com
Fri Dec 18 18:12:24 EST 2009
The branch, complete has been updated
via cd6e2c20ccb9e7e2f5e931fcb7665be02e063a9f (commit)
via fc46b77711f36fd3cfa9c5b1dc22958e76789ea6 (commit)
from 1c60e67ae7a60506437b3eb6fac82e66723e65fc (commit)
Summary of changes:
lib/Path/Dispatcher/Rule.pm | 4 ++++
lib/Path/Dispatcher/Rule/Eq.pm | 2 +-
t/300-complete-simple.t | 12 +++++++++++-
3 files changed, 16 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit fc46b77711f36fd3cfa9c5b1dc22958e76789ea6
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Dec 18 18:05:02 2009 -0500
Promote complete to a public method; stub for all Rules
diff --git a/lib/Path/Dispatcher/Rule.pm b/lib/Path/Dispatcher/Rule.pm
index 1dbafd4..83ccbe5 100644
--- a/lib/Path/Dispatcher/Rule.pm
+++ b/lib/Path/Dispatcher/Rule.pm
@@ -67,6 +67,10 @@ sub match {
return $match;
}
+sub complete {
+ return (); # no completions
+}
+
sub _prefix_match {
my $self = shift;
return $self->_match(@_);
diff --git a/lib/Path/Dispatcher/Rule/Eq.pm b/lib/Path/Dispatcher/Rule/Eq.pm
index b0f3b10..dd7138a 100644
--- a/lib/Path/Dispatcher/Rule/Eq.pm
+++ b/lib/Path/Dispatcher/Rule/Eq.pm
@@ -25,7 +25,7 @@ sub _prefix_match {
return (1, substr($path->path, length($self->string)));
}
-sub _complete {
+sub complete {
my $self = shift;
my $path = shift->path;
my $completed = $self->string;
commit cd6e2c20ccb9e7e2f5e931fcb7665be02e063a9f
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Dec 18 18:07:36 2009 -0500
Test completing on an individual rule
diff --git a/t/300-complete-simple.t b/t/300-complete-simple.t
index cc35ddc..cb5c512 100644
--- a/t/300-complete-simple.t
+++ b/t/300-complete-simple.t
@@ -1,7 +1,17 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 16;
+use Path::Dispatcher;
+
+my $complete = Path::Dispatcher::Rule::Eq->new(string => "complete");
+is_deeply([$complete->complete(Path::Dispatcher::Path->new('x'))], []);
+is_deeply([$complete->complete(Path::Dispatcher::Path->new('completexxx'))], []);
+is_deeply([$complete->complete(Path::Dispatcher::Path->new('cxxx'))], []);
+
+is_deeply([$complete->complete(Path::Dispatcher::Path->new('c'))], ['complete']);
+is_deeply([$complete->complete(Path::Dispatcher::Path->new('compl'))], ['complete']);
+is_deeply([$complete->complete(Path::Dispatcher::Path->new('complete'))], ['complete']);
do {
package MyApp::Dispatcher;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list