From: Rafael Kitover Date: Wed, 28 Sep 2011 19:31:02 +0000 (-0400) Subject: remove dependency on File::Slurp X-Git-Tag: 0.07011~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-Schema-Loader.git;a=commitdiff_plain;h=a79e11896d6d1d70842c432cde8830ded06568ce remove dependency on File::Slurp The current version of File::Slurp has a "use 5.6.2;" statement. This throws a warning on perl 5.10.0 which breaks some of our tests. The statement should be "use 5.006002;". My attempts to contact the author, Uri Guttman were not successful. As we have our own convenience method 'slurp_file' in ::Utils now, there is little need to depend on File::Slurp anymore anyway. For these reasons the dependency has been removed. --- diff --git a/Changes b/Changes index 16a2de9..5ece3fb 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - remove dependency on File::Slurp - allow the constraint and exclude options to be used simultaneously (bphillips) - fix Oracle common tests fail with multi_schema due to not resetting diff --git a/Makefile.PL b/Makefile.PL index 511b9d3..359ff9a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -49,7 +49,6 @@ requires 'Carp::Clan' => 0; requires 'Class::Inspector' => 0; requires 'DBIx::Class' => '0.08127'; requires 'Class::Unload' => 0; -requires 'File::Slurp' => '9999.14'; requires 'List::MoreUtils' => 0; requires 'namespace::clean' => '0.20'; requires 'Scope::Guard' => 0; diff --git a/lib/DBIx/Class/Schema/Loader/Utils.pm b/lib/DBIx/Class/Schema/Loader/Utils.pm index a920890..5b19370 100644 --- a/lib/DBIx/Class/Schema/Loader/Utils.pm +++ b/lib/DBIx/Class/Schema/Loader/Utils.pm @@ -5,7 +5,6 @@ use strict; use warnings; use Data::Dumper (); use Test::More; -use File::Slurp 'read_file'; use namespace::clean; use Exporter 'import'; @@ -137,7 +136,9 @@ sub warnings_exist_silent(&$$) { } sub slurp_file($) { - my $data = read_file(shift, binmode => ':encoding(UTF-8)'); + open my $fh, '<:encoding(UTF-8)', shift; + my $data = do { local $/; <$fh> }; + close $fh; $data =~ s/$CRLF|$LF/\n/g; diff --git a/t/25backcompat.t b/t/25backcompat.t index eaa97bd..57a9c04 100644 --- a/t/25backcompat.t +++ b/t/25backcompat.t @@ -6,8 +6,8 @@ use File::Path qw/rmtree make_path/; use Class::Unload; use File::Temp qw/tempfile tempdir/; use IO::File; -use File::Slurp 'slurp'; use DBIx::Class::Schema::Loader (); +use DBIx::Class::Schema::Loader::Utils 'slurp_file'; use Lingua::EN::Inflect::Number (); use lib qw(t/lib); use make_dbictest_db_with_unique; @@ -735,7 +735,7 @@ sub class_content_like; my $schema = $res->{schema}; my $file = $schema->loader->get_dump_filename($SCHEMA_CLASS); - my $code = slurp $file; + my $code = slurp_file $file; my ($dumped_ver) = $code =~ /^# Created by DBIx::Class::Schema::Loader v(\S+)/m; @@ -1302,7 +1302,7 @@ sub class_content_like { my ($schema, $class, $re, $test_name) = @_; my $file = $schema->loader->get_dump_filename($class); - my $code = slurp $file; + my $code = slurp_file $file; like $code, $re, $test_name; } diff --git a/t/30_01comments.t b/t/30_01comments.t index e7edc25..b00d42b 100644 --- a/t/30_01comments.t +++ b/t/30_01comments.t @@ -1,10 +1,11 @@ use strict; +use warnings; use Test::More; use Test::Exception; use Test::Warn; -use lib qw(t/lib); -use File::Slurp qw(slurp); +use DBIx::Class::Schema::Loader::Utils 'slurp_file'; use File::Path; +use lib qw(t/lib); use make_dbictest_db_comments; use dbixcsl_test_dir qw/$tdir/; @@ -23,8 +24,8 @@ DBICTest::Schema::1->connect($make_dbictest_db_comments::dsn); plan tests => 4; -my $foo = slurp("$dump_path/DBICTest/Schema/1/Result/Foo.pm"); -my $bar = slurp("$dump_path/DBICTest/Schema/1/Result/Bar.pm"); +my $foo = slurp_file("$dump_path/DBICTest/Schema/1/Result/Foo.pm"); +my $bar = slurp_file("$dump_path/DBICTest/Schema/1/Result/Bar.pm"); like($foo, qr/Result::Foo - a short comment/, 'Short table comment inline'); like($bar, qr/Result::Bar\n\n=head1 DESCRIPTION\n\na (very ){80}long comment/, diff --git a/t/30_02bad_comment_table.t b/t/30_02bad_comment_table.t index ec0eda6..bee64f9 100644 --- a/t/30_02bad_comment_table.t +++ b/t/30_02bad_comment_table.t @@ -1,13 +1,14 @@ use strict; +use warnings; use Test::More; use Test::Exception; use Test::Warn; -use lib qw(t/lib); -use File::Slurp qw(slurp); +use DBIx::Class::Schema::Loader::Utils 'slurp_file'; use File::Path; +use Try::Tiny; +use lib qw(t/lib); use make_dbictest_db_bad_comment_tables; use dbixcsl_test_dir qw/$tdir/; -use Try::Tiny; my $dump_path = "$tdir/dump"; @@ -26,8 +27,8 @@ try { plan tests => 1; -my $foo = try { slurp("$dump_path/DBICTest/Schema/1/Result/Foo.pm") }; -my $bar = try { slurp("$dump_path/DBICTest/Schema/1/Result/Bar.pm") }; +my $foo = try { slurp_file("$dump_path/DBICTest/Schema/1/Result/Foo.pm") }; +my $bar = try { slurp_file("$dump_path/DBICTest/Schema/1/Result/Bar.pm") }; like($foo, qr/Result::Foo\n/, 'No error from invalid comment tables'); diff --git a/t/30_03no_comment_table.t b/t/30_03no_comment_table.t index 6652bdf..6ce45ff 100644 --- a/t/30_03no_comment_table.t +++ b/t/30_03no_comment_table.t @@ -1,10 +1,11 @@ use strict; +use warnings; use Test::More; use Test::Exception; use Test::Warn; -use lib qw(t/lib); -use File::Slurp qw(slurp); +use DBIx::Class::Schema::Loader::Utils 'slurp_file'; use File::Path; +use lib qw(t/lib); use make_dbictest_db; use dbixcsl_test_dir qw/$tdir/; @@ -23,8 +24,8 @@ DBICTest::Schema::1->connect($make_dbictest_db::dsn); plan tests => 1; -my $foo = slurp("$dump_path/DBICTest/Schema/1/Result/Foo.pm"); -my $bar = slurp("$dump_path/DBICTest/Schema/1/Result/Bar.pm"); +my $foo = slurp_file("$dump_path/DBICTest/Schema/1/Result/Foo.pm"); +my $bar = slurp_file("$dump_path/DBICTest/Schema/1/Result/Bar.pm"); like($foo, qr/Result::Foo\n/, 'No error from lack of comment tables');