[Bps-public-commit] r16376 - in Path-Dispatcher/trunk: lib/Path/Dispatcher t t/lib/Path/Dispatcher/Test
sartak at bestpractical.com
sartak at bestpractical.com
Sun Oct 19 08:04:57 EDT 2008
Author: sartak
Date: Sun Oct 19 08:04:55 2008
New Revision: 16376
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm
Path-Dispatcher/trunk/t/016-more-under.t
Path-Dispatcher/trunk/t/100-declarative.t
Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/App.pm
Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/Framework.pm
Log:
r74157 at onn: sartak | 2008-10-19 08:01:51 -0400
Require that declarative dispatchers inherit from Path::Dispatcher::Declarative, for sanity (and feature) reasons
Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm (original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm Sun Oct 19 08:04:55 2008
@@ -20,22 +20,15 @@
sub import {
my $self = shift;
my $pkg = caller;
- my @args = grep { !/^-[Bb]ase/ } @_;
- # they must have specified '-base' if there are a different number of args
- if (@args != @_) {
+ do {
no strict 'refs';
push @{ $pkg . '::ISA' }, $self;
- }
- else {
- # we don't want our subclasses exporting our sugar
- # unless the user specifies -base
- return if $self ne __PACKAGE__;
- }
+ };
local $CALLER = $pkg;
- $exporter->($self, @args);
+ $exporter->($self, @_);
}
sub build_sugar {
Modified: Path-Dispatcher/trunk/t/016-more-under.t
==============================================================================
--- Path-Dispatcher/trunk/t/016-more-under.t (original)
+++ Path-Dispatcher/trunk/t/016-more-under.t Sun Oct 19 08:04:55 2008
@@ -7,7 +7,7 @@
do {
package Under::Where;
- use Path::Dispatcher::Declarative -base;
+ use Path::Dispatcher::Declarative;
under 'ticket' => sub {
on 'create' => sub { push @calls, "ticket create" };
Modified: Path-Dispatcher/trunk/t/100-declarative.t
==============================================================================
--- Path-Dispatcher/trunk/t/100-declarative.t (original)
+++ Path-Dispatcher/trunk/t/100-declarative.t Sun Oct 19 08:04:55 2008
@@ -1,41 +1,25 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 6;
+use Test::More tests => 3;
my @calls;
-for my $use_base (0, 1) {
- my $dispatcher = $use_base ? 'MyApp::Dispatcher' : 'MyApp::DispatcherBase';
-
- # duplicated code is worse than eval!
- my $code = "
- package $dispatcher;
- ";
-
- $code .= 'use Path::Dispatcher::Declarative';
- $code .= ' -base' if $use_base;
- $code .= ';';
-
- $code .= '
- on qr/(b)(ar)(.*)/ => sub {
- push @calls, [$1, $2, $3];
- };
- ';
-
- eval $code;
-
- if ($use_base) {
- ok($dispatcher->isa('Path::Dispatcher::Declarative'), "use Path::Dispatcher::Declarative -base sets up ISA");
- }
- else {
- ok(!$dispatcher->isa('Path::Dispatcher::Declarative'), "use Path::Dispatcher::Declarative does NOT set up ISA");
- }
-
- can_ok($dispatcher => qw/dispatcher dispatch run/);
- $dispatcher->run('foobarbaz');
- is_deeply([splice @calls], [
- [ 'b', 'ar', 'baz' ],
- ]);
-}
+do {
+ package MyApp::Dispatcher;
+ use Path::Dispatcher::Declarative;
+
+ on qr/(b)(ar)(.*)/ => sub {
+ push @calls, [$1, $2, $3];
+ };
+
+};
+
+ok(MyApp::Dispatcher->isa('Path::Dispatcher::Declarative'), "use Path::Dispatcher::Declarative sets up ISA");
+
+can_ok('MyApp::Dispatcher' => qw/dispatcher dispatch run/);
+MyApp::Dispatcher->run('foobarbaz');
+is_deeply([splice @calls], [
+ [ 'b', 'ar', 'baz' ],
+]);
Modified: Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/App.pm
==============================================================================
--- Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/App.pm (original)
+++ Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/App.pm Sun Oct 19 08:04:55 2008
@@ -2,7 +2,7 @@
package Path::Dispatcher::Test::App;
use strict;
use warnings;
-use Path::Dispatcher::Test::Framework -base;
+use Path::Dispatcher::Test::Framework;
before qr/foo/ => sub {
push @main::calls, 'app before foo';
Modified: Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/Framework.pm
==============================================================================
--- Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/Framework.pm (original)
+++ Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/Framework.pm Sun Oct 19 08:04:55 2008
@@ -2,7 +2,7 @@
package Path::Dispatcher::Test::Framework;
use strict;
use warnings;
-use Path::Dispatcher::Declarative -base;
+use Path::Dispatcher::Declarative;
before qr/foo/ => sub {
push @main::calls, 'framework before foo';
More information about the Bps-public-commit
mailing list