Auto.pm

filter: Statementstmt 96.6% 57 / 59 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 93.7% 75 / 80 CC 9 SCAR 17.2
CC
9
Cov
93%
matrix
9.2
BEGIN
1.0
BEGIN
1.0
CRAP 5.6
↑ Summary Auto/Templates.pm »
1 package HTML::Auto;
2 # ABSTRACT: write HTML for common elements
3 3 $HTML::Auto::VERSION = '0.09';
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use HTML::Auto::Templates;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 require Exporter;
11 3 our @ISA = qw(Exporter);
12 3 our @EXPORT_OK = qw(matrix h v);
13  
14 3 ▶sub matrix {
Subroutine matrix: called CC=9 SCAR=22.2
Pod documented
15 3 my ($cols,$lines,$data,$options) = @_;
16  
17 3 ▶ if ($options->{ucfirst}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"ucfirst"}) 0 3 3
18 0 foreach (@$cols, @$lines) {
19 0 $_ = ucfirst($_);
20 }
21 }
22  
23 3 my $vals = [];
24 3 my $attrs = [];
25 3 my $more = [];
26  
27 3 foreach my $row (@$data) {
28 6 my $vrow = [];
29 6 my $arow = [];
30 6 my $mrow = [];
31 6 foreach(@$row){
32 12 ▶ if (ref($_)){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 1 11 12
33 1 push @$vrow, $_->{v};
34 1 push @$arow, $_->{a};
35 1 push @$mrow, $_->{more_info};
36 }
37 else {
38 11 push @$vrow, $_;
39 11 push @$arow, undef;
40 11 push @$mrow, undef;
41 }
42 }
43 6 push @$vals, $vrow;
44 6 push @$attrs, $arow;
45 6 push @$more, $mrow;
46 }
47  
48 3 my $vars = {
49 cols => $cols,
50 lines => $lines,
51 vals => $vals,
52 attrs => $attrs,
53 more => $more,
54 };
55 $vars->{css} = $options->{css}
56 3 ▶ if $options->{css};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"css"} 0 3 3
57 $vars->{myformat} = $options->{format}
58 3 ▶ if $options->{format};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"format"} 0 3 3
59 $vars->{diagonal} = $options->{diagonal}
60 3 ▶ if $options->{diagonal};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"diagonal"} 2 1 3
61  
62 3 my $template_name = 'matrix';
63 3 __process($template_name, $vars);
64 }
65  
66 1 ▶sub h {
Subroutine h: called CC=1 SCAR=0.0
Pod documented
67 1 my (@list) = @_;
68  
69 1 my $vars = {
70 list => [@list],
71 };
72 1 my $template_name = 'h';
73  
74 1 __process($template_name, $vars);
75 }
76  
77 1 ▶sub v {
Subroutine v: called CC=1 SCAR=0.0
Pod documented
78 1 my (@list) = @_;
79  
80 1 my $vars = {
81 list => [@list],
82 };
83 1 my $template_name = 'v';
84  
85 1 __process($template_name, $vars);
86 }
87  
88 5 ▶sub __process {
Subroutine __process: called CC=1 SCAR=0.0
89 5 my ($template_name,$vars) = @_;
90  
91 # build html from template
92 5 my $template_config = {
93 INCLUDE_PATH => [ 'templates' ],
94 };
95 5 my $template = Template->new({
96 LOAD_TEMPLATES => [ HTML::Auto::Templates->new($template_config) ],
97 });
98 5 my $html;
99 5 $template->process($template_name, $vars, \$html);
100  
101 5 return $html;
102 }
103  
104 3 1;
105  
106 __END__
↑ Summary Auto/Templates.pm »