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