ColorTheme/Test/Dynamic.pm

filter: Statementstmt 65.2% 15 / 23 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 52.9% 18 / 34 CC 3 SCAR 17.7
CC
3
Cov
56%
list_items
12.0
get_item_color
2.0
BEGIN
1.0
CRAP 5.9
« ColorThemeBase/Constructor.pm ↑ Summary ColorThemeBase/Static/FromStructColors.pm »
1 package ColorTheme::Test::Dynamic;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent 'ColorThemeBase::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8 2 our $DATE = '2024-07-17'; # DATE
9 2 our $DIST = 'ColorThemeBase-Static'; # DIST
10 2 our $VERSION = '0.009'; # VERSION
11  
12 2 our %THEME = (
13 v => 2,
14 summary => 'A dynamic color theme',
15 dynamic => 1,
16 args => {
17 tone => {schema=>['str*', in=>['red','green']], req=>1},
18 opt1 => {schema=>'str*', default=>'foo'},
19 opt2 => {schema=>'str*'},
20 },
21 examples => [
22 {
23 summary => 'An red tone',
24 args => { tone => 'red' },
25 },
26 ],
27 );
28  
29 0 ▶sub list_items {
Subroutine list_items: not called CC=3 SCAR=24.8
Pod undocumented
30 0 my $self = shift;
31  
32 0 my @list;
33 0 ▶ if ($self->{tone} eq 'red') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'tone'} eq 'red') { } 0 0 0
34 0 @list = ('red1', 'red2', 'red3');
35 } else {
36 0 @list = ('green1', 'green2', 'green3');
37 }
38 0 ▶ wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
39 }
40  
41 0 ▶sub get_item_color {
Subroutine get_item_color: not called CC=1 SCAR=6.9
Pod undocumented
42 0 my ($self, $name, $args) = @_;
43  
44 +{
45 red1 => 'ff0000',
46 red2 => 'cc0000',
47 red3 => '992211',
48 green1 => '00ff00',
49 green2 => '00cc00',
50 green3 => '15a008',
51 0 }->{$name};
52 }
53  
54 2 1;
55 # ABSTRACT: A dynamic color theme
56  
57 __END__
« ColorThemeBase/Constructor.pm ↑ Summary ColorThemeBase/Static/FromStructColors.pm »