From: Rafael Kitover Date: Sat, 24 Jul 2010 19:18:05 +0000 (-0400) Subject: remove dep on Data::Dumper::Concise X-Git-Tag: 0.07001~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=15efd63a68d0c568a39fdef54f96f8c13cabbdd3;p=dbsrgits%2FDBIx-Class-Schema-Loader.git remove dep on Data::Dumper::Concise --- diff --git a/Makefile.PL b/Makefile.PL index 9ab25fc..1ed32e9 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -36,7 +36,6 @@ requires 'Class::Unload' => 0; requires 'File::Slurp' => '9999.13'; requires 'List::MoreUtils' => 0; requires 'namespace::clean' => 0; -requires 'Data::Dumper::Concise' => '2.002'; requires 'Scope::Guard' => 0; requires 'List::MoreUtils' => 0; requires 'Exporter' => '5.63'; diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index fc8da77..42e2fa4 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -16,10 +16,9 @@ use Lingua::EN::Inflect::Phrase qw//; use File::Temp qw//; use Class::Unload; use Class::Inspector (); -use Data::Dumper::Concise; use Scalar::Util 'looks_like_number'; use File::Slurp 'slurp'; -use DBIx::Class::Schema::Loader::Utils 'split_name'; +use DBIx::Class::Schema::Loader::Utils qw/split_name dumper_squashed/; use DBIx::Class::Schema::Loader::Optional::Dependencies (); use Try::Tiny; use DBIx::Class (); @@ -1822,12 +1821,7 @@ sub _make_pod { $s = !defined $s ? 'undef' : length($s) == 0 ? '(empty string)' : ref($s) eq 'SCALAR' ? $$s : - ref($s) ? do { - my $dd = Dumper; - $dd->Indent(0); - $dd->Values([$s]); - $dd->Dump; - } : + ref($s) ? dumper_squashed $s : looks_like_number($s) ? $s : qq{'$s'} ; diff --git a/lib/DBIx/Class/Schema/Loader/Utils.pm b/lib/DBIx/Class/Schema/Loader/Utils.pm index aaea3aa..5371dab 100644 --- a/lib/DBIx/Class/Schema/Loader/Utils.pm +++ b/lib/DBIx/Class/Schema/Loader/Utils.pm @@ -5,7 +5,7 @@ use strict; use warnings; use Exporter 'import'; -our @EXPORT_OK = qw/split_name/; +our @EXPORT_OK = qw/split_name dumper dumper_squashed/; use constant BY_CASE_TRANSITION => qr/(?<=[[:lower:]\d])[\W_]*(?=[[:upper:]])|[\W_]+/; @@ -19,5 +19,23 @@ sub split_name($) { split $name =~ /[[:upper:]]/ && $name =~ /[[:lower:]]/ ? BY_CASE_TRANSITION : BY_NON_ALPHANUM, $name; } +# Stolen from Data::Dumper::Concise + +sub dumper($) { + my $val = shift; + + my $dd = Data::Dumper->new([]); + $dd->Terse(1)->Indent(1)->Useqq(1)->Deparse(1)->Quotekeys(0)->Sortkeys(1); + return $dd->Values([ $val ])->Dump; +} + +sub dumper_squashed($) { + my $val = shift; + + my $dd = Data::Dumper->new([]); + $dd->Terse(1)->Indent(1)->Useqq(1)->Deparse(1)->Quotekeys(0)->Sortkeys(1)->Indent(0); + return $dd->Values([ $val ])->Dump; +} + 1; # vim:et sts=4 sw=4 tw=0: diff --git a/t/23dumpmore.t b/t/23dumpmore.t index 8f48199..61b3429 100644 --- a/t/23dumpmore.t +++ b/t/23dumpmore.t @@ -2,7 +2,7 @@ use strict; use Test::More; use File::Path; use IPC::Open3; -use Data::Dumper::Concise; +use DBIx::Class::Schema::Loader::Utils 'dumper_squashed'; use DBIx::Class::Schema::Loader (); use DBIx::Class::Schema::Loader::Optional::Dependencies (); use File::Temp 'tempfile'; @@ -42,7 +42,7 @@ sub dump_dbicdump { my @cmd = ($^X, qw(./script/dbicdump)); while (my ($opt, $val) = each(%{ $tdata{options} })) { - $val = Dumper($val) if ref $val; + $val = dumper_squashed $val if ref $val; push @cmd, '-o', "$opt=$val"; } diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 49137d6..d3086ac 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -12,7 +12,7 @@ use DBI; use Digest::MD5; use File::Find 'find'; use Class::Unload (); -use Data::Dumper::Concise; +use DBIx::Class::Schema::Loader::Utils 'dumper_squashed'; use List::MoreUtils 'apply'; use DBIx::Class::Schema::Loader::Optional::Dependencies (); use namespace::clean; @@ -1011,19 +1011,9 @@ sub test_data_types { my %info = %{ $rsrc->column_info($col_name) }; delete @info{qw/is_nullable timezone locale sequence/}; - my $text_col_def = do { - my $dd = Dumper; - $dd->Indent(0); - $dd->Values([\%info]); - $dd->Dump; - }; - - my $text_expected_info = do { - my $dd = Dumper; - $dd->Indent(0); - $dd->Values([$expected_info]); - $dd->Dump; - }; + my $text_col_def = dumper_squashed \%info; + + my $text_expected_info = dumper_squashed $expected_info; is_deeply \%info, $expected_info, "test column $col_name has definition: $text_col_def expecting: $text_expected_info";