remove dep on Data::Dumper::Concise
Rafael Kitover [Sat, 24 Jul 2010 19:18:05 +0000 (15:18 -0400)]
Makefile.PL
lib/DBIx/Class/Schema/Loader/Base.pm
lib/DBIx/Class/Schema/Loader/Utils.pm
t/23dumpmore.t
t/lib/dbixcsl_common_tests.pm

index 9ab25fc..1ed32e9 100644 (file)
@@ -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';
index fc8da77..42e2fa4 100644 (file)
@@ -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'}
                                   ;
index aaea3aa..5371dab 100644 (file)
@@ -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:
index 8f48199..61b3429 100644 (file)
@@ -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";
     }
 
index 49137d6..d3086ac 100644 (file)
@@ -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";