[Bps-public-commit] Path-Dispatcher branch, complete, updated. a379380aa70134d1b317932743e7c03e1d4e5bf4

sartak at bestpractical.com sartak at bestpractical.com
Fri Dec 18 19:34:15 EST 2009


The branch, complete has been updated
       via  a379380aa70134d1b317932743e7c03e1d4e5bf4 (commit)
       via  cb47b4b9aaa3aae550b94d0d169ef5852d47c16f (commit)
      from  8fe3edd918ea18f494d380af3432aa04997ddb1d (commit)

Summary of changes:
 lib/Path/Dispatcher/Rule/Tokens.pm |    5 ++++-
 lib/Path/Dispatcher/Rule/Under.pm  |    9 ++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit cb47b4b9aaa3aae550b94d0d169ef5852d47c16f
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Dec 18 19:33:04 2009 -0500

    First stab at making delimiters work better

diff --git a/lib/Path/Dispatcher/Rule/Under.pm b/lib/Path/Dispatcher/Rule/Under.pm
index 4b270d1..35574fc 100644
--- a/lib/Path/Dispatcher/Rule/Under.pm
+++ b/lib/Path/Dispatcher/Rule/Under.pm
@@ -50,7 +50,14 @@ sub complete {
 
     my $prefix = substr($path->path, 0, length($path->path) - length($new_path->path));
 
-    return map { "$prefix $_" } map { $_->complete($new_path) } $self->rules;
+    my @completions = map { $_->complete($new_path) } $self->rules;
+
+    if ($predicate->can('untokenize')) {
+        return map { $predicate->untokenize($prefix, $_) } @completions;
+    }
+    else {
+        return map { "$prefix$_" } @completions;
+    }
 }
 
 sub readable_attributes { shift->predicate->readable_attributes }

commit a379380aa70134d1b317932743e7c03e1d4e5bf4
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Dec 18 19:34:04 2009 -0500

    Remove excess delimiters in untokenize

diff --git a/lib/Path/Dispatcher/Rule/Tokens.pm b/lib/Path/Dispatcher/Rule/Tokens.pm
index 8e4fb86..22367c8 100644
--- a/lib/Path/Dispatcher/Rule/Tokens.pm
+++ b/lib/Path/Dispatcher/Rule/Tokens.pm
@@ -120,7 +120,10 @@ sub tokenize {
 sub untokenize {
     my $self   = shift;
     my @tokens = @_;
-    return join $self->delimiter, @tokens;
+    return join $self->delimiter,
+           grep { length }
+           map { split $self->delimiter, $_ }
+           @tokens;
 }
 
 sub readable_attributes {

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



More information about the Bps-public-commit mailing list