make ReadLineHistory history file location portable
[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',
8995c74b 16 lazy => 1,
24cc824f 17 default => '',
18 provides => {
19 append => 'add_to_session',
20 },
21);
22
a4c582b6 23before eval => sub {
24cc824f 24 my $self = shift;
25 my $line = shift;
26
24cc824f 27 # prepend each line with #
28 $line =~ s/^/# /mg;
29
a4c582b6 30 $self->add_to_session($line . "\n");
31};
32
33around eval => sub {
34 my $orig = shift;
35 my $self = shift;
36 my $line = shift;
37
38 my @ret = $orig->($self, $line, @_);
24cc824f 39
a4c582b6 40 $self->add_to_session(join("\n", @ret) . "\n\n");
24cc824f 41
42 return @ret;
43};
44
45sub command_nopaste {
46 my $self = shift;
47
48 require App::Nopaste;
49 return App::Nopaste->nopaste(
50 text => $self->complete_session,
51 desc => "Devel::REPL session",
52 lang => "perl",
53 );
54}
55
561;
57
cfd1094b 58__END__
59
60=head1 NAME
61
62Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output
63
30b459d4 64=head1 AUTHOR
65
66Shawn M Moore, C<< <sartak at gmail dot com> >>
67
cfd1094b 68=cut
69