fix ConfigLoader
David Kamholz [Wed, 8 Feb 2006 20:42:11 +0000 (20:42 +0000)]
Build.PL
Changes
lib/Catalyst/Plugin/ConfigLoader/JSON.pm
lib/Catalyst/Plugin/ConfigLoader/YAML.pm

index a8e80b1..461dbd9 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -10,7 +10,6 @@ my $build = Module::Build->new(
        create_makefile_pl => 'traditional',\r
        requires           => {\r
                'Catalyst'    => 0,\r
-               'File::Slurp' => 0,\r
                'Data::Visitor' => 0.02,\r
        },\r
 );\r
diff --git a/Changes b/Changes
index 4c4c0f6..dcc1191 100644 (file)
--- a/Changes
+++ b/Changes
@@ -4,7 +4,7 @@ Revision history for Perl extension Catalyst::Plugin::ConfigLoader.
     - add finalize_config method\r
     - make default finalize_config traverse the config and substitute\r
       things beginning __HOME__/* with real path\r
-    - don't (re-)use File::Slurp, not sure how to eliminate warnings\r
+    - don't use File::Slurp, produces annoying warnings on some systems\r
 \r
 0.03  Mon Jan 30 2006\r
     - pod fixes\r
index 3a187d1..a820535 100644 (file)
@@ -3,8 +3,6 @@ package Catalyst::Plugin::ConfigLoader::JSON;
 use strict;\r
 use warnings;\r
 \r
-#use File::Slurp;    \r
-\r
 =head1 NAME\r
 \r
 Catalyst::Plugin::ConfigLoader::JSON - Load JSON config files\r
@@ -42,7 +40,10 @@ sub load {
     my $class = shift;\r
     my $file  = shift;\r
 \r
-    my $content = read_file( $file );\r
+    my $content;\r
+    open(my $fh, $file) or die $!;\r
+    { local $/; $content = <$fh> }\r
+    close $fh;\r
 \r
     eval { require JSON::Syck; };\r
     if( $@ ) {\r
index e16bce1..f1f6588 100644 (file)
@@ -3,8 +3,6 @@ package Catalyst::Plugin::ConfigLoader::YAML;
 use strict;\r
 use warnings;\r
 \r
-#use File::Slurp;\r
-\r
 =head1 NAME\r
 \r
 Catalyst::Plugin::ConfigLoader::YAML - Load YAML config files\r
@@ -46,7 +44,10 @@ sub load {
         return YAML::LoadFile( $file );\r
     }\r
     else {\r
-        my $content = read_file( $file );\r
+        my $content;\r
+        open(my $fh, $file) or die $!;\r
+        { local $/; $content = <$fh> }\r
+        close $fh;\r
         return YAML::Syck::Load( $content );\r
     }\r
 }\r