3 package Devel::REPL::Plugin::Nopaste;
5 our $VERSION = '1.003027';
7 use Devel::REPL::Plugin;
8 use Moose::Util::TypeConstraints 'enum';
9 use namespace::autoclean;
10 use Scalar::Util qw(blessed);
14 $self->load_plugin('Turtles');
17 has complete_session => (
24 add_to_session => 'append',
32 default => 'Devel::REPL session',
35 has 'nopaste_format' => (
37 isa => enum( [qw[ comment_code comment_output ]] ),
39 default => 'comment_output',
46 if ( $self->nopaste_format() eq 'comment_code' ) {
47 # prepend each line with #
51 $self->add_to_session($line . "\n");
59 my @ret = $orig->($self, $line, @_);
60 my @ret_as_str = map {
63 } elsif (blessed($_) && $_->can('stringify')) {
70 if ( $self->nopaste_format() eq 'comment_output' ) {
71 # prepend each line with #
72 map { $_ =~ s/^/# /mg } @ret_as_str;
75 $self->add_to_session(join("\n", @ret_as_str) . "\n\n");
84 return App::Nopaste->nopaste(
85 text => $self->complete_session,
86 desc => $self->paste_title(),
91 sub command_pastetitle {
92 my ( $self, undef, $title ) = @_;
94 $self->paste_title( $title );
103 Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output
107 This module provides these commands to your Devel::REPL shell:
111 The C<#nopaste> sends a transcript of your session to a nopaste
116 The C<#pastetitle> command allows you to set the title of the paste on
117 the nopaste site. For example:
119 C<#pastetitle example of some code>
121 defaults to C<'Devel::REPL session'>.
125 =head2 nopaste_format
127 The format sent to the nopaste server can be adjusted with the
128 C<nopaste_format> option. By default, the output of each perl
129 statement is commented out, and the perl statements themselves are
130 not. This can be reversed by setting the C<nopaste_format> attribute
131 to C<comment_code> like this in your re.pl file:
133 C<< $_REPL->nopaste_format( 'comment_code' ); >>
135 The default of commenting out the output would be set like this:
137 C<< $_REPL->nopaste_format( 'comment_output' ); >>
139 These options can be set during a L<Devel::REPL> session, but only affect
140 the future parts of the session, not the past parts.
144 Shawn M Moore, C<< <sartak at gmail dot com> >>
150 =item Andrew Moore - C<< <amoore@cpan.org> >>