[Catalyst-commits] r13193 - in Catalyst-Runtime/5.80/trunk: . lib
t/aggregate t/lib t/lib/PluginTestApp/Controller
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Sun May 2 23:16:25 GMT 2010
Author: rafl
Date: 2010-05-03 00:16:25 +0100 (Mon, 03 May 2010)
New Revision: 13193
Modified:
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/Makefile.PL
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_plugin.t
Catalyst-Runtime/5.80/trunk/t/lib/PluginTestApp.pm
Catalyst-Runtime/5.80/trunk/t/lib/PluginTestApp/Controller/Root.pm
Log:
Allow parameterized roles to be applied as plugins.
Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2010-05-02 22:26:22 UTC (rev 13192)
+++ Catalyst-Runtime/5.80/trunk/Changes 2010-05-02 23:16:25 UTC (rev 13193)
@@ -20,6 +20,7 @@
HttpOnly flag
- Allow the myapp_test.pl script to be given a list of paths which it
will retrieve all of. (RT#53653)
+ - Allow parameterized roles to be applied as plugins.
Documentation:
- The Catalyst::Test::get method is documented as returning the raw
Modified: Catalyst-Runtime/5.80/trunk/Makefile.PL
===================================================================
--- Catalyst-Runtime/5.80/trunk/Makefile.PL 2010-05-02 22:26:22 UTC (rev 13192)
+++ Catalyst-Runtime/5.80/trunk/Makefile.PL 2010-05-02 23:16:25 UTC (rev 13193)
@@ -26,6 +26,7 @@
requires 'Class::C3::Adopt::NEXT' => '0.07';
requires 'CGI::Simple::Cookie' => '1.109';
requires 'Data::Dump';
+requires 'Data::OptList';
requires 'HTML::Entities';
requires 'HTTP::Body' => '1.06'; # ->cleanup(1)
requires 'HTTP::Headers' => '1.64';
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2010-05-02 22:26:22 UTC (rev 13192)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2010-05-02 23:16:25 UTC (rev 13193)
@@ -14,6 +14,7 @@
use Catalyst::Response;
use Catalyst::Utils;
use Catalyst::Controller;
+use Data::OptList;
use Devel::InnerPackage ();
use File::stat;
use Module::Pluggable::Object ();
@@ -2782,6 +2783,7 @@
my ( $proto, $plugin, $instant ) = @_;
my $class = ref $proto || $proto;
+ # FIXME: also pass along plugin options as soon as the mop has it
Class::MOP::load_class( $plugin );
$class->log->warn( "$plugin inherits from 'Catalyst::Component' - this is decated and will not work in 5.81" )
if $plugin->isa( 'Catalyst::Component' );
@@ -2797,22 +2799,30 @@
my ( $class, $plugins ) = @_;
$class->_plugins( {} ) unless $class->_plugins;
- $plugins ||= [];
+ $plugins = Data::OptList::mkopt($plugins || []);
- my @plugins = Catalyst::Utils::resolve_namespace($class . '::Plugin', 'Catalyst::Plugin', @$plugins);
+ my @plugins = map {
+ [ Catalyst::Utils::resolve_namespace(
+ $class . '::Plugin',
+ 'Catalyst::Plugin', $_->[0]
+ ),
+ $_->[1],
+ ]
+ } @{ $plugins };
for my $plugin ( reverse @plugins ) {
- Class::MOP::load_class($plugin);
- my $meta = find_meta($plugin);
+ Class::MOP::load_class($plugin->[0]);
+ # pass along $plugin->[1] as well once cmop supports it
+ my $meta = find_meta($plugin->[0]);
next if $meta && $meta->isa('Moose::Meta::Role');
- $class->_register_plugin($plugin);
+ $class->_register_plugin($plugin->[0]);
}
my @roles =
- map { $_->name }
- grep { $_ && blessed($_) && $_->isa('Moose::Meta::Role') }
- map { find_meta($_) }
+ map { $_->[0]->name, $_->[1] }
+ grep { $_->[0] && blessed($_->[0]) && $_->[0]->isa('Moose::Meta::Role') }
+ map { [find_meta($_->[0]), $_->[1]] }
@plugins;
Moose::Util::apply_all_roles(
Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_plugin.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_plugin.t 2010-05-02 22:26:22 UTC (rev 13192)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_plugin.t 2010-05-02 23:16:25 UTC (rev 13193)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 24;
+use Test::More;
use lib 't/lib';
@@ -61,3 +61,4 @@
is_deeply [ TestApp->registered_plugins ], \@expected,
'registered_plugins() should only report the plugins for the current class';
+done_testing;
Modified: Catalyst-Runtime/5.80/trunk/t/lib/PluginTestApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/PluginTestApp/Controller/Root.pm 2010-05-02 22:26:22 UTC (rev 13192)
+++ Catalyst-Runtime/5.80/trunk/t/lib/PluginTestApp/Controller/Root.pm 2010-05-02 23:16:25 UTC (rev 13193)
@@ -34,6 +34,13 @@
ref($c)->plugin( faux => $faux_plugin );
isa_ok $c, 'Catalyst::Plugin::Test::Plugin';
+
+ # applied parameterized role
+ if (eval { require MooseX::Role::Parameterized; 1 }) {
+ can_ok $c, 'affe';
+ is $c->affe, 'birne', 'right method created by parameterized role';
+ }
+
isa_ok $c, 'TestApp::Plugin::FullyQualified';
ok !$c->isa($faux_plugin),
'... and it should not inherit from the instant plugin';
Modified: Catalyst-Runtime/5.80/trunk/t/lib/PluginTestApp.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/PluginTestApp.pm 2010-05-02 22:26:22 UTC (rev 13192)
+++ Catalyst-Runtime/5.80/trunk/t/lib/PluginTestApp.pm 2010-05-02 23:16:25 UTC (rev 13193)
@@ -1,10 +1,13 @@
package PluginTestApp;
use Test::More;
-use Catalyst qw(
- Test::Plugin
- +TestApp::Plugin::FullyQualified
- );
+use Catalyst (
+ 'Test::Plugin',
+ '+TestApp::Plugin::FullyQualified',
+ (eval { require MooseX::Role::Parameterized; 1 }
+ ? ('+TestApp::Plugin::ParameterizedRole' => { method_name => 'affe' })
+ : ()),
+);
sub _test_plugins {
my $c = shift;
More information about the Catalyst-commits
mailing list