r54993 - in /trunk/libpath-dispatcher-perl: ./ debian/ lib/Path/ lib/Path/Dispatcher/ lib/Path/Dispatcher/Rule/ t/

nhandler-guest at users.alioth.debian.org nhandler-guest at users.alioth.debian.org
Mon Mar 29 01:58:37 UTC 2010


Author: nhandler-guest
Date: Mon Mar 29 01:58:19 2010
New Revision: 54993

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=54993
Log:
New upstream release

Added:
    trunk/libpath-dispatcher-perl/META.yml
      - copied unchanged from r54992, branches/upstream/libpath-dispatcher-perl/current/META.yml
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Alternation.pm
      - copied unchanged from r54992, branches/upstream/libpath-dispatcher-perl/current/lib/Path/Dispatcher/Rule/Alternation.pm
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Enum.pm
      - copied unchanged from r54992, branches/upstream/libpath-dispatcher-perl/current/lib/Path/Dispatcher/Rule/Enum.pm
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Sequence.pm
      - copied unchanged from r54992, branches/upstream/libpath-dispatcher-perl/current/lib/Path/Dispatcher/Rule/Sequence.pm
    trunk/libpath-dispatcher-perl/t/023-alternation.t
      - copied unchanged from r54992, branches/upstream/libpath-dispatcher-perl/current/t/023-alternation.t
    trunk/libpath-dispatcher-perl/t/024-sequence.t
      - copied unchanged from r54992, branches/upstream/libpath-dispatcher-perl/current/t/024-sequence.t
    trunk/libpath-dispatcher-perl/t/025-sequence-custom-rule.t
      - copied unchanged from r54992, branches/upstream/libpath-dispatcher-perl/current/t/025-sequence-custom-rule.t
Removed:
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Builder.pm
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Declarative.pm
    trunk/libpath-dispatcher-perl/t/016-more-under.t
    trunk/libpath-dispatcher-perl/t/020-chain.t
    trunk/libpath-dispatcher-perl/t/021-declarative-defaults.t
    trunk/libpath-dispatcher-perl/t/100-declarative.t
    trunk/libpath-dispatcher-perl/t/101-subclass.t
    trunk/libpath-dispatcher-perl/t/102-abort.t
    trunk/libpath-dispatcher-perl/t/103-input.t
    trunk/libpath-dispatcher-perl/t/104-config.t
    trunk/libpath-dispatcher-perl/t/105-empty.t
    trunk/libpath-dispatcher-perl/t/106-metadata.t
    trunk/libpath-dispatcher-perl/t/200-under-next_rule.t
    trunk/libpath-dispatcher-perl/t/300-complete-simple.t
    trunk/libpath-dispatcher-perl/t/301-complete-complex.t
    trunk/libpath-dispatcher-perl/t/302-complete-delimiter.t
    trunk/libpath-dispatcher-perl/t/303-complete-alternation.t
    trunk/libpath-dispatcher-perl/t/800-cb-slash-path-delimiter.t
    trunk/libpath-dispatcher-perl/t/801-cb-chaining.t
Modified:
    trunk/libpath-dispatcher-perl/Changes
    trunk/libpath-dispatcher-perl/MANIFEST
    trunk/libpath-dispatcher-perl/Makefile.PL
    trunk/libpath-dispatcher-perl/debian/changelog
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher.pm
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule.pm
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/CodeRef.pm
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Dispatch.pm
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Eq.pm
    trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Intersection.pm
    trunk/libpath-dispatcher-perl/t/017-intersection.t

Modified: trunk/libpath-dispatcher-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/Changes?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/Changes (original)
+++ trunk/libpath-dispatcher-perl/Changes Mon Mar 29 01:58:19 2010
@@ -1,6 +1,31 @@
 Revision history for Path-Dispatcher
 
