[Bps-public-commit] Path-Dispatcher branch, pass-match, updated. 1149ef8acbfeafdd39066b3d830a5022abbf8a7f

Shawn Moore sartak at bestpractical.com
Sun Oct 17 04:04:30 EDT 2010


The branch, pass-match has been updated
       via  1149ef8acbfeafdd39066b3d830a5022abbf8a7f (commit)
       via  1e967eabd75df13906d0cd1535d39b6c773dda91 (commit)
       via  e63ba10544ea43928b250ee338d19506d217cb37 (commit)
       via  a184e65ba3cfa4ac6ea669b46eb518c5357e820b (commit)
       via  432fb42bd49b93ddbb9a351a76067e99f336f9c4 (commit)
       via  5c528bf5a0cc7d773975074c646cd846ce81c06c (commit)
       via  a9426dd3e631e368f941b665febf179dbbd01dd5 (commit)
       via  8ea24b6b8795de3ed5ba5738e0af41ef131f8aee (commit)
       via  865df9dc05cd3a1469f80c58c8a23b19aeaa5aa2 (commit)
       via  ecc47f58c32006b1cfcc5357a98dc9c0662608d0 (commit)
       via  aa383ce72217273855dd608a1ebd4d7a420dc362 (commit)
       via  a435ea3cf02e9cf5510bc92f44fc11cc2ed8cb03 (commit)
       via  e91d9d65cd652f376bdbb2a854fe8ff1ea6ab990 (commit)
       via  92d489c824436af10f01b962ae416cbd27b7e922 (commit)
      from  8d0b049f3349f33dbc1991166870da62b1bdd257 (commit)

Summary of changes:
 Changes                              |   22 +++++++++--
 inc/Module/Install.pm                |   10 ++++--
 inc/Module/Install/Base.pm           |    2 +-
 inc/Module/Install/Can.pm            |    2 +-
 inc/Module/Install/Fetch.pm          |    2 +-
 inc/Module/Install/Makefile.pm       |    2 +-
 inc/Module/Install/Metadata.pm       |    2 +-
 inc/Module/Install/Win32.pm          |    2 +-
 inc/Module/Install/WriteAll.pm       |    2 +-
 lib/Path/Dispatcher.pm               |   29 ++++-----------
 lib/Path/Dispatcher/Cookbook.pod     |   25 ++++++-------
 lib/Path/Dispatcher/Dispatch.pm      |    7 +---
 lib/Path/Dispatcher/Match.pm         |   18 ++++++---
 lib/Path/Dispatcher/Path.pm          |    4 +-
 lib/Path/Dispatcher/Role/Rules.pm    |    2 +-
 lib/Path/Dispatcher/Rule.pm          |   67 ++--------------------------------
 lib/Path/Dispatcher/Rule/Chain.pm    |    2 -
 lib/Path/Dispatcher/Rule/CodeRef.pm  |   11 +-----
 lib/Path/Dispatcher/Rule/Dispatch.pm |    4 +--
 lib/Path/Dispatcher/Rule/Enum.pm     |    8 ++---
 lib/Path/Dispatcher/Rule/Eq.pm       |    8 ++---
 lib/Path/Dispatcher/Rule/Metadata.pm |   11 +-----
 lib/Path/Dispatcher/Rule/Regex.pm    |   11 ++----
 lib/Path/Dispatcher/Rule/Sequence.pm |    2 +-
 lib/Path/Dispatcher/Rule/Tokens.pm   |   60 ++++---------------------------
 lib/Path/Dispatcher/Rule/Under.pm    |    6 +--
 t/001-api.t                          |    2 +-
 t/002-rule.t                         |    5 ++-
 t/014-tokens-prefix.t                |    4 +--
 29 files changed, 101 insertions(+), 231 deletions(-)

- Log -----------------------------------------------------------------
commit 92d489c824436af10f01b962ae416cbd27b7e922
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 15:53:26 2010 +0900

    Fix release year of 0.15

diff --git a/Changes b/Changes
index 8f5d961..88d0658 100644
--- a/Changes
+++ b/Changes
@@ -6,7 +6,7 @@ Revision history for Path-Dispatcher
 
         Add documentation for shell tab completion
 
-0.15 Tue Mar 16 09:40:40 2009
+0.15 Tue Mar 16 09:40:40 2010
         ** Factored Path-Dispatcher-Declarative into its own distribution
         ** Be sure to update your dependency lists!
 

commit e91d9d65cd652f376bdbb2a854fe8ff1ea6ab990
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:00:00 2010 +0900

    Make all readwrite attributes readonly

