ConfigLoader updated to version 0.07
Brian Cassidy [Tue, 9 May 2006 23:48:04 +0000 (23:48 +0000)]
Changes
lib/Catalyst/Plugin/ConfigLoader.pm
lib/Catalyst/Plugin/ConfigLoader/YAML.pm

diff --git a/Changes b/Changes
index 6ad4142..54dffe5 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 This file documents the revision history for Perl extension Catalyst.
 
         - Fix ->config failing to copy _config for subclassing
+        - ConfigLoader: Updated to version 0.07
 
 5.6902  2006-05-04 13:00:00
         - Remove tarballs and OSX metadata files.
index c50c0f5..374dc41 100644 (file)
@@ -10,7 +10,7 @@ use Module::Pluggable::Fast
     require => 1;\r
 use Data::Visitor::Callback;\r
 \r
-our $VERSION = '0.06';\r
+our $VERSION = '0.07';\r
 \r
 =head1 NAME\r
 \r
@@ -23,7 +23,7 @@ Catalyst::Plugin::ConfigLoader - Load config files of various types
     # ConfigLoader should be first in your list so\r
     # other plugins can get the config information\r
     use Catalyst qw( ConfigLoader ... );\r
-       \r
+    \r
     # by default myapp.* will be loaded\r
     # you can specify a file if you'd like\r
     __PACKAGE__->config( file = > 'config.yaml' );    \r
@@ -68,6 +68,9 @@ sub setup {
         for( @files ) {\r
             next unless -f $_;\r
             my $config = $loader->load( $_ );\r
+            \r
+            _fix_syntax( $config );\r
+            \r
             $c->config( $config ) if $config;\r
         }\r
     }\r
@@ -104,6 +107,23 @@ sub finalize_config {
     $v->visit( $c->config );\r
 }\r
 \r
+sub _fix_syntax {\r
+    my $config     = shift;\r
+    my @components = (\r
+        map +{\r
+            prefix => $_ eq 'Component' ? '' : $_ . '::',\r
+            values => delete $config->{ lc $_ } || delete $config->{ $_ }\r
+        }, qw( Component Model View Controller )\r
+    );\r
+\r
+    foreach my $comp ( @components ) {\r
+        my $prefix = $comp->{ prefix };\r
+        foreach my $element ( keys %{ $comp->{ values } } ) {\r
+            $config->{ "$prefix$element" } = $comp->{ values }->{ $element };\r
+        }\r
+    }\r
+}\r
+\r
 =head1 AUTHOR\r
 \r
 =over 4 \r
index 88683dc..3e521ff 100644 (file)
@@ -74,6 +74,10 @@ it under the same terms as Perl itself.
 \r
 =item * L<Catalyst::Plugin::ConfigLoader>\r
 \r
+=item * L<YAML>\r
+\r
+=item * L<YAML::Syck>\r
+\r
 =back\r
 \r
 =cut\r