1 package Devel::REPL::Plugin::Nopaste;
3 use Devel::REPL::Plugin;
4 use MooseX::AttributeHelpers;
5 use Moose::Util::TypeConstraints;
6 use namespace::clean -except => [ 'meta' ];
7 use Scalar::Util qw(blessed);
11 $self->load_plugin('Turtles');
14 has complete_session => (
15 metaclass => 'String',
21 append => 'add_to_session',
29 default => 'Devel::REPL session',
32 has 'nopaste_format' => (
34 isa => enum( [qw[ comment_code comment_output ]] ),
36 default => 'comment_output',
43 if ( $self->nopaste_format() eq 'comment_code' ) {
44 # prepend each line with #
48 $self->add_to_session($line . "\n");
56 my @ret = $orig->($self, $line, @_);
57 my @ret_as_str = map {
60 } elsif (blessed($_) && $_->can('stringify')) {
67 if ( $self->nopaste_format() eq 'comment_output' ) {
68 # prepend each line with #
69 map { $_ =~ s/^/# /mg } @ret_as_str;
72 $self->add_to_session(join("\n", @ret_as_str) . "\n\n");
81 return App::Nopaste->nopaste(
82 text => $self->complete_session,
83 desc => $self->paste_title(),
88 sub command_pastetitle {
89 my ( $self, undef, $title ) = @_;
91 $self->paste_title( $title );
100 Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output
104 This module provides these commands to your Devel::REPL shell:
108 The C<#nopaste> sends a transcript of your session to a nopaste
113 The C<#pastetitle> command allows you to set the title of the paste on
114 the nopaste site. For example:
116 C<#pastetitle example of some code>
118 defaults to 'Devel::REPL session'
122 =head2 nopaste_format
124 The format sent to the nopaste server can be adjusted with the
125 C<nopaste_format> option. By default, the output of each perl
126 statement is commented out, and the perl statements themselves are
127 not. This can be reversed by setting the C<nopaste_format> attribute
128 to C<comment_code> like this in your re.pl file:
130 C<< $_REPL->nopaste_format( 'comment_code' ); >>
132 The default of commenting out the output would be set like this:
134 C<< $_REPL->nopaste_format( 'comment_output' ); >>
136 These options can be set during a Devel::REPL session, but only affect
137 the future parts of the session, not the past parts.
141 Shawn M Moore, C<< <sartak at gmail dot com> >>
147 =item Andrew Moore - C<< <amoore@cpan.org> >>