diff --git a/lib/Path/Dispatcher.pm b/lib/Path/Dispatcher.pm
index b69beaf..bf66a91 100644
--- a/lib/Path/Dispatcher.pm
+++ b/lib/Path/Dispatcher.pm
@@ -14,7 +14,7 @@ use constant path_class     => 'Path::Dispatcher::Path';
 with 'Path::Dispatcher::Role::Rules';
 
 has name => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'Str',
     default => do {
         my $i = 0;
diff --git a/lib/Path/Dispatcher/Dispatch.pm b/lib/Path/Dispatcher/Dispatch.pm
index 54e56db..453211c 100644
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@ -4,7 +4,7 @@ use Any::Moose;
 use Path::Dispatcher::Match;
 
 has _matches => (
-    is        => 'rw',
+    is        => 'ro',
     isa       => 'ArrayRef',
     default   => sub { [] },
 );
diff --git a/lib/Path/Dispatcher/Match.pm b/lib/Path/Dispatcher/Match.pm
index 7ade7ca..8d37ffb 100644
--- a/lib/Path/Dispatcher/Match.pm
+++ b/lib/Path/Dispatcher/Match.pm
@@ -5,30 +5,30 @@ use Path::Dispatcher::Path;
 use Path::Dispatcher::Rule;
 
 has path => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'Path::Dispatcher::Path',
     required => 1,
 );
 
 has leftover => (
-    is  => 'rw',
+    is  => 'ro',
     isa => 'Str',
 );
 
 has rule => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'Path::Dispatcher::Rule',
     required => 1,
 );
 
 has positional_captures => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'ArrayRef[Str|Undef]',
     default => sub { [] },
 );
 
 has named_captures => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'HashRef[Str|Undef]',
     default => sub { {} },
 );
diff --git a/lib/Path/Dispatcher/Path.pm b/lib/Path/Dispatcher/Path.pm
index c5b04c7..fdd0fae 100644
--- a/lib/Path/Dispatcher/Path.pm
+++ b/lib/Path/Dispatcher/Path.pm
@@ -4,13 +4,13 @@ use Any::Moose;
 use overload q{""} => sub { shift->path };
 
 has path => (
-    is        => 'rw',
+    is        => 'ro',
     isa       => 'Str',
     predicate => 'has_path',
 );
 
 has metadata => (
-    is        => 'rw',
+    is        => 'ro',
     isa       => 'HashRef',
     predicate => 'has_metadata',
 );
diff --git a/lib/Path/Dispatcher/Role/Rules.pm b/lib/Path/Dispatcher/Role/Rules.pm
index f05d3e6..f763af0 100644
--- a/lib/Path/Dispatcher/Role/Rules.pm
+++ b/lib/Path/Dispatcher/Role/Rules.pm
@@ -2,7 +2,7 @@ package Path::Dispatcher::Role::Rules;
 use Any::Moose '::Role';
 
 has _rules => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'ArrayRef',
     init_arg => 'rules',
     default  => sub { [] },
diff --git a/lib/Path/Dispatcher/Rule.pm b/lib/Path/Dispatcher/Rule.pm
index 3081c03..dbb2203 100644
--- a/lib/Path/Dispatcher/Rule.pm
+++ b/lib/Path/Dispatcher/Rule.pm
@@ -6,19 +6,19 @@ use Path::Dispatcher::Match;
 use constant match_class => "Path::Dispatcher::Match";
 
 has block => (
-    is        => 'rw',
+    is        => 'ro',
     isa       => 'CodeRef',
     predicate => 'has_block',
 );
 
 has prefix => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'Bool',
     default => 0,
 );
 
 has name => (
-    is        => 'rw',
+    is        => 'ro',
     isa       => 'Str',
     predicate => 'has_name',
 );
diff --git a/lib/Path/Dispatcher/Rule/CodeRef.pm b/lib/Path/Dispatcher/Rule/CodeRef.pm
index e8609da..54a2339 100644
--- a/lib/Path/Dispatcher/Rule/CodeRef.pm
+++ b/lib/Path/Dispatcher/Rule/CodeRef.pm
@@ -3,7 +3,7 @@ use Any::Moose;
 extends 'Path::Dispatcher::Rule';
 
 has matcher => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'CodeRef',
     required => 1,
 );
diff --git a/lib/Path/Dispatcher/Rule/Dispatch.pm b/lib/Path/Dispatcher/Rule/Dispatch.pm
index a76ddc4..d87e955 100644
--- a/lib/Path/Dispatcher/Rule/Dispatch.pm
+++ b/lib/Path/Dispatcher/Rule/Dispatch.pm
@@ -3,7 +3,7 @@ use Any::Moose;
 extends 'Path::Dispatcher::Rule';
 
 has dispatcher => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'Path::Dispatcher',
     required => 1,
     handles  => ['rules', 'complete'],
diff --git a/lib/Path/Dispatcher/Rule/Enum.pm b/lib/Path/Dispatcher/Rule/Enum.pm
index dd20ea4..0025cb6 100644
--- a/lib/Path/Dispatcher/Rule/Enum.pm
+++ b/lib/Path/Dispatcher/Rule/Enum.pm
@@ -3,13 +3,13 @@ use Any::Moose;
 extends 'Path::Dispatcher::Rule';
 
 has enum => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'ArrayRef[Str]',
     required => 1,
 );
 
 has case_sensitive => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'Bool',
     default => 1,
 );
diff --git a/lib/Path/Dispatcher/Rule/Eq.pm b/lib/Path/Dispatcher/Rule/Eq.pm
index e0a7554..37ff30d 100644
--- a/lib/Path/Dispatcher/Rule/Eq.pm
+++ b/lib/Path/Dispatcher/Rule/Eq.pm
@@ -3,13 +3,13 @@ use Any::Moose;
 extends 'Path::Dispatcher::Rule';
 
 has string => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'Str',
     required => 1,
 );
 
 has case_sensitive => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'Bool',
     default => 1,
 );
