remove dependency on File::Slurp
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / Utils.pm
index 667caee..5b19370 100644 (file)
@@ -8,7 +8,7 @@ use Test::More;
 use namespace::clean;
 use Exporter 'import';
 
-our @EXPORT_OK = qw/split_name dumper dumper_squashed eval_package_without_redefine_warnings class_path no_warnings warnings_exist warnings_exist_silent/;
+our @EXPORT_OK = qw/split_name dumper dumper_squashed eval_package_without_redefine_warnings class_path no_warnings warnings_exist warnings_exist_silent slurp_file/;
 
 use constant BY_CASE_TRANSITION =>
     qr/(?<=[[:lower:]\d])[\W_]*(?=[[:upper:]])|[\W_]+/;
@@ -16,6 +16,9 @@ use constant BY_CASE_TRANSITION =>
 use constant BY_NON_ALPHANUM =>
     qr/[\W_]+/;
 
+my $LF   = "\x0a";
+my $CRLF = "\x0d\x0a";
+
 sub split_name($) {
     my $name = shift;
 
@@ -132,6 +135,15 @@ sub warnings_exist_silent(&$$) {
     ok $matched, $test_name;
 }
 
+sub slurp_file($) {
+    open my $fh, '<:encoding(UTF-8)', shift;
+    my $data = do { local $/; <$fh> };
+    close $fh;
+
+    $data =~ s/$CRLF|$LF/\n/g;
+
+    return $data;
+}
 
 1;
 # vim:et sts=4 sw=4 tw=0: