Commit | Line | Data |
24cc824f |
1 | package Devel::REPL::Plugin::Nopaste; |
2 | |
3 | use Moose::Role; |
4 | use MooseX::AttributeHelpers; |
5 | use namespace::clean -except => [ 'meta' ]; |
6 | |
7 | with 'Devel::REPL::Plugin::Turtles'; |
8 | |
9 | has complete_session => ( |
10 | metaclass => 'String', |
11 | is => 'rw', |
12 | isa => 'Str', |
13 | default => '', |
14 | provides => { |
15 | append => 'add_to_session', |
16 | }, |
17 | ); |
18 | |
a4c582b6 |
19 | before 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 | |
29 | around 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 | |
41 | sub 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 | |
52 | 1; |
53 | |
cfd1094b |
54 | __END__ |
55 | |
56 | =head1 NAME |
57 | |
58 | Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output |
59 | |
60 | =cut |
61 | |