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