use namespaace::clean in turtles completion driver
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Nopaste.pm
CommitLineData
24cc824f 1package Devel::REPL::Plugin::Nopaste;
2
3use Moose::Role;
4use MooseX::AttributeHelpers;
5use namespace::clean -except => [ 'meta' ];
6
7with 'Devel::REPL::Plugin::Turtles';
8
9has complete_session => (
10 metaclass => 'String',
11 is => 'rw',
12 isa => 'Str',
13 default => '',
14 provides => {
15 append => 'add_to_session',
16 },
17);
18
a4c582b6 19before eval => sub {
24cc824f 20 my $self = shift;
21 my $line = shift;
22
24cc824f 23 # prepend each line with #
24 $line =~ s/^/# /mg;
25
a4c582b6 26 $self->add_to_session($line . "\n");
27};
28
29around eval => sub {
30 my $orig = shift;
31 my $self = shift;
32 my $line = shift;
33
34 my @ret = $orig->($self, $line, @_);
24cc824f 35
a4c582b6 36 $self->add_to_session(join("\n", @ret) . "\n\n");
24cc824f 37
38 return @ret;
39};
40
41sub command_nopaste {
42 my $self = shift;
43
44 require App::Nopaste;
45 return App::Nopaste->nopaste(
46 text => $self->complete_session,
47 desc => "Devel::REPL session",
48 lang => "perl",
49 );
50}
51
521;
53
cfd1094b 54__END__
55
56=head1 NAME
57
58Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output
59
30b459d4 60=head1 AUTHOR
61
62Shawn M Moore, C<< <sartak at gmail dot com> >>
63
cfd1094b 64=cut
65