-0.14
+0.15 Tue Mar 16 09:40:40 2009
+        ** Factored Path-Dispatcher-Declarative into its own distribution
+        ** Be sure to update your dependency information!
+
+        Implement ->complete for Rule::Dispatch
+
+        Add Path::Dispatcher::Rule::Alternation
+
+        Implement case insensitivity fory Rule::Eq
+
+        Add Path::Dispatcher::Rule::Sequence - like Rule::Tokens but
+            better!
+
+        Add Path::Dispatcher::Rule::Enum
+
+        Path autoboxing has been factored out into a private method for
+            more overridability
+
+        A few documentation improvements as usual :)
+
+0.14 Thu Dec 31 13:18:19 2009
+        Add Path::Dispatcher->complete for tab-completion
+
+        Handle delimiters better in Path::Dispatcher::Rule::Tokens
+
+        Factor out a _prefix method for rules to simplify their logic
 
 0.13 Sun Aug 9 13:38:19 2009
         Add unshift_rule to classes that do Role::Rules

Modified: trunk/libpath-dispatcher-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/MANIFEST?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/MANIFEST (original)
+++ trunk/libpath-dispatcher-perl/MANIFEST Mon Mar 29 01:58:19 2010
@@ -8,27 +8,29 @@
 inc/Module/Install/Win32.pm
 inc/Module/Install/WriteAll.pm
 lib/Path/Dispatcher.pm
-lib/Path/Dispatcher/Builder.pm
 lib/Path/Dispatcher/Cookbook.pod
-lib/Path/Dispatcher/Declarative.pm
 lib/Path/Dispatcher/Dispatch.pm
 lib/Path/Dispatcher/Match.pm
 lib/Path/Dispatcher/Path.pm
 lib/Path/Dispatcher/Role/Rules.pm
 lib/Path/Dispatcher/Rule.pm
+lib/Path/Dispatcher/Rule/Alternation.pm
 lib/Path/Dispatcher/Rule/Always.pm
 lib/Path/Dispatcher/Rule/Chain.pm
 lib/Path/Dispatcher/Rule/CodeRef.pm
 lib/Path/Dispatcher/Rule/Dispatch.pm
 lib/Path/Dispatcher/Rule/Empty.pm
+lib/Path/Dispatcher/Rule/Enum.pm
 lib/Path/Dispatcher/Rule/Eq.pm
 lib/Path/Dispatcher/Rule/Intersection.pm
 lib/Path/Dispatcher/Rule/Metadata.pm
 lib/Path/Dispatcher/Rule/Regex.pm
+lib/Path/Dispatcher/Rule/Sequence.pm
 lib/Path/Dispatcher/Rule/Tokens.pm
 lib/Path/Dispatcher/Rule/Under.pm
 Makefile.PL
 MANIFEST			This list of files
+META.yml
 t/000-compile.t
 t/001-api.t
 t/002-rule.t
@@ -44,27 +46,13 @@
 t/013-tokens.t
 t/014-tokens-prefix.t
 t/015-regex-prefix.t
-t/016-more-under.t
 t/017-intersection.t
 t/018-metadata.t
 t/019-intersection-metadata.t
-t/020-chain.t
-t/021-declarative-defaults.t
 t/022-numbers-undef.t
-t/100-declarative.t
-t/101-subclass.t
-t/102-abort.t
-t/103-input.t
-t/104-config.t
-t/105-empty.t
-t/106-metadata.t
-t/200-under-next_rule.t
-t/300-complete-simple.t
-t/301-complete-complex.t
-t/302-complete-delimiter.t
-t/303-complete-alternation.t
-t/800-cb-slash-path-delimiter.t
-t/801-cb-chaining.t
+t/023-alternation.t
+t/024-sequence.t
+t/025-sequence-custom-rule.t
 t/900-use-path-dispatcher.t
 t/901-return-values.t
 t/902-coderef.t

Modified: trunk/libpath-dispatcher-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/Makefile.PL?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/Makefile.PL (original)
+++ trunk/libpath-dispatcher-perl/Makefile.PL Mon Mar 29 01:58:19 2010
@@ -5,7 +5,6 @@
 repository 'http://github.com/bestpractical/path-dispatcher';
 
 requires 'Any::Moose';
-requires 'Sub::Exporter';
 
 build_requires 'Test::Exception';
 

