From: Tomas Doran <bobtfish@bobtfish.net>
Date: Sat, 22 May 2010 11:47:53 +0000 (+0100)
Subject: Fix RT#57027
X-Git-Tag: 0.07~1
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3690815fae7ae7497b9047b720b1a043bc3304c8;p=gitmo%2FMooseX-SimpleConfig.git

Fix RT#57027
---

diff --git a/ChangeLog b/ChangeLog
index 7806a66..52b96c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 Revision history for Perl extension MooseX::SimpleConfig
 
+  - Reverse order of testing config files so that latter options on the
+    command line (when multiple are specified) take precedence. (RT#57027)
+  - Reduce exception thrown by being unable to find a config file to a
+    warning (RT#57027)
   - Fixed configfile attribute examples
   - Added metadata to Makefile.PL
 
diff --git a/README b/README
index 65b8383..20a0050 100644
--- a/README
+++ b/README
@@ -68,12 +68,12 @@ ATTRIBUTES
     Provided by the base role MooseX::ConfigFromFile. You can provide a
     default configfile pathname like so:
 
-      has +configfile ( default => '/etc/myapp.yaml' );
+      has '+configfile' => ( default => '/etc/myapp.yaml' );
 
     You can pass an array of filenames if you want, but as usual the array
     has to be wrapped in a sub ref.
 
-      has +configfile ( default => sub { [ '/etc/myapp.yaml', '/etc/myapp_local.yml' ] } );
+      has '+configfile' => ( default => sub { [ '/etc/myapp.yaml', '/etc/myapp_local.yml' ] } );
 
     Config files are trivially merged at the top level, with the right-hand
     files taking precedence.
diff --git a/lib/MooseX/SimpleConfig.pm b/lib/MooseX/SimpleConfig.pm
index 1a7add5..2850669 100644
--- a/lib/MooseX/SimpleConfig.pm
+++ b/lib/MooseX/SimpleConfig.pm
@@ -24,10 +24,11 @@ sub get_config_from_file {
     } );
 
     my %raw_config;
-    foreach my $file_tested ( @{$files_ref} ) {
+    foreach my $file_tested ( reverse @{$files_ref} ) {
         if ( ! exists $raw_cfany->{$file_tested} ) {
-            die qq{Specified configfile '$file_tested' does not exist, } .
-                q{is empty, or is not readable};
+            warn qq{Specified configfile '$file_tested' does not exist, } .
+                qq{is empty, or is not readable\n};
+                next;
         }
 
         my $cfany_hash = $raw_cfany->{$file_tested};