From: Brian Cassidy Date: Wed, 6 Feb 2008 16:37:13 +0000 (+0000) Subject: sort configs by filename for loading (RT #31498) X-Git-Tag: v0.20~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Plugin-ConfigLoader.git;a=commitdiff_plain;h=90c108e6b1da7eedb2f0adb194c68edd4dec4668 sort configs by filename for loading (RT #31498) --- diff --git a/Changes b/Changes index 505effa..3d4ac43 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension Catalyst::Plugin::ConfigLoader. +0.20 Wed Feb 06 2008 + - sort configs by filename for loading (RT #31498) + 0.19 Wed Nov 21 2007 - fixed suffix appending to explicit config paths diff --git a/lib/Catalyst/Plugin/ConfigLoader.pm b/lib/Catalyst/Plugin/ConfigLoader.pm index 5c2a61e..930d7c1 100644 --- a/lib/Catalyst/Plugin/ConfigLoader.pm +++ b/lib/Catalyst/Plugin/ConfigLoader.pm @@ -8,7 +8,7 @@ use NEXT; use Data::Visitor::Callback; use Catalyst::Utils (); -our $VERSION = '0.19'; +our $VERSION = '0.20'; =head1 NAME @@ -59,21 +59,24 @@ sub setup { } ); + # map the array of hashrefs to a simple hash + my %configs = map { %$_ } @$cfg; + # split the responses into normal and local cfg my $local_suffix = $c->get_config_local_suffix; - my ( @cfg, @localcfg ); - for ( @$cfg ) { - if ( ( keys %$_ )[ 0 ] =~ m{ $local_suffix \. }xms ) { - push @localcfg, $_; + my ( @main, @locals ); + for ( sort keys %configs ) { + if ( m{$local_suffix\.}ms ) { + push @locals, $_; } else { - push @cfg, $_; + push @main, $_; } } # load all the normal cfgs, then the local cfgs last so they can override # normal cfgs - $c->load_config( $_ ) for @cfg, @localcfg; + $c->load_config( { $_ => $configs{ $_ } } ) for @main, @locals; $c->finalize_config; $c->NEXT::setup( @_ ); @@ -335,7 +338,7 @@ Work to this module has been generously sponsored by: =head1 COPYRIGHT AND LICENSE -Copyright 2007 by Brian Cassidy +Copyright 2008 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.