refactored
[catagits/Catalyst-Plugin-ConfigLoader.git] / lib / Catalyst / Plugin / ConfigLoader / INI.pm
index df263da..64d04d7 100644 (file)
@@ -13,11 +13,21 @@ Loads INI files. Example:
 \r
     name=TestApp\r
     \r
-    [Controller::Config]\r
+    [Controller::Foo]\r
     foo=bar\r
 \r
 =head1 METHODS\r
 \r
+=head2 extensions( )\r
+\r
+return an array of valid extensions (C<ini>).\r
+\r
+=cut\r
+\r
+sub extensions {\r
+    return qw( ini );\r
+}\r
+\r
 =head2 load( $file )\r
 \r
 Attempts to load C<$file> as an INI file.\r
@@ -25,23 +35,13 @@ Attempts to load C<$file> as an INI file.
 =cut\r
 \r
 sub load {\r
-       my $class    = shift;\r
-       my $confpath = shift;\r
-\r
-       my $file;\r
-    if( $confpath =~ /\.(.{3})$/ ) {\r
-        return unless $1 eq 'ini';\r
-        $file = $confpath;\r
-    }\r
-    else {\r
-        $file = "$confpath.ini";\r
-    }\r
-    \r
-    return unless -f $file;\r
+    my $class = shift;\r
+    my $file  = shift;\r
 \r
     require Config::Tiny;\r
     my $config = Config::Tiny->read( $file );\r
     my $main   = delete $config->{ _ };\r
+    \r
     $config->{ $_ } = $main->{ $_ } for keys %$main;\r
 \r
     return $config;\r
@@ -68,6 +68,8 @@ it under the same terms as Perl itself.
 \r
 =item * L<Catalyst>\r
 \r
+=item * <Catalyst::Plugin::ConfigLoader>\r
+\r
 =back\r
 \r
 =cut\r