1 package Devel::REPL::Plugin::Nopaste;
3 use Devel::REPL::Plugin;
5 use Scalar::Util qw(blessed);
6 use MooX::Types::MooseLike::Base qw(Str);
10 $self->load_plugin('Turtles');
13 has complete_session => (
17 default => sub { '' },
22 my $session = $self->complete_session;
23 $session .= $_ for @_;
24 $self->complete_session($session);
31 default => sub { 'Devel::REPL session' },
34 has 'nopaste_format' => (
36 isa => sub { $_[0] =~ qr[^(?:comment_code|comment_output)$] },
38 default => sub { 'comment_output' },
45 if ( $self->nopaste_format() eq 'comment_code' ) {
46 # prepend each line with #
50 $self->add_to_session($line . "\n");
58 my @ret = $orig->($self, $line, @_);
59 my @ret_as_str = map {
62 } elsif (blessed($_) && $_->can('stringify')) {
69 if ( $self->nopaste_format() eq 'comment_output' ) {
70 # prepend each line with #
71 map { $_ =~ s/^/# /mg } @ret_as_str;
74 $self->add_to_session(join("\n", @ret_as_str) . "\n\n");
83 return App::Nopaste->nopaste(
84 text => $self->complete_session,
85 desc => $self->paste_title(),
90 sub command_pastetitle {
91 my ( $self, undef, $title ) = @_;
93 $self->paste_title( $title );
102 Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output
106 This module provides these commands to your Devel::REPL shell:
110 The C<#nopaste> sends a transcript of your session to a nopaste
115 The C<#pastetitle> command allows you to set the title of the paste on
116 the nopaste site. For example:
118 C<#pastetitle example of some code>
120 defaults to 'Devel::REPL session'
124 =head2 nopaste_format
126 The format sent to the nopaste server can be adjusted with the
127 C<nopaste_format> option. By default, the output of each perl
128 statement is commented out, and the perl statements themselves are
129 not. This can be reversed by setting the C<nopaste_format> attribute
130 to C<comment_code> like this in your re.pl file:
132 C<< $_REPL->nopaste_format( 'comment_code' ); >>
134 The default of commenting out the output would be set like this:
136 C<< $_REPL->nopaste_format( 'comment_output' ); >>
138 These options can be set during a Devel::REPL session, but only affect
139 the future parts of the session, not the past parts.
143 Shawn M Moore, C<< <sartak at gmail dot com> >>
149 =item Andrew Moore - C<< <amoore@cpan.org> >>