keep $VERSION right in the repo
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / PPI.pm
1 use strict;
2 use warnings;
3 package Devel::REPL::Plugin::PPI;
4
5 our $VERSION = '1.003027';
6
7 use Devel::REPL::Plugin;
8 use PPI;
9 use PPI::Dumper;
10 use namespace::autoclean;
11
12 sub BEFORE_PLUGIN {
13     my $self = shift;
14     $self->load_plugin('Turtles');
15 }
16
17 sub expr_command_ppi {
18   my ( $self, $eval, $code ) = @_;
19
20   my $document = PPI::Document->new(\$code);
21   my $dumper   = PPI::Dumper->new($document);
22   return $dumper->string;
23 }
24
25 __PACKAGE__
26
27 __END__
28
29 =pod
30
31 =head1 NAME
32
33 Devel::REPL::Plugin::PPI - PPI dumping of Perl code
34
35 =head1 SYNOPSIS
36
37   repl> #ppi Devel::REPL
38   PPI::Document
39     PPI::Statement
40       PPI::Token::Word    'Devel::REPL'
41
42   repl> #ppi {
43   > warn $];
44   > }
45   PPI::Document
46     PPI::Statement::Compound
47       PPI::Structure::Block       { ... }
48         PPI::Token::Whitespace    '\n'
49         PPI::Statement
50           PPI::Token::Word        'warn'
51           PPI::Token::Whitespace          ' '
52           PPI::Token::Magic       '$]'
53           PPI::Token::Structure   ';'
54         PPI::Token::Whitespace    '\n'
55
56 =head1 DESCRIPTION
57
58 This plugin provides a C<ppi> command that uses L<PPI::Dumper> to dump
59 L<PPI>-parsed Perl documents.
60
61 The code is not actually executed, which means that when used with
62 L<Deve::REPL::Plugin::OutputCache> there is no new value in C<_>.
63
64 =head1 AUTHOR
65
66 Shawn M Moore E<lt>sartak@gmail.comE<gt>
67
68 =cut
69
70