[Catalyst] ConfigLoader patch: pretty syntax for plugins

Dagfinn Ilmari Mannsåker ilmari at ilmari.org
Tue Aug 5 00:51:10 BST 2008


Hi all,

I noticed that ConfigLoader's pretty syntax¹ (particluarly with
Config::General) for model, view and controller config didn't extend to
plugin config.

[1]: Like this:

<Model Foo>
    bar baz
</Model>

instead of 

<Model::Foo>
    bar baz
</Model::Foo>

Here's a patch that extends the feature to cover plugins:

=== Changes
==================================================================
--- Changes	(revision 55488)
+++ Changes	(local)
@@ -5,6 +5,7 @@
       Config::General format
     - fix up pod to explain in more detail how to pass options to each
       driver class (Sergio Salvi)
+    - add nice syntax for plugins as well as models/views/controllers
 
 0.20  Fri May 02 2008
     - sort configs by filename for loading (RT #31498)
=== lib/Catalyst/Plugin/ConfigLoader.pm
==================================================================
--- lib/Catalyst/Plugin/ConfigLoader.pm	(revision 55488)
+++ lib/Catalyst/Plugin/ConfigLoader.pm	(local)
@@ -227,7 +227,7 @@
             values => delete $config->{ lc $_ } || delete $config->{ $_ }
         },
         grep { ref $config->{ lc $_ } || ref $config->{ $_ } }
-            qw( Component Model M View V Controller C )
+            qw( Component Model M View V Controller C Plugin )
     );
 
     foreach my $comp ( @components ) {
=== t/20-mock_load.t
==================================================================
--- t/20-mock_load.t	(revision 55488)
+++ t/20-mock_load.t	(local)
@@ -1,6 +1,6 @@
 package MockApp;
 
-use Test::More tests => 9;
+use Test::More tests => 10;
 
 use Cwd;
 $ENV{ CATALYST_HOME } = cwd . '/t/mockapp';
@@ -21,3 +21,4 @@
 is( __PACKAGE__->config->{ 'view' },                     'View::TT::New' );
 is( __PACKAGE__->config->{ 'foo_sub' },                  'x-y' );
 is( __PACKAGE__->config->{ 'literal_macro' },            '__DATA__' );
+is( __PACKAGE__->config->{ 'Plugin::Zot' }->{ zoot },    'zooot');
=== t/mockapp/mockapp.pl
==================================================================
--- t/mockapp/mockapp.pl	(revision 55488)
+++ t/mockapp/mockapp.pl	(local)
@@ -4,4 +4,5 @@
     'Model::Baz'      => { qux => 'xyzzy' },
     foo_sub           => '__foo(x,y)__',
     literal_macro     => '__literal(__DATA__)__',
+    Plugin            => { Zot => { zoot => 'zooot' } },
 }


-- 
ilmari
"A disappointingly low fraction of the human race is,
 at any given time, on fire." - Stig Sandbeck Mathisen



More information about the Catalyst mailing list