Modified: trunk/libpath-dispatcher-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/debian/changelog?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/debian/changelog (original)
+++ trunk/libpath-dispatcher-perl/debian/changelog Mon Mar 29 01:58:19 2010
@@ -1,3 +1,9 @@
+libpath-dispatcher-perl (0.15-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Nathan Handler <nhandler at ubuntu.com>  Sun, 28 Mar 2010 20:44:50 -0500
+
 libpath-dispatcher-perl (0.14-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libpath-dispatcher-perl/lib/Path/Dispatcher.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/lib/Path/Dispatcher.pm?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/lib/Path/Dispatcher.pm (original)
+++ trunk/libpath-dispatcher-perl/lib/Path/Dispatcher.pm Mon Mar 29 01:58:19 2010
@@ -2,7 +2,7 @@
 use Any::Moose;
 use 5.008001;
 
-our $VERSION = '0.14';
+our $VERSION = '0.15';
 
 use Path::Dispatcher::Rule;
 use Path::Dispatcher::Dispatch;
@@ -27,14 +27,7 @@
 
 sub dispatch {
     my $self = shift;
-    my $path = shift;
-
-    # Automatically box paths
-    unless (blessed($path) && $path->isa('Path::Dispatcher::Path')) {
-        $path = $self->path_class->new(
-            path => $path,
-        );
-    }
+    my $path = $self->_autobox_path(shift);
 
     my $dispatch = $self->dispatch_class->new;
 
@@ -71,17 +64,23 @@
 
 sub complete {
     my $self = shift;
+    my $path = $self->_autobox_path(shift);
+
+    my %seen;
+    return grep { !$seen{$_}++ } map { $_->complete($path) } $self->rules;
+}
+
+sub _autobox_path {
+    my $self = shift;
     my $path = shift;
 
-    # Automatically box paths
     unless (blessed($path) && $path->isa('Path::Dispatcher::Path')) {
         $path = $self->path_class->new(
             path => $path,
         );
     }
 
-    my %seen;
-    return grep { !$seen{$_}++ } map { $_->complete($path) } $self->rules;
+    return $path;
 }
 
 # We don't export anything, so if they request something, then try to error
@@ -114,7 +113,7 @@
     $dispatcher->add_rule(
         Path::Dispatcher::Rule::Regex->new(
             regex => qr{^/(foo)/},
-            block => sub { warn $1; }, # foo
+            block => sub { warn $1; },
         )
     );
 
@@ -218,7 +217,7 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2008-2009 Best Practical Solutions.
+Copyright 2008-2010 Best Practical Solutions.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.

Modified: trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule.pm?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule.pm (original)
+++ trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule.pm Mon Mar 29 01:58:19 2010
@@ -139,15 +139,18 @@
 no Any::Moose;
 
 # don't require others to load our subclasses explicitly
+require Path::Dispatcher::Rule::Alternation;
 require Path::Dispatcher::Rule::Always;
 require Path::Dispatcher::Rule::Chain;
 require Path::Dispatcher::Rule::CodeRef;
 require Path::Dispatcher::Rule::Dispatch;
 require Path::Dispatcher::Rule::Empty;
+require Path::Dispatcher::Rule::Enum;
 require Path::Dispatcher::Rule::Eq;
 require Path::Dispatcher::Rule::Intersection;
 require Path::Dispatcher::Rule::Metadata;
 require Path::Dispatcher::Rule::Regex;
+require Path::Dispatcher::Rule::Sequence;
 require Path::Dispatcher::Rule::Tokens;
 require Path::Dispatcher::Rule::Under;
 

Modified: trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/CodeRef.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/CodeRef.pm?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/CodeRef.pm (original)
+++ trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/CodeRef.pm Mon Mar 29 01:58:19 2010
@@ -53,8 +53,10 @@
 
 Rules of this class can match arbitrarily complex values. This should be used
 only when there is no other recourse, because there's no way we can inspect
-how things match. Create a custom subclass of L<Path::Dispatcher::Rule> if
-necessary!
+how things match.
+
+You're much better off creating a custom subclass of L<Path::Dispatcher::Rule>
+if at all possible.
 
 =head1 ATTRIBUTES
 

Modified: trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Dispatch.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Dispatch.pm?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Dispatch.pm (original)
+++ trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Dispatch.pm Mon Mar 29 01:58:19 2010
@@ -6,7 +6,7 @@
     is       => 'rw',
     isa      => 'Path::Dispatcher',
     required => 1,
-    handles  => ['rules'],
+    handles  => ['rules', 'complete'],
 );
 
 sub match {

Modified: trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Eq.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Eq.pm?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Eq.pm (original)
+++ trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Eq.pm Mon Mar 29 01:58:19 2010
@@ -8,11 +8,22 @@
     required => 1,
 );
 
+has case_sensitive => (
+    is      => 'rw',
+    isa     => 'Bool',
+    default => 1,
+);
+
 sub _match {
     my $self = shift;
     my $path = shift;
 
-    return $path->path eq $self->string;
+    if ($self->case_sensitive) {
+        return $path->path eq $self->string;
+    }
+    else {
+        return lc($path->path) eq lc($self->string);
+    }
 }
 
 sub _prefix_match {
@@ -20,7 +31,13 @@
     my $path = shift;
 
     my $truncated = substr($path->path, 0, length($self->string));
-    return 0 unless $truncated eq $self->string;
+
+    if ($self->case_sensitive) {
+        return 0 unless $truncated eq $self->string;
+    }
+    else {
+        return 0 unless lc($truncated) eq lc($self->string);
+    }
 
     return (1, substr($path->path, length($self->string)));
 }
@@ -30,7 +47,18 @@
     my $path = shift->path;
     my $completed = $self->string;
 
-    return unless substr($completed, 0, length($path)) eq $path;
+    # by convention, complete does include the path itself if it
+    # is a complete match
+    return if length($path) >= length($completed);
+
+    my $partial = substr($completed, 0, length($path));
+    if ($self->case_sensitive) {
+        return unless $partial eq $path;
+    }
+    else {
+        return unless lc($partial) eq lc($path);
+    }
+
     return $completed;
 }
 
@@ -51,7 +79,7 @@
 
     my $rule = Path::Dispatcher::Rule::Eq->new(
         string => 'comment',
-        block  => sub { display_comment($2) },
+        block  => sub { display_comment($1) },
     );
 
 =head1 DESCRIPTION

Modified: trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Intersection.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Intersection.pm?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Intersection.pm (original)
+++ trunk/libpath-dispatcher-perl/lib/Path/Dispatcher/Rule/Intersection.pm Mon Mar 29 01:58:19 2010
@@ -8,7 +8,10 @@
     my $self = shift;
     my $path = shift;
 
-    for my $rule ($self->rules) {
+    my @rules = $self->rules;
+    return 0 if @rules == 0;
+
+    for my $rule (@rules) {
         return 0 unless $rule->match($path);
     }
 

Modified: trunk/libpath-dispatcher-perl/t/017-intersection.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpath-dispatcher-perl/t/017-intersection.t?rev=54993&op=diff
==============================================================================
--- trunk/libpath-dispatcher-perl/t/017-intersection.t (original)
+++ trunk/libpath-dispatcher-perl/t/017-intersection.t Mon Mar 29 01:58:19 2010
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 3;
+use Test::More tests => 4;
 use Path::Dispatcher;
 
 my @calls;
@@ -33,3 +33,16 @@
 $dispatcher->run(" foo ");
 is_deeply([splice @calls], [], "each subrule of the intersection must match");
 
+# test empty intersection
+$dispatcher = Path::Dispatcher->new(
+    rules => [
+        Path::Dispatcher::Rule::Intersection->new(
+            rules => [ ],
+            block => sub { push @calls, 'intersection' },
+        ),
+    ],
+);
+
+$dispatcher->run("foo");
+is_deeply([splice @calls], [], "no subrules means no match");
+




More information about the Pkg-perl-cvs-commits mailing list