1 package Devel::REPL::Plugin::Nopaste;
3 use Devel::REPL::Plugin;
4 use Moose::Util::TypeConstraints;
5 use namespace::autoclean;
6 use Scalar::Util qw(blessed);
10 $self->load_plugin('Turtles');
13 has complete_session => (
20 add_to_session => 'append',
28 default => 'Devel::REPL session',
31 has 'nopaste_format' => (
33 isa => enum( [qw[ comment_code comment_output ]] ),
35 default => 'comment_output',
42 if ( $self->nopaste_format() eq 'comment_code' ) {
43 # prepend each line with #
47 $self->add_to_session($line . "\n");
55 my @ret = $orig->($self, $line, @_);
56 my @ret_as_str = map {
59 } elsif (blessed($_) && $_->can('stringify')) {
66 if ( $self->nopaste_format() eq 'comment_output' ) {
67 # prepend each line with #
68 map { $_ =~ s/^/# /mg } @ret_as_str;
71 $self->add_to_session(join("\n", @ret_as_str) . "\n\n");
80 return App::Nopaste->nopaste(
81 text => $self->complete_session,
82 desc => $self->paste_title(),
87 sub command_pastetitle {
88 my ( $self, undef, $title ) = @_;
90 $self->paste_title( $title );
99 Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output
103 This module provides these commands to your Devel::REPL shell:
107 The C<#nopaste> sends a transcript of your session to a nopaste
112 The C<#pastetitle> command allows you to set the title of the paste on
113 the nopaste site. For example:
115 C<#pastetitle example of some code>
117 defaults to 'Devel::REPL session'
121 =head2 nopaste_format
123 The format sent to the nopaste server can be adjusted with the
124 C<nopaste_format> option. By default, the output of each perl
125 statement is commented out, and the perl statements themselves are
126 not. This can be reversed by setting the C<nopaste_format> attribute
127 to C<comment_code> like this in your re.pl file:
129 C<< $_REPL->nopaste_format( 'comment_code' ); >>
131 The default of commenting out the output would be set like this:
133 C<< $_REPL->nopaste_format( 'comment_output' ); >>
135 These options can be set during a Devel::REPL session, but only affect
136 the future parts of the session, not the past parts.
140 Shawn M Moore, C<< <sartak at gmail dot com> >>
146 =item Andrew Moore - C<< <amoore@cpan.org> >>