Commit | Line | Data |
24cc824f |
1 | package Devel::REPL::Plugin::Nopaste; |
2 | |
6a5409bc |
3 | use Devel::REPL::Plugin; |
24cc824f |
4 | use MooseX::AttributeHelpers; |
5 | use namespace::clean -except => [ 'meta' ]; |
6 | |
3a400715 |
7 | sub BEFORE_PLUGIN { |
8 | my $self = shift; |
9 | $self->load_plugin('Turtles'); |
10 | } |
24cc824f |
11 | |
12 | has complete_session => ( |
13 | metaclass => 'String', |
14 | is => 'rw', |
15 | isa => 'Str', |
16 | default => '', |
17 | provides => { |
18 | append => 'add_to_session', |
19 | }, |
20 | ); |
21 | |
a4c582b6 |
22 | before 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 | |
32 | around 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 | |
44 | sub 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 | |
55 | 1; |
56 | |
cfd1094b |
57 | __END__ |
58 | |
59 | =head1 NAME |
60 | |
61 | Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output |
62 | |
30b459d4 |
63 | =head1 AUTHOR |
64 | |
65 | Shawn M Moore, C<< <sartak at gmail dot com> >> |
66 | |
cfd1094b |
67 | =cut |
68 | |