diff --git a/lib/Path/Dispatcher/Rule/Metadata.pm b/lib/Path/Dispatcher/Rule/Metadata.pm
index e25b47b..4b9b3c6 100644
--- a/lib/Path/Dispatcher/Rule/Metadata.pm
+++ b/lib/Path/Dispatcher/Rule/Metadata.pm
@@ -3,13 +3,13 @@ use Any::Moose;
 extends 'Path::Dispatcher::Rule';
 
 has field => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'Str',
     required => 1,
 );
 
 has matcher => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'Path::Dispatcher::Rule',
     required => 1,
 );
diff --git a/lib/Path/Dispatcher/Rule/Regex.pm b/lib/Path/Dispatcher/Rule/Regex.pm
index 141df64..df5125c 100644
--- a/lib/Path/Dispatcher/Rule/Regex.pm
+++ b/lib/Path/Dispatcher/Rule/Regex.pm
@@ -3,7 +3,7 @@ use Any::Moose;
 extends 'Path::Dispatcher::Rule';
 
 has regex => (
-    is       => 'rw',
+    is       => 'ro',
     isa      => 'RegexpRef',
     required => 1,
 );
diff --git a/lib/Path/Dispatcher/Rule/Sequence.pm b/lib/Path/Dispatcher/Rule/Sequence.pm
index c50ecf0..1155f5c 100644
--- a/lib/Path/Dispatcher/Rule/Sequence.pm
+++ b/lib/Path/Dispatcher/Rule/Sequence.pm
@@ -5,7 +5,7 @@ extends 'Path::Dispatcher::Rule';
 with 'Path::Dispatcher::Role::Rules';
 
 has delimiter => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'Str',
     default => ' ',
 );
diff --git a/lib/Path/Dispatcher/Rule/Tokens.pm b/lib/Path/Dispatcher/Rule/Tokens.pm
index 6e01f57..472e8be 100644
--- a/lib/Path/Dispatcher/Rule/Tokens.pm
+++ b/lib/Path/Dispatcher/Rule/Tokens.pm
@@ -3,20 +3,20 @@ use Any::Moose;
 extends 'Path::Dispatcher::Rule';
 
 has tokens => (
-    is         => 'rw',
+    is         => 'ro',
     isa        => 'ArrayRef',
     auto_deref => 1,
     required   => 1,
 );
 
 has delimiter => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'Str',
     default => ' ',
 );
 
 has case_sensitive => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => 'Bool',
     default => 1,
 );
diff --git a/lib/Path/Dispatcher/Rule/Under.pm b/lib/Path/Dispatcher/Rule/Under.pm
index 35574fc..d38ce51 100644
--- a/lib/Path/Dispatcher/Rule/Under.pm
+++ b/lib/Path/Dispatcher/Rule/Under.pm
@@ -11,7 +11,7 @@ subtype 'Path::Dispatcher::PrefixRule'
      => message { "This rule ($_) does not match just prefixes!" };
 
 has predicate => (
-    is  => 'rw',
+    is  => 'ro',
     isa => 'Path::Dispatcher::PrefixRule',
 );
 

commit a435ea3cf02e9cf5510bc92f44fc11cc2ed8cb03
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:04:21 2010 +0900

    Make _dispatch rule

