File Coverage

blib/lib/SHARYANTO/ColorTheme/Util.pm
Criterion Covered Total %
statement 26 28 92.8
branch 6 12 50.0
condition 1 6 16.6
subroutine 5 5 100.0
pod 1 1 100.0
total 39 52 75.0


line stmt bran cond sub pod time code
1             package SHARYANTO::ColorTheme::Util;
2              
3 1     1   563 use 5.010;
  1         2  
  1         31  
4 1     1   3 use strict;
  1         1  
  1         21  
5 1     1   3 use warnings;
  1         1  
  1         274  
6              
7             require Exporter;
8             our @ISA = qw(Exporter);
9             our @EXPORT_OK = qw(create_color_theme_transform);
10              
11             our $VERSION = '0.76'; # VERSION
12              
13             sub create_color_theme_transform {
14 1     1 1 19 my ($basect, $func) = @_;
15              
16 1         1 my $derivedct = {};
17              
18 1         2 for my $cn (keys %{ $basect->{colors} }) {
  1         7  
19 2         4 my $cv = $basect->{colors}{$cn};
20              
21 2 50       5 if ($cv) {
22             $derivedct->{colors}{$cn} = sub {
23 2     2   7 my ($self, %args) = @_;
24 2         5 my $basec = $basect->{colors}{$cn};
25 2 100       6 if (ref($basec) eq 'CODE') {
26 1         5 $basec = $basec->($self, name=>$cn, %args);
27             }
28 2 50       7 if ($basec) {
29 2 50       4 if (ref($basec) eq 'ARRAY') {
30 0 0 0     0 $basec = [map {defined($_) && /^#?[0-9A-Fa-f]{6}$/ ?
  0         0  
31             $func->($_) : $_} @$basec];
32             } else {
33 2         5 for ($basec) {
34 2 50 33     28 $_ = defined($_) && /^#?[0-9A-Fa-f]{6}$/ ?
35             $func->($_) : $_;
36             }
37             }
38             }
39 2         18 return $basec;
40 2         10 };
41             } else {
42             #$derivedct->{colors}{$cn} = $cv;
43             }
44             }
45 1         3 $derivedct;
46             }
47              
48             1;
49             # ABSTRACT: Utility routines
50              
51             __END__