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