diff --git a/lib/Path/Dispatcher.pm b/lib/Path/Dispatcher.pm
index bf66a91..1daa15f 100644
--- a/lib/Path/Dispatcher.pm
+++ b/lib/Path/Dispatcher.pm
@@ -32,7 +32,7 @@ sub dispatch {
     my $dispatch = $self->dispatch_class->new;
 
     for my $rule ($self->rules) {
-        $self->dispatch_rule(
+        $self->_dispatch_rule(
             rule     => $rule,
             dispatch => $dispatch,
             path     => $path,
@@ -42,7 +42,7 @@ sub dispatch {
     return $dispatch;
 }
 
-sub dispatch_rule {
+sub _dispatch_rule {
     my $self = shift;
     my %args = @_;
 

commit aa383ce72217273855dd608a1ebd4d7a420dc362
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:02:47 2010 +0900

    0.16 changes

diff --git a/Changes b/Changes
index 88d0658..23fc04e 100644
--- a/Changes
+++ b/Changes
@@ -1,8 +1,17 @@
 Revision history for Path-Dispatcher
 
 0.16
-        Use glob assignment for populating capture variables instead of a
-            regular expression, thanks to chromatic
+        ** BACKWARDS INCOMPATIBLE CHANGE: Pass the match object into rule
+        **    blocks rather than assigning $1, $2, $3. Use ->pos(1), (2), (3),
+        **    etc. instead. This cleans up the code a lot and makes
+        **    Path-Dispatcher more flexible.
+
+        Add support for named captures
+
+        Make all attributes read-only. If you need something to be read-write,
+            I am open to such a change. Just let me know!
+
+        Make _dispatcher_rule private
 
         Add documentation for shell tab completion
 

commit ecc47f58c32006b1cfcc5357a98dc9c0662608d0
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:13:31 2010 +0900

    Remove trace/name/readable_attributes
    
        This wants to be implemented in a better way. AOP..?

diff --git a/Changes b/Changes
index 23fc04e..31200fd 100644
--- a/Changes
+++ b/Changes
@@ -13,6 +13,9 @@ Revision history for Path-Dispatcher
 
         Make _dispatcher_rule private
 
+        Remove trace/readable_attribute/name support. This wants to be
+            implemented in a different, better, more comprehensive way.
+
         Add documentation for shell tab completion
 
 0.15 Tue Mar 16 09:40:40 2010
diff --git a/lib/Path/Dispatcher.pm b/lib/Path/Dispatcher.pm
index 1daa15f..d705d02 100644
--- a/lib/Path/Dispatcher.pm
+++ b/lib/Path/Dispatcher.pm
@@ -13,18 +13,6 @@ use constant path_class     => 'Path::Dispatcher::Path';
 
 with 'Path::Dispatcher::Role::Rules';
 
-has name => (
-    is      => 'ro',
-    isa     => 'Str',
-    default => do {
-        my $i = 0;
-        sub {
-            my $self = shift;
-            join '-', blessed($self), ++$i;
-        },
-    },
-);
-
 sub dispatch {
     my $self = shift;
     my $path = $self->_autobox_path(shift);
@@ -137,11 +125,6 @@ inspired by L<Jifty::Dispatcher>.
 
 A list of L<Path::Dispatcher::Rule> objects.
 
-=head2 name
-
-A human-readable name; this will be used in the debugging hooks. In
-L<Path::Dispatcher::Declarative>, this is the package name of the dispatcher.
-
 =head1 METHODS
 
 =head2 add_rule
diff --git a/lib/Path/Dispatcher/Dispatch.pm b/lib/Path/Dispatcher/Dispatch.pm
index 453211c..e361f70 100644
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@ -37,9 +37,6 @@ sub run {
         eval {
             local $SIG{__DIE__} = 'DEFAULT';
 
-            $match->rule->trace(running => 1, match => $match)
-                if $ENV{PATH_DISPATCHER_TRACE};
-
             push @results, $match->run(@args);
 
             die "Path::Dispatcher abort\n";
diff --git a/lib/Path/Dispatcher/Rule.pm b/lib/Path/Dispatcher/Rule.pm
index dbb2203..07d3330 100644
--- a/lib/Path/Dispatcher/Rule.pm
+++ b/lib/Path/Dispatcher/Rule.pm
@@ -17,12 +17,6 @@ has prefix => (
     default => 0,
 );
 
-has name => (
-    is        => 'ro',
-    isa       => 'Str',
-    predicate => 'has_name',
-);
-
 sub match {
     my $self = shift;
     my $path = shift;
@@ -48,8 +42,6 @@ sub match {
         %$result,
     );
 
-    $self->trace(match => $match) if $ENV{'PATH_DISPATCHER_TRACE'};
-
     return $match;
 }
 
@@ -70,57 +62,6 @@ sub run {
     $self->block->(@_);
 }
 
-sub readable_attributes { }
-
-sub trace {
-    my $self  = shift;
-    my %args  = @_;
-
-    my $level = $ENV{'PATH_DISPATCHER_TRACE'};
-
-    return if exists($args{level})
-           && $level < $args{level};
-
-    my $match = $args{match};
-    my $path  = $match ? $match->path : $args{path};
-
-    # name
-    my $trace = '';
-    if ($self->has_name) {
-        $trace .= $self->name;
-    }
-    else {
-        $trace .= "$self";
-    }
-
-    # attributes such as tokens or regex
-    if ($level >= 2) {
-        my $attr = $self->readable_attributes;
-        $trace .= " $attr" if defined($attr) && length($attr);
-    }
-
-    # what just happened
-    if ($args{running}) {
-        $trace .= " running codeblock with path ($path)";
-        if ($level >= 10) {
-            require B::Deparse;
-            $trace .= ": " . B::Deparse->new->coderef2text($match->rule->block);
-        }
-    }
-    elsif ($match) {
-        $trace .= " matched against ($path)";
-        $trace .= " with (" . $match->leftover . ") left over"
-            if length($match->leftover);
-    }
-    else {
-        $trace .= " did not match against ($path)";
-    }
-
-    $trace .= ".\n";
-
-    warn $trace;
-}
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/Chain.pm b/lib/Path/Dispatcher/Rule/Chain.pm
index f0b311e..6e21270 100644
--- a/lib/Path/Dispatcher/Rule/Chain.pm
+++ b/lib/Path/Dispatcher/Rule/Chain.pm
@@ -14,8 +14,6 @@ sub BUILD {
     }
 }
 
-sub readable_attributes { 'chain' }
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/CodeRef.pm b/lib/Path/Dispatcher/Rule/CodeRef.pm
index 54a2339..d119301 100644
--- a/lib/Path/Dispatcher/Rule/CodeRef.pm
+++ b/lib/Path/Dispatcher/Rule/CodeRef.pm
@@ -16,15 +16,6 @@ sub _match {
     return $self->matcher->($path);
 }
 
-sub readable_attributes {
-    return if $ENV{'PATH_DISPATCHER_TRACE'} < 10;
-
-    my $self = shift;
-
-    require B::Deparse;
-    return B::Deparse->new->coderef2text($self->matcher);
-}
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/Dispatch.pm b/lib/Path/Dispatcher/Rule/Dispatch.pm
index d87e955..b2b4fc8 100644
--- a/lib/Path/Dispatcher/Rule/Dispatch.pm
+++ b/lib/Path/Dispatcher/Rule/Dispatch.pm
@@ -17,8 +17,6 @@ sub match {
     return $dispatch->matches;
 }
 
-sub readable_attributes { shift->dispatcher->name }
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/Enum.pm b/lib/Path/Dispatcher/Rule/Enum.pm
index 0025cb6..5032553 100644
--- a/lib/Path/Dispatcher/Rule/Enum.pm
+++ b/lib/Path/Dispatcher/Rule/Enum.pm
@@ -85,8 +85,6 @@ sub complete {
     return @completions;
 }
 
-sub readable_attributes { q{"} . shift->string . q{"} }
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/Eq.pm b/lib/Path/Dispatcher/Rule/Eq.pm
index 37ff30d..4963634 100644
--- a/lib/Path/Dispatcher/Rule/Eq.pm
+++ b/lib/Path/Dispatcher/Rule/Eq.pm
@@ -66,8 +66,6 @@ sub complete {
     return $completed;
 }
 
-sub readable_attributes { q{"} . shift->string . q{"} }
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/Metadata.pm b/lib/Path/Dispatcher/Rule/Metadata.pm
index 4b9b3c6..7633588 100644
--- a/lib/Path/Dispatcher/Rule/Metadata.pm
+++ b/lib/Path/Dispatcher/Rule/Metadata.pm
@@ -28,13 +28,6 @@ sub _match {
     };
 }
 
-sub readable_attributes {
-    my $self = shift;
-    return sprintf "{ '%s': %s }",
-        $self->field,
-        $self->matcher->readable_attributes;
-}
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/Regex.pm b/lib/Path/Dispatcher/Rule/Regex.pm
index df5125c..0066ef8 100644
--- a/lib/Path/Dispatcher/Rule/Regex.pm
+++ b/lib/Path/Dispatcher/Rule/Regex.pm
@@ -23,8 +23,6 @@ sub _match {
     }
 }
 
-sub readable_attributes { shift->regex }
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/Tokens.pm b/lib/Path/Dispatcher/Rule/Tokens.pm
index 472e8be..f91128b 100644
--- a/lib/Path/Dispatcher/Rule/Tokens.pm
+++ b/lib/Path/Dispatcher/Rule/Tokens.pm
@@ -138,52 +138,6 @@ sub untokenize {
            @tokens;
 }
 
-sub readable_attributes {
-    my $self = shift;
-
-    my $deserialize;
-    $deserialize = sub {
-        my $ret = '';
-        for (my $i = 0; $i < @_; ++$i) {
-            local $_ = $_[$i];
-
-            if (ref($_) eq 'ARRAY') {
-                $ret .= $deserialize->(@$_);
-            }
-            else {
-                $ret .= $_;
-            }
-
-            $ret .= ',' if $i + 1 < @_;
-        }
-
-        return "[" . $ret . "]";
-    };
-
-    return $deserialize->($self->tokens);
-}
-
-sub trace {
-    my $self = shift;
-    my %args = @_;
-
-    $self->SUPER::trace(@_);
-
-    return if $ENV{'PATH_DISPATCHER_TRACE'} < 3;
-
-    if ($args{no_tokens}) {
-        warn "... We ran out of tokens when trying to match ($args{on_token}).\n";
-    }
-    elsif ($args{no_match}) {
-        my ($got, $expected) = @args{'got_token', 'on_token'};
-        warn "... Did not match ($got) against expected ($expected).\n";
-    }
-    elsif ($args{tokens_left}) {
-        my @tokens = @{ $args{tokens_left} };
-        warn "... We ran out of path tokens, expecting (@tokens).\n";
-    }
-};
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 
diff --git a/lib/Path/Dispatcher/Rule/Under.pm b/lib/Path/Dispatcher/Rule/Under.pm
index d38ce51..a9230db 100644
--- a/lib/Path/Dispatcher/Rule/Under.pm
+++ b/lib/Path/Dispatcher/Rule/Under.pm
@@ -60,8 +60,6 @@ sub complete {
     }
 }
 
-sub readable_attributes { shift->predicate->readable_attributes }
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 

commit 865df9dc05cd3a1469f80c58c8a23b19aeaa5aa2
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:24:48 2010 +0900

    Tidy

diff --git a/lib/Path/Dispatcher/Rule.pm b/lib/Path/Dispatcher/Rule.pm
index 07d3330..c08405c 100644
--- a/lib/Path/Dispatcher/Rule.pm
+++ b/lib/Path/Dispatcher/Rule.pm
@@ -37,8 +37,8 @@ sub match {
     }
 
     my $match = $self->match_class->new(
-        path     => $path,
-        rule     => $self,
+        path => $path,
+        rule => $self,
         %$result,
     );
 

commit 8ea24b6b8795de3ed5ba5738e0af41ef131f8aee
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:25:52 2010 +0900

    Another talk :)

diff --git a/lib/Path/Dispatcher.pm b/lib/Path/Dispatcher.pm
index d705d02..7e0653c 100644
--- a/lib/Path/Dispatcher.pm
+++ b/lib/Path/Dispatcher.pm
@@ -169,6 +169,8 @@ Shawn M Moore, C<< <sartak at bestpractical.com> >>
 
 =item L<http://sartak.org/talks/yapc-na-2010/path-dispatcher/>
 
+=item L<http://sartak.org/talks/yapc-asia-2010/evolution-of-path-dispatcher/>
+
 =item L<Jifty::Dispatcher>
 
 =item L<Catalyst::Dispatcher>

commit a9426dd3e631e368f941b665febf179dbbd01dd5
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:50:14 2010 +0900

    Make what you replace clearer

diff --git a/lib/Path/Dispatcher/Cookbook.pod b/lib/Path/Dispatcher/Cookbook.pod
index 20d9b9f..d0e92b0 100644
--- a/lib/Path/Dispatcher/Cookbook.pod
+++ b/lib/Path/Dispatcher/Cookbook.pod
@@ -69,23 +69,23 @@ out the various completions of "hel".
     };
 
 Then tell your shell about how to use _gencomp. For zsh it might look
-like this (replace "app" with your binary name):
+like this (replace "APP" with your binary name):
 
-    /usr/share/zsh/site-functions/_app:
-        #compdef app
-        typeset -a app_completions
-        app_completions=($($words[1] _gencomp $words[2,-1]))
-        compadd $app_completions
+    /usr/share/zsh/site-functions/_APP:
+        #compdef APP
+        typeset -a APP_completions
+        APP_completions=($($words[1] _gencomp $words[2,-1]))
+        compadd $APP_completions
 
 For bash it might look like this:
 
-    /etc/bash_completion.d/app.bash:
-        function _app_()
+    /etc/bash_completion.d/APP.bash:
+        function _APP_()
         {
             COMPREPLY=($($1 _gencomp ${COMP_WORDS[COMP_CWORD]}))
         }
 
-        complete -F _app_ app
+        complete -F _APP_ APP
 
 =cut
 

commit 5c528bf5a0cc7d773975074c646cd846ce81c06c
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:50:38 2010 +0900

    Use ->pos instead of $1 in doc

diff --git a/lib/Path/Dispatcher.pm b/lib/Path/Dispatcher.pm
index 7e0653c..76d1c48 100644
--- a/lib/Path/Dispatcher.pm
+++ b/lib/Path/Dispatcher.pm
@@ -90,7 +90,7 @@ Path::Dispatcher - flexible and extensible dispatch
     $dispatcher->add_rule(
         Path::Dispatcher::Rule::Regex->new(
             regex => qr{^/(foo)/},
-            block => sub { warn $1; },
+            block => sub { warn shift->pos(1); },
         )
     );
 
@@ -98,7 +98,7 @@ Path::Dispatcher - flexible and extensible dispatch
         Path::Dispatcher::Rule::Tokens->new(
             tokens    => ['ticket', 'delete', qr/^\d+$/],
             delimiter => '/',
-            block     => sub { delete_ticket($3) },
+            block     => sub { delete_ticket(shift->pos(3)) },
         )
     );
 
diff --git a/lib/Path/Dispatcher/Cookbook.pod b/lib/Path/Dispatcher/Cookbook.pod
index d0e92b0..54089d5 100644
--- a/lib/Path/Dispatcher/Cookbook.pod
+++ b/lib/Path/Dispatcher/Cookbook.pod
@@ -62,10 +62,9 @@ we name it _gencomp, so that if the user types "app _gencomp hel" it will print
 out the various completions of "hel".
 
     on qr/^_gencomp\s*(.*)/ => sub {
-        my $self = shift;
-        my $path = $1;
-        $path = "" if !defined($path);
-        print "$_\n" for dispatcher->complete($path);
+        my $prefix = shift->pos(1);
+        $prefix = "" if !defined($prefix);
+        print "$_\n" for dispatcher->complete($prefix);
     };
 
 Then tell your shell about how to use _gencomp. For zsh it might look
diff --git a/lib/Path/Dispatcher/Dispatch.pm b/lib/Path/Dispatcher/Dispatch.pm
index e361f70..276fbec 100644
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@ -71,7 +71,7 @@ Path::Dispatcher::Dispatch - a list of matches
         rules => [
             Path::Dispatcher::Rule::Tokens->new(
                 tokens => [ 'attack', qr/^\w+$/ ],
-                block  => sub { attack($2) },
+                block  => sub { attack(shift->pos(2)) },
             ),
         ],
     );
diff --git a/lib/Path/Dispatcher/Rule/Enum.pm b/lib/Path/Dispatcher/Rule/Enum.pm
index 5032553..4bb29ca 100644
--- a/lib/Path/Dispatcher/Rule/Enum.pm
+++ b/lib/Path/Dispatcher/Rule/Enum.pm
@@ -100,7 +100,7 @@ Path::Dispatcher::Rule::Enum - one of a list of strings must match
 
     my $rule = Path::Dispatcher::Rule::Enum->new(
         enum  => [qw(perl ruby python php)],
-        block => sub { warn "$1 rules!" },
+        block => sub { warn "I love " . shift->pos(1) },
     );
 
 =head1 DESCRIPTION
diff --git a/lib/Path/Dispatcher/Rule/Eq.pm b/lib/Path/Dispatcher/Rule/Eq.pm
index 4963634..714d32b 100644
--- a/lib/Path/Dispatcher/Rule/Eq.pm
+++ b/lib/Path/Dispatcher/Rule/Eq.pm
@@ -81,7 +81,7 @@ Path::Dispatcher::Rule::Eq - predicate is a string equality
 
     my $rule = Path::Dispatcher::Rule::Eq->new(
         string => 'comment',
-        block  => sub { display_comment($1) },
+        block  => sub { display_comment(shift->pos(1)) },
     );
 
 =head1 DESCRIPTION
diff --git a/lib/Path/Dispatcher/Rule/Regex.pm b/lib/Path/Dispatcher/Rule/Regex.pm
index 0066ef8..11945b1 100644
--- a/lib/Path/Dispatcher/Rule/Regex.pm
+++ b/lib/Path/Dispatcher/Rule/Regex.pm
@@ -38,7 +38,7 @@ Path::Dispatcher::Rule::Regex - predicate is a regular expression
 
     my $rule = Path::Dispatcher::Rule::Regex->new(
         regex => qr{^/comment(s?)/(\d+)$},
-        block => sub { display_comment($2) },
+        block => sub { display_comment(shift->pos(2)) },
     );
 
 =head1 DESCRIPTION
@@ -51,9 +51,8 @@ Rules of this class use a regular expression to match against the path.
 
 The regular expression to match against the path. It works just as you'd expect!
 
-The results are the capture variables (C<$1>, C<$2>, etc) and when the
-resulting L<Path::Dispatcher::Match> is executed, the codeblock will see these
-values. C<$`>, C<$&>, and C<$'> are not (yet) restored.
+The capture variables (C<$1>, C<$2>, etc) will be available in the match
+object as C<< ->pos(1) >> etc. C<$`>, C<$&>, and C<$'> are not restored.
 
 =cut
 
diff --git a/lib/Path/Dispatcher/Rule/Tokens.pm b/lib/Path/Dispatcher/Rule/Tokens.pm
index f91128b..b42593e 100644
--- a/lib/Path/Dispatcher/Rule/Tokens.pm
+++ b/lib/Path/Dispatcher/Rule/Tokens.pm
@@ -154,7 +154,7 @@ Path::Dispatcher::Rule::Tokens - predicate is a list of tokens
     my $rule = Path::Dispatcher::Rule::Tokens->new(
         tokens    => [ "comment", "show", qr/^\d+$/ ],
         delimiter => '/',
-        block     => sub { display_comment($3) },
+        block     => sub { display_comment(shift->pos(3)) },
     );
 
     $rule->match("/comment/show/25");
@@ -176,9 +176,9 @@ first matches "ticket". Then, the next token must be "show" or "display". The
 final token must be a number or a pound sign followed by three word characters.
 
 The results are the tokens in the original string, as they were matched. If you
-have three tokens, then C<$1> will be the string's first token, C<$2> its
-second, and C<$3> its third. So matching "ticket display #AAA" would have
-"ticket" in C<$1>, "display" in C<$2>, and "#AAA" in C<$3>.
+have three tokens, then C<< match->pos(1) >> will be the string's first token
+("ticket"), C<< match->pos(2) >> its second ("display"), and C<< match->pos(3)
+>> its third ("#AAA").
 
 Capture groups inside a regex token are completely ignored.
 
diff --git a/lib/Path/Dispatcher/Rule/Under.pm b/lib/Path/Dispatcher/Rule/Under.pm
index a9230db..e28acc1 100644
--- a/lib/Path/Dispatcher/Rule/Under.pm
+++ b/lib/Path/Dispatcher/Rule/Under.pm
@@ -85,7 +85,7 @@ Path::Dispatcher::Rule::Under - rules under a predicate
 
     my $delete = Path::Dispatcher::Rule::Tokens->new(
         tokens => [ 'delete', qr/^\d+$/ ],
-        block  => sub { delete_ticket($2) },
+        block  => sub { delete_ticket(shift->pos(2)) },
     );
 
     my $rule = Path::Dispatcher::Rule::Under->new(
diff --git a/t/001-api.t b/t/001-api.t
index c1b83ba..e59f683 100644
--- a/t/001-api.t
+++ b/t/001-api.t
@@ -53,5 +53,5 @@ is_deeply([splice @calls], [ ['bar'] ], "invoked the rule block on 'run'");
 
 isa_ok($dispatch, 'Path::Dispatcher::Dispatch');
 $dispatch->run;
-is_deeply([splice @calls], [ ['bar'] ], "invoked the rule block on 'run', makes sure \$1 etc are still correctly set");
+is_deeply([splice @calls], [ ['bar'] ], "invoked the rule block on 'run', makes sure ->pos etc are still correctly set");
 

commit 432fb42bd49b93ddbb9a351a76067e99f336f9c4
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:54:21 2010 +0900

    Test cleanup

diff --git a/t/002-rule.t b/t/002-rule.t
index 6c4e890..17d53d3 100644
--- a/t/002-rule.t
+++ b/t/002-rule.t
@@ -16,8 +16,9 @@ my $rule = Path::Dispatcher::Rule::Regex->new(
     },
 );
 
-isa_ok($rule->match(Path::Dispatcher::Path->new('foobar')), 'Path::Dispatcher::Match');
-is_deeply($rule->match(Path::Dispatcher::Path->new('foobar'))->positional_captures, ['fo', 'ob']);
+my $match = $rule->match(Path::Dispatcher::Path->new('foobar'));
+isa_ok($match, 'Path::Dispatcher::Match');
+is_deeply($match->positional_captures, ['fo', 'ob']);
 is_deeply([splice @calls], [], "block not called on match");
 
 $rule->run;
diff --git a/t/014-tokens-prefix.t b/t/014-tokens-prefix.t
index a263bcb..8924e99 100644
--- a/t/014-tokens-prefix.t
+++ b/t/014-tokens-prefix.t
@@ -4,11 +4,9 @@ use warnings;
 use Test::More tests => 5;
 use Path::Dispatcher;
 
-my @calls;
-
 my $rule = Path::Dispatcher::Rule::Tokens->new(
     tokens => ['foo', 'bar'],
-    block  => sub { push @calls, [$1, $2, $3] },
+    block  => sub { },
     prefix => 1,
 );
 

commit a184e65ba3cfa4ac6ea669b46eb518c5357e820b
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:54:39 2010 +0900

    Another change

diff --git a/Changes b/Changes
index 31200fd..041b246 100644
--- a/Changes
+++ b/Changes
@@ -18,6 +18,8 @@ Revision history for Path-Dispatcher
 
         Add documentation for shell tab completion
 
+        Plenty other updated documentation
+
 0.15 Tue Mar 16 09:40:40 2010
         ** Factored Path-Dispatcher-Declarative into its own distribution
         ** Be sure to update your dependency lists!

commit e63ba10544ea43928b250ee338d19506d217cb37
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:55:07 2010 +0900

    Bump MI

diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm
index af32a30..8ee839d 100644
--- a/inc/Module/Install.pm
+++ b/inc/Module/Install.pm
@@ -31,7 +31,7 @@ BEGIN {
 	# This is not enforced yet, but will be some time in the next few
 	# releases once we can make sure it won't clash with custom
 	# Module::Install extensions.
-	$VERSION = '0.99';
+	$VERSION = '1.00';
 
 	# Storage for the pseudo-singleton
 	$MAIN    = undef;
@@ -230,8 +230,12 @@ sub preload {
 sub new {
 	my ($class, %args) = @_;
 
-    delete $INC{'FindBin.pm'};
-    require FindBin;
+	delete $INC{'FindBin.pm'};
+	{
+		# to suppress the redefine warning
+		local $SIG{__WARN__} = sub {};
+		require FindBin;
+	}
 
 	# ignore the prefix on extension modules built from top level.
 	my $base_path = Cwd::abs_path($FindBin::Bin);
diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm
index c86c197..b55bda3 100644
--- a/inc/Module/Install/Base.pm
+++ b/inc/Module/Install/Base.pm
@@ -4,7 +4,7 @@ package Module::Install::Base;
 use strict 'vars';
 use vars qw{$VERSION};
 BEGIN {
-	$VERSION = '0.99';
+	$VERSION = '1.00';
 }
 
 # Suspend handler for "redefined" warnings
diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm
index 994dd3f..71ccc27 100644
--- a/inc/Module/Install/Can.pm
+++ b/inc/Module/Install/Can.pm
@@ -9,7 +9,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.99';
+	$VERSION = '1.00';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm
index df357b2..ec1f106 100644
--- a/inc/Module/Install/Fetch.pm
+++ b/inc/Module/Install/Fetch.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.99';
+	$VERSION = '1.00';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm
index a3536a4..5dfd0e9 100644
--- a/inc/Module/Install/Makefile.pm
+++ b/inc/Module/Install/Makefile.pm
@@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/;
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.99';
+	$VERSION = '1.00';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm
index bdeb367..cfe45b3 100644
--- a/inc/Module/Install/Metadata.pm
+++ b/inc/Module/Install/Metadata.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.99';
+	$VERSION = '1.00';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm
index a9417aa..edc18b4 100644
--- a/inc/Module/Install/Win32.pm
+++ b/inc/Module/Install/Win32.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.99';
+	$VERSION = '1.00';
 	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm
index 75a089f..d0f6599 100644
--- a/inc/Module/Install/WriteAll.pm
+++ b/inc/Module/Install/WriteAll.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.99';
+	$VERSION = '1.00';
 	@ISA     = qw{Module::Install::Base};
 	$ISCORE  = 1;
 }

commit 1e967eabd75df13906d0cd1535d39b6c773dda91
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:55:59 2010 +0900

    Bump to 0.16

diff --git a/Changes b/Changes
index 041b246..9b883eb 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
 Revision history for Path-Dispatcher
 
-0.16
+0.16 Sun Oct 17 2010
         ** BACKWARDS INCOMPATIBLE CHANGE: Pass the match object into rule
         **    blocks rather than assigning $1, $2, $3. Use ->pos(1), (2), (3),
         **    etc. instead. This cleans up the code a lot and makes
diff --git a/lib/Path/Dispatcher.pm b/lib/Path/Dispatcher.pm
index 76d1c48..ca76cfe 100644
--- a/lib/Path/Dispatcher.pm
+++ b/lib/Path/Dispatcher.pm
@@ -2,7 +2,7 @@ package Path::Dispatcher;
 use Any::Moose;
 use 5.008001;
 
-our $VERSION = '0.15';
+our $VERSION = '0.16';
 
 use Path::Dispatcher::Rule;
 use Path::Dispatcher::Dispatch;

commit 1149ef8acbfeafdd39066b3d830a5022abbf8a7f
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Sun Oct 17 16:59:11 2010 +0900

    Add ->named($key) for named captures

diff --git a/lib/Path/Dispatcher/Match.pm b/lib/Path/Dispatcher/Match.pm
index 8d37ffb..a44a3a9 100644
--- a/lib/Path/Dispatcher/Match.pm
+++ b/lib/Path/Dispatcher/Match.pm
@@ -41,7 +41,7 @@ sub run {
 }
 
 sub pos {
-    my $self = shift;
+    my $self  = shift;
     my $index = shift;
 
     return undef if $index == 0;
@@ -51,6 +51,12 @@ sub pos {
     return $self->positional_captures->[$index];
 }
 
+sub named {
+    my $self = shift;
+    my $key  = shift;
+    return $self->named_captures->{$key};
+}
+
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 

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



More information about the Bps-public-commit mailing list