X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FDDS.pm;h=6e01fe7145469f1289f3cad2ddaa14bbb950ea4b;hp=512d48c6cd6165c8aca46a9499e2cc7fa3fc8afc;hb=e4761e81ea1521f1daf146e8e5ec066b40d35888;hpb=950232b2d6e2398c5f804c58e2bedf1e98fd7151 diff --git a/lib/Devel/REPL/Plugin/DDS.pm b/lib/Devel/REPL/Plugin/DDS.pm index 512d48c..6e01fe7 100644 --- a/lib/Devel/REPL/Plugin/DDS.pm +++ b/lib/Devel/REPL/Plugin/DDS.pm @@ -1,18 +1,22 @@ package Devel::REPL::Plugin::DDS; -use Moose::Role; +use Devel::REPL::Plugin; use Data::Dump::Streamer (); -around 'print' => sub { +around 'format_result' => sub { my $orig = shift; my $self = shift; my $to_dump = (@_ > 1) ? [@_] : $_[0]; my $out; if (ref $to_dump) { - my $dds = Data::Dump::Streamer->new; - $dds->Freezer(sub { "$_[0]"; }); - $dds->Data($to_dump); - $out = $dds->Out; + if (overload::Method($to_dump, '""')) { + $out = "$to_dump"; + } else { + my $dds = Data::Dump::Streamer->new; + $dds->Freezer(sub { "$_[0]"; }); + $dds->Data($to_dump); + $out = $dds->Out; + } } else { $out = $to_dump; } @@ -20,3 +24,30 @@ around 'print' => sub { }; 1; + +__END__ + +=head1 NAME + +Devel::REPL::Plugin::DDS - Format results with Data::Dump::Streamer + +=head1 SYNOPSIS + + # in your re.pl file: + use Devel::REPL; + my $repl = Devel::REPL->new; + $repl->load_plugin('DDS'); + $repl->run; + + # after you run re.pl: + $ map $_*2, ( 1,2,3 ) + $ARRAY1 = [ + 2, + 4, + 6 + ]; + + $ + +=cut +