3 package Devel::REPL::Plugin::Nopaste;
4 # ABSTRACT: #nopaste to upload session's input and output
6 our $VERSION = '1.003027';
8 use Devel::REPL::Plugin;
9 use Moose::Util::TypeConstraints 'enum';
10 use namespace::autoclean;
11 use Scalar::Util qw(blessed);
15 $self->load_plugin('Turtles');
18 has complete_session => (
25 add_to_session => 'append',
33 default => 'Devel::REPL session',
36 has 'nopaste_format' => (
38 isa => enum( [qw[ comment_code comment_output ]] ),
40 default => 'comment_output',
47 if ( $self->nopaste_format() eq 'comment_code' ) {
48 # prepend each line with #
52 $self->add_to_session($line . "\n");
60 my @ret = $orig->($self, $line, @_);
61 my @ret_as_str = map {
64 } elsif (blessed($_) && $_->can('stringify')) {
71 if ( $self->nopaste_format() eq 'comment_output' ) {
72 # prepend each line with #
73 map { $_ =~ s/^/# /mg } @ret_as_str;
76 $self->add_to_session(join("\n", @ret_as_str) . "\n\n");
85 return App::Nopaste->nopaste(
86 text => $self->complete_session,
87 desc => $self->paste_title(),
92 sub command_pastetitle {
93 my ( $self, undef, $title ) = @_;
95 $self->paste_title( $title );
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 C<'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 L<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> >>