keep all namespaces clean
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / DDC.pm
1 use strict;
2 use warnings;
3 package Devel::REPL::Plugin::DDC;
4
5 use Devel::REPL::Plugin;
6 use Data::Dumper::Concise ();
7 use namespace::autoclean;
8
9 around 'format_result' => sub {
10   my $orig = shift;
11   my $self = shift;
12   my $to_dump = (@_ > 1) ? [@_] : $_[0];
13   my $out;
14   if (ref $to_dump) {
15     if (overload::Method($to_dump, '""')) {
16       $out = "$to_dump";
17     } else {
18       $out = Data::Dumper::Concise::Dumper($to_dump);
19     }
20   } else {
21     $out = $to_dump;
22   }
23   $self->$orig($out);
24 };
25
26 1;
27
28 __END__
29
30 =head1 NAME
31
32 Devel::REPL::Plugin::DDC - Format results with Data::Dumper::Concise
33
34 =head1 SYNOPSIS
35
36  # in your re.pl file:
37  use Devel::REPL;
38  my $repl = Devel::REPL->new;
39  $repl->load_plugin('DDS');
40  $repl->run;
41
42  # after you run re.pl:
43  $ map $_*2, ( 1,2,3 )
44 [
45   2,
46   4,
47   6
48 ];
49
50  $
51
52 =cut
53