[Catalyst-commits] r7437 - in trunk/Catalyst-Plugin-ConfigLoader: . lib/Catalyst/Plugin

bricas at dev.catalyst.perl.org bricas at dev.catalyst.perl.org
Wed Feb 6 16:37:14 GMT 2008


Author: bricas
Date: 2008-02-06 16:37:13 +0000 (Wed, 06 Feb 2008)
New Revision: 7437

Modified:
   trunk/Catalyst-Plugin-ConfigLoader/Changes
   trunk/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm
Log:
sort configs by filename for loading (RT #31498)

Modified: trunk/Catalyst-Plugin-ConfigLoader/Changes
===================================================================
--- trunk/Catalyst-Plugin-ConfigLoader/Changes	2008-02-05 20:38:25 UTC (rev 7436)
+++ trunk/Catalyst-Plugin-ConfigLoader/Changes	2008-02-06 16:37:13 UTC (rev 7437)
@@ -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
 

Modified: trunk/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm
===================================================================
--- trunk/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm	2008-02-05 20:38:25 UTC (rev 7436)
+++ trunk/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm	2008-02-06 16:37:13 UTC (rev 7437)
@@ -8,7 +8,7 @@
 use Data::Visitor::Callback;
 use Catalyst::Utils ();
 
-our $VERSION = '0.19';
+our $VERSION = '0.20';
 
 =head1 NAME
 
@@ -59,21 +59,24 @@
         }
     );
 
+    # 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 @@
 
 =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. 




More information about the Catalyst-commits mailing list