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