X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FConfigLoader.pm;h=374dc41db4fc4698ab2649fcd8e2cfc90ba86b57;hp=c50c0f557d56f488fae57f7c368f454fc144a192;hb=c7b9fd14369947e369470e283e1dee9891e6f76d;hpb=af00c122ea90cce0d758c8757d0746b14211d4bf diff --git a/lib/Catalyst/Plugin/ConfigLoader.pm b/lib/Catalyst/Plugin/ConfigLoader.pm index c50c0f5..374dc41 100644 --- a/lib/Catalyst/Plugin/ConfigLoader.pm +++ b/lib/Catalyst/Plugin/ConfigLoader.pm @@ -10,7 +10,7 @@ use Module::Pluggable::Fast require => 1; use Data::Visitor::Callback; -our $VERSION = '0.06'; +our $VERSION = '0.07'; =head1 NAME @@ -23,7 +23,7 @@ Catalyst::Plugin::ConfigLoader - Load config files of various types # ConfigLoader should be first in your list so # other plugins can get the config information use Catalyst qw( ConfigLoader ... ); - + # by default myapp.* will be loaded # you can specify a file if you'd like __PACKAGE__->config( file = > 'config.yaml' ); @@ -68,6 +68,9 @@ sub setup { for( @files ) { next unless -f $_; my $config = $loader->load( $_ ); + + _fix_syntax( $config ); + $c->config( $config ) if $config; } } @@ -104,6 +107,23 @@ sub finalize_config { $v->visit( $c->config ); } +sub _fix_syntax { + my $config = shift; + my @components = ( + map +{ + prefix => $_ eq 'Component' ? '' : $_ . '::', + values => delete $config->{ lc $_ } || delete $config->{ $_ } + }, qw( Component Model View Controller ) + ); + + foreach my $comp ( @components ) { + my $prefix = $comp->{ prefix }; + foreach my $element ( keys %{ $comp->{ values } } ) { + $config->{ "$prefix$element" } = $comp->{ values }->{ $element }; + } + } +} + =head1 AUTHOR =over 4