| 1 | package Reply::Plugin::Colors; | ||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:DOY'; | |||||||||||
| 3 | 1 | $Reply::Plugin::Colors::VERSION = '0.42'; | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | # ABSTRACT: colorize output | ||||||||||||
| 7 | |||||||||||||
| 8 | 1 | ▶ | use base 'Reply::Plugin'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 1 | ▶ | use Term::ANSIColor; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 1 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=10.5
| |||||||||||||
| 12 | 1 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 13 | 0 | require Win32::Console::ANSI; | |||||||||||
| 14 | 0 | Win32::Console::ANSI->import; | |||||||||||
| 15 | } | ||||||||||||
| 16 | } | ||||||||||||
| 17 | |||||||||||||
| 18 | |||||||||||||
| 19 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 20 | 0 | my $class = shift; | |||||||||||
| 21 | 0 | my %opts = @_; | |||||||||||
| 22 | |||||||||||||
| 23 | 0 | my $self = $class->SUPER::new(@_); | |||||||||||
| 24 | 0 | ▶ | $self->{error} = $opts{error} || 'red'; | ||||||||||
|
Condition0%0/2
$opts{'error'} || 'red'
MC/DC0%0/1
$opts{'error'} || 'red'
$opts{'error'}
Truth table0%0/2
A
A= $opts{'error'}
| |||||||||||||
| 25 | 0 | ▶ | $self->{warning} = $opts{warning} || 'yellow'; | ||||||||||
|
Condition0%0/2
$opts{'warning'} || 'yellow'
MC/DC0%0/1
$opts{'warning'} || 'yellow'
$opts{'warning'}
Truth table0%0/2
A
A= $opts{'warning'}
| |||||||||||||
| 26 | 0 | ▶ | $self->{result} = $opts{result} || 'green'; | ||||||||||
|
Condition0%0/2
$opts{'result'} || 'green'
MC/DC0%0/1
$opts{'result'} || 'green'
$opts{'result'}
Truth table0%0/2
A
A= $opts{'result'}
| |||||||||||||
| 27 | |||||||||||||
| 28 | 0 | return $self; | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 0 | ▶ | sub compile { | ||||||||||
|
Subroutine
compile: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||
| 33 | 0 | my ($next, @args) = @_; | |||||||||||
| 34 | |||||||||||||
| 35 | 0 | ▶ | local $SIG{__WARN__} = sub { $self->print_warn(@_) }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 36 | 0 | $next->(@args); | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 0 | ▶ | sub execute { | ||||||||||
|
Subroutine
execute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||
| 41 | 0 | my ($next, @args) = @_; | |||||||||||
| 42 | |||||||||||||
| 43 | 0 | ▶ | local $SIG{__WARN__} = sub { $self->print_warn(@_) }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 44 | 0 | $next->(@args); | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 0 | ▶ | sub print_error { | ||||||||||
|
Subroutine
print_error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 48 | 0 | my $self = shift; | |||||||||||
| 49 | 0 | my ($next, $error) = @_; | |||||||||||
| 50 | |||||||||||||
| 51 | 0 | print color($self->{error}); | |||||||||||
| 52 | 0 | $next->($error); | |||||||||||
| 53 | 0 | local $| = 1; | |||||||||||
| 54 | 0 | print color('reset'); | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | 0 | ▶ | sub print_result { | ||||||||||
|
Subroutine
print_result: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 58 | 0 | my $self = shift; | |||||||||||
| 59 | 0 | my ($next, @result) = @_; | |||||||||||
| 60 | |||||||||||||
| 61 | 0 | print color($self->{result}); | |||||||||||
| 62 | 0 | $next->(@result); | |||||||||||
| 63 | 0 | local $| = 1; | |||||||||||
| 64 | 0 | print color('reset'); | |||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | 0 | ▶ | sub print_warn { | ||||||||||
|
Subroutine
print_warn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 68 | 0 | my $self = shift; | |||||||||||
| 69 | 0 | my ($warning) = @_; | |||||||||||
| 70 | |||||||||||||
| 71 | 0 | print color($self->{warning}); | |||||||||||
| 72 | 0 | print $warning; | |||||||||||
| 73 | 0 | local $| = 1; | |||||||||||
| 74 | 0 | print color('reset'); | |||||||||||
| 75 | } | ||||||||||||
| 76 | |||||||||||||
| 77 | |||||||||||||
| 78 | 1 | 1; | |||||||||||
| 79 | |||||||||||||
| 80 | __END__ | ||||||||||||