MilkyHolmes/Role/HasPersonalColor.pm

filter: Statementstmt 48.0% 12 / 25 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 3 / 8 Podpod 0.0% 0 / 3 totaltotal 34.8% 15 / 43 CC 3 SCAR 15.5
CC
3
Cov
40%
say
12.0
color_enable
2.0
_escaped_color_begin
2.0
CRAP 4.7
↑ Summary MilkyHolmes/Group/MilkyHolmes.pm »
1 package Acme::MilkyHolmes::Role::HasPersonalColor;
2 3 ▶use Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 requires 'color';
6 3 requires 'color_enable';
7  
8 3 my $ansi_colors = {
9 pink => '1;35', # Light Purple
10 yellow => '1;33',
11 green => '0;32',
12 blue => '0;34',
13 black => '0;30;47', #background is white
14 white => '1;37;40', #background is black
15 cyan => '0;36',
16 red => '0;31',
17 purple => '0;35',
18 brown => '0;33',
19 lightgray => '0;37',
20 darkgray => '1;30',
21 lightblue => '1;34',
22 lightgreen => '1;32',
23 lightcyan => '1;36',
24 lightred => '1;31',
25 lightpurple => '1;35',
26 };
27  
28 0 ▶sub color_enable {
Subroutine color_enable: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my ($self) = shift;
30 0 return 1;
31 }
32  
33 12 ▶sub color {
Subroutine color: called CC=1 SCAR=0.0
Pod undocumented
34 12 my ($self) = @_;
35 12 return $self->common->[0]->{color};
36 }
37  
38  
39 0 ▶sub say {
Subroutine say: not called CC=3 SCAR=24.8
Pod undocumented
40 0 my ($self, $comment) = @_;
41  
42 0 my $message = encode_utf8($self->nickname . ': ' . $comment);
43  
44 0 ▶ if ( defined $self->color && $self->color_enable ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->color and $self->color_enable) 0 0 0
Condition0%0/3
defined $self->color and $self->color_enable
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->color and $self->color_enable
defined $self->color $self->color_enable
Truth table0%0/3
A and B
A= defined $self->colorB= $self->color_enable
ABresult
0X0
100
111
45 0 $message = $self->_escaped_message($self->color, $message);
46  
47 }
48 0 print "$message\n";
49 }
50  
51 0 ▶sub _escaped_color_begin {
Subroutine _escaped_color_begin: not called CC=1 SCAR=6.9
52 0 my ($self, $color_name) = @_;
53 0 return "\e[" . $ansi_colors->{$color_name} . "m"
54 }
55  
56 0 ▶sub _escape_end {
Subroutine _escape_end: not called CC=1 SCAR=6.9
57 0 my ($self) = @_;
58 0 return "\e[m";
59 }
60  
61 0 ▶sub _escaped_message {
Subroutine _escaped_message: not called CC=1 SCAR=6.9
62 0 my ($self, $color_name, $message) = @_;
63 0 return $self->_escaped_color_begin($color_name) . $message . $self->_escape_end();
64 }
65  
66  
67 3 1;
68  
↑ Summary MilkyHolmes/Group/MilkyHolmes.pm »