| 1 | package Devel::REPL::Plugin::Clipboard; | ||||||||||||
| 2 | |||||||||||||
| 3 | # ABSTRACT: #clip output to clipboard | ||||||||||||
| 4 | |||||||||||||
| 5 | 1 | ▶ | use Devel::REPL::Plugin; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use Clipboard; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use Term::ANSIColor 2.01 qw(colorstrip); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | |||||||||||||
| 11 | 0 | ▶ | sub BEFORE_PLUGIN { | ||||||||||
|
Subroutine
BEFORE_PLUGIN: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 12 | 0 | my $self = shift; | |||||||||||
| 13 | 0 | $self->load_plugin('Turtles'); | |||||||||||
| 14 | 0 | return; | |||||||||||
| 15 | } | ||||||||||||
| 16 | |||||||||||||
| 17 | 1 | has last_output => ( | |||||||||||
| 18 | is => 'rw', | ||||||||||||
| 19 | isa => 'Str', | ||||||||||||
| 20 | lazy => 1, | ||||||||||||
| 21 | default => '', | ||||||||||||
| 22 | ); | ||||||||||||
| 23 | |||||||||||||
| 24 | 0 | ▶ | around 'format_result' => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||
| 25 | 0 | my $orig = shift; | |||||||||||
| 26 | 0 | my $self = shift; | |||||||||||
| 27 | |||||||||||||
| 28 | 0 | my @ret; | |||||||||||
| 29 | 0 | ▶ | if (wantarray) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | 0 | @ret = $self->$orig(@_); | |||||||||||
| 31 | } | ||||||||||||
| 32 | else { | ||||||||||||
| 33 | 0 | $ret[0] = $self->$orig(@_); | |||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | # Remove any color control characters that plugins like | ||||||||||||
| 37 | # Data::Printer may have added | ||||||||||||
| 38 | 0 | ▶ | my $output = colorstrip( join( "\n", map { $_ // '' } @ret ) ); | ||||||||||
|
Condition0%0/2
$_ // ""
MC/DC0%0/1
$_ // ""
$_
Truth table0%0/2
A
A= $_
| |||||||||||||
| 39 | |||||||||||||
| 40 | 0 | $self->last_output($output); | |||||||||||
| 41 | |||||||||||||
| 42 | 0 | ▶ | return wantarray ? @ret : $ret[0]; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 1 | }; | |||||||||||
| 44 | |||||||||||||
| 45 | 0 | ▶ | sub command_clip { | ||||||||||
|
Subroutine
command_clip: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 46 | 0 | my ($self) = @_; | |||||||||||
| 47 | 0 | Clipboard->copy( $self->last_output ); | |||||||||||
| 48 | 0 | return 'Output copied to clipboard'; | |||||||||||
| 49 | } | ||||||||||||
| 50 | |||||||||||||
| 51 | 1 | 1; | |||||||||||
| 52 | |||||||||||||
| 53 | __END__ | ||||||||||||