This file is indexed.

/usr/share/perl5/Devel/REPL/Plugin/Nopaste.pm is in libdevel-repl-perl 1.003012-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package Devel::REPL::Plugin::Nopaste;

use Devel::REPL::Plugin;
use MooseX::AttributeHelpers;
use Moose::Util::TypeConstraints;
use namespace::clean -except => [ 'meta' ];
use Scalar::Util qw(blessed);

sub BEFORE_PLUGIN {
    my $self = shift;
    $self->load_plugin('Turtles');
}

has complete_session => (
    metaclass => 'String',
    is        => 'rw',
    isa       => 'Str',
    lazy      => 1,
    default   => '',
    provides  => {
        append => 'add_to_session',
    },
);

has paste_title => (
    is        => 'rw',
    isa       => 'Str',
    lazy      => 1,
    default   => 'Devel::REPL session',
);

has 'nopaste_format' => (
    is      => 'rw',
    isa     => enum( [qw[ comment_code comment_output ]] ),
    lazy    => 1,
    default => 'comment_output',
);

before eval => sub {
    my $self = shift;
    my $line = shift;

    if ( $self->nopaste_format() eq 'comment_code' ) {
        # prepend each line with #
        $line =~ s/^/# /mg;
    }

    $self->add_to_session($line . "\n");
};

around eval => sub {
    my $orig = shift;
    my $self = shift;
    my $line = shift;

    my @ret = $orig->($self, $line, @_);
    my @ret_as_str = map {
        if (!defined($_)) {
            '';
        } elsif (blessed($_) && $_->can('stringify')) {
            $_->stringify();
        } else {
            $_;
        }
    } @ret;

    if ( $self->nopaste_format() eq 'comment_output' ) {
        # prepend each line with #
        map { $_ =~ s/^/# /mg } @ret_as_str;
    }

    $self->add_to_session(join("\n", @ret_as_str) . "\n\n");

    return @ret;
};

sub command_nopaste {
    my $self = shift;

    require App::Nopaste;
    return App::Nopaste->nopaste(
        text => $self->complete_session,
        desc => $self->paste_title(),
        lang => "perl",
    );
}

sub command_pastetitle {
    my ( $self, undef, $title ) = @_;

    $self->paste_title( $title );
}

1;

__END__

=head1 NAME

Devel::REPL::Plugin::Nopaste - #nopaste to upload session's input and output

=head1 COMMANDS

This module provides these commands to your Devel::REPL shell:

=head2 #nopaste

The C<#nopaste> sends a transcript of your session to a nopaste
site.

=head2 #pastetitle

The C<#pastetitle> command allows you to set the title of the paste on
the nopaste site. For example:

C<#pastetitle example of some code>

defaults to 'Devel::REPL session'

=head1 CONFIGURATION

=head2 nopaste_format

The format sent to the nopaste server can be adjusted with the
C<nopaste_format> option. By default, the output of each perl
statement is commented out, and the perl statements themselves are
not. This can be reversed by setting the C<nopaste_format> attribute
to C<comment_code> like this in your re.pl file:

C<< $_REPL->nopaste_format( 'comment_code' ); >>

The default of commenting out the output would be set like this:

C<< $_REPL->nopaste_format( 'comment_output' ); >>

These options can be set during a Devel::REPL session, but only affect
the future parts of the session, not the past parts.

=head1 AUTHOR

Shawn M Moore, C<< <sartak at gmail dot com> >>

=head1 CONTRIBUTORS

=over 4

=item Andrew Moore - C<< <amoore@cpan.org> >>

=back

=cut