File Coverage

blib/lib/ColorThemeBase/Static/FromStructColors.pm
Criterion Covered Total %
statement 22 23 95.6
branch 7 8 87.5
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 33 37 89.1


line stmt bran cond sub pod time code
1             package ColorThemeBase::Static::FromStructColors;
2              
3 4     4   311218 use strict 'subs', 'vars';
  4         10  
  4         235  
4             #use warnings;
5              
6 4     4   22 use parent 'ColorThemeBase::Base';
  4         8  
  4         42  
7              
8             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
9             our $DATE = '2024-07-17'; # DATE
10             our $DIST = 'ColorThemeBase-Static'; # DIST
11             our $VERSION = '0.009'; # VERSION
12              
13             sub list_items {
14 2     2 0 13 my $self = shift;
15              
16 2         5 my $theme_hash = \%{"$self->{orig_class}::THEME"};
  2         14  
17 2         5 my @list = sort keys %{ $theme_hash->{items} };
  2         17  
18 2 100       23 wantarray ? @list : \@list;
19             }
20              
21             sub get_item_color {
22 6     6 0 29 my ($self, $name, $args) = @_;
23              
24 6         26 my $theme_hash = \%{"$self->{orig_class}::THEME"};
  6         62  
25              
26 6         18 my $c = $theme_hash->{items}{$name};
27 6 100       27 return unless defined $c;
28              
29 5 100       20 if (ref $c eq 'CODE') {
30 1         5 my $c2 = $c->($self, $name, $args);
31 1 50       138 if (ref $c2 eq 'CODE') {
32 0         0 die "Color '$name' of theme $self->{orig_class} returns coderef, ".
33             "which after called still returns a coderef";
34             }
35 1         10 return $c2;
36             }
37 4         58 $c;
38             }
39              
40             1;
41             # ABSTRACT: Base class for color theme modules with static list of items (from %THEME)
42              
43             __END__