3 package Devel::REPL::Plugin::Nopaste;
5 use Devel::REPL::Plugin;
6 use Moose::Util::TypeConstraints;
7 use namespace::autoclean;
8 use Scalar::Util qw(blessed);
12 $self->load_plugin('Turtles');
15 has complete_session => (
22 add_to_session => 'append',
30 default => 'Devel::REPL session',
33 has 'nopaste_format' => (
35 isa => enum( [qw[ comment_code comment_output ]] ),
37 default => 'comment_output',
44 if ( $self->nopaste_format() eq 'comment_code' ) {
45 # prepend each line with #
49 $self->add_to_session($line . "\n");
57 my @ret = $orig->($self, $line, @_);
58 my @ret_as_str = map {
61 } elsif (blessed($_) && $_->can('stringify')) {
68 if ( $self->nopaste_format() eq 'comment_output' ) {
69 # prepend each line with #
70 map { $_ =~ s/^/# /mg } @ret_as_str;
73 $self->add_to_session(join("\n", @ret_as_str) . "\n\n");
82 return App::Nopaste->nopaste(
83 text => $self->complete_session,
84 desc => $self->paste_title(),
89 sub command_pastetitle {
90 my ( $self, undef, $title ) = @_;
92 $self->paste_title( $title );
101 Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output
105 This module provides these commands to your Devel::REPL shell:
109 The C<#nopaste> sends a transcript of your session to a nopaste
114 The C<#pastetitle> command allows you to set the title of the paste on
115 the nopaste site. For example:
117 C<#pastetitle example of some code>
119 defaults to C<'Devel::REPL session'>.
123 =head2 nopaste_format
125 The format sent to the nopaste server can be adjusted with the
126 C<nopaste_format> option. By default, the output of each perl
127 statement is commented out, and the perl statements themselves are
128 not. This can be reversed by setting the C<nopaste_format> attribute
129 to C<comment_code> like this in your re.pl file:
131 C<< $_REPL->nopaste_format( 'comment_code' ); >>
133 The default of commenting out the output would be set like this:
135 C<< $_REPL->nopaste_format( 'comment_output' ); >>
137 These options can be set during a L<Devel::REPL> session, but only affect
138 the future parts of the session, not the past parts.
142 Shawn M Moore, C<< <sartak at gmail dot com> >>
148 =item Andrew Moore - C<< <amoore@cpan.org> >>