[Bps-public-commit] path-dispatcher-declarative branch, master, updated. 6d581950c48d579941b8cff9348b298856623999

Shawn Moore sartak at bestpractical.com
Tue Nov 2 08:12:12 EDT 2010


The branch, master has been updated
       via  6d581950c48d579941b8cff9348b298856623999 (commit)
       via  aa1a4d75921b443fabec830f4946674497147db3 (commit)
       via  a31e5d59cd8d173691918495519efa11311f6ea2 (commit)
       via  7cf36e4f2aec1ed148d854b76421f50c6f974ad6 (commit)
       via  6ab5ff6750f70489bbe026cdaeeb5a548b549822 (commit)
      from  90b3bc12231d6287c5c02051299b0acef5b11250 (commit)

Summary of changes:
 Changes                                    |    6 ++++++
 Makefile.PL                                |    2 +-
 lib/Path/Dispatcher/Declarative.pm         |    2 +-
 lib/Path/Dispatcher/Declarative/Builder.pm |   24 +++++++++++++++---------
 4 files changed, 23 insertions(+), 11 deletions(-)

- Log -----------------------------------------------------------------
commit 6ab5ff6750f70489bbe026cdaeeb5a548b549822
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 2 07:47:41 2010 -0400

    Use the old method of matching a regex
    
        Glob assignment breaks Prophet because $1 etc leak

diff --git a/lib/Path/Dispatcher/Declarative/Builder.pm b/lib/Path/Dispatcher/Declarative/Builder.pm
index 57ea62d..c8cedb9 100644
--- a/lib/Path/Dispatcher/Declarative/Builder.pm
+++ b/lib/Path/Dispatcher/Declarative/Builder.pm
@@ -225,15 +225,23 @@ sub _add_rule {
         my $old_block = $block;
         $block = sub {
             my $match = shift;
+            my @pos = @{ $match->positional_captures };
 
-            # clear $1, $2, $3 so they don't pollute the number vars for the block
-            "x" =~ /x/;
+            # we don't have direct write access to $1 and friends, so we have to
+            # do this little hack. the only way we can update $1 is by matching
+            # against a regex (5.10 fixes that)..
+            my $re  = join '', map { defined($_) ? "(\Q$_\E)" : "(wontmatch)?" } @pos;
+            my $str = join '', map { defined($_) ? $_         : ""             } @pos;
+
+            # we need to check length because Perl's annoying gotcha of the empty regex
+            # actually being an alias for whatever the previously used regex was
+            # (useful last decade when qr// hadn't been invented)
+            # we need to do the match anyway, because we have to clear the number vars
+            ($str, $re) = ("x", "x") if length($str) == 0;
+
+            $str =~ qr{^$re$}
+                or die "Unable to match '$str' against a copy of itself ($re)!";
 
-            # populate $1, $2, etc for the duration of $code
-            # it'd be nice if we could use "local" but it seems to break tests
-            my $i = 0;
-            no strict 'refs';
-            *{ ++$i } = \$_ for @{ $match->positional_captures };
 
             $old_block->(@_);
         };

commit 7cf36e4f2aec1ed148d854b76421f50c6f974ad6
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 2 07:49:48 2010 -0400

    Remove stray has_name

diff --git a/lib/Path/Dispatcher/Declarative/Builder.pm b/lib/Path/Dispatcher/Declarative/Builder.pm
index c8cedb9..8b91004 100644
--- a/lib/Path/Dispatcher/Declarative/Builder.pm
+++ b/lib/Path/Dispatcher/Declarative/Builder.pm
@@ -260,8 +260,6 @@ sub _add_rule {
         $parent->add_rule($rule);
     }
     else {
-        $rule->name($rule_name)
-            unless $rule->has_name;
         return $rule, @_;
     }
 }

commit a31e5d59cd8d173691918495519efa11311f6ea2
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 2 08:02:44 2010 -0400

    Depend on PD 1.02

diff --git a/Makefile.PL b/Makefile.PL
index 13f2c70..6a8dbad 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,7 +4,7 @@ name       'Path-Dispatcher-Declarative';
 all_from   'lib/Path/Dispatcher/Declarative.pm';
 repository 'http://github.com/bestpractical/path-dispatcher-declarative';
 
-requires 'Path::Dispatcher' => '1.01';
+requires 'Path::Dispatcher' => '1.02';
 
 requires 'Any::Moose';
 requires 'Sub::Exporter';

commit aa1a4d75921b443fabec830f4946674497147db3
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 2 08:03:37 2010 -0400

    0.03 changes

diff --git a/Changes b/Changes
index 4053962..6cc5cfa 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,11 @@
 Revision history for Path-Dispatcher-Declarative
 
+0.03  2010-11-02
+        Improve reinstatement of $1, $2 so they don't leak outside of the
+            scope of your blocks
+
+        Remove a couple stray references to named rules
+
 0.02  2010-10-24
         Reinstate the back-compat that Path-Dispatcher 1.00 broke by setting
             $1, $2, etc. for you

commit 6d581950c48d579941b8cff9348b298856623999
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 2 08:03:46 2010 -0400

    Bump to 0.03

diff --git a/lib/Path/Dispatcher/Declarative.pm b/lib/Path/Dispatcher/Declarative.pm
index 4c0907c..fd3b5f2 100644
--- a/lib/Path/Dispatcher/Declarative.pm
+++ b/lib/Path/Dispatcher/Declarative.pm
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 use 5.008001;
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 use Path::Dispatcher;
 use Path::Dispatcher::Declarative::Builder;

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



More information about the Bps-public-commit mailing list