HTML/STL.pm

filter: Statementstmt 98.6% 71 / 72 Branchbran 90.0% 9 / 10 Conditioncond 50.0% 9 / 18 MC/DCmcdc 18.1% 2 / 11 Subroutinesub 100% 27 / 27 Podpod 0.0% 0 / 1 totaltotal 84.8% 118 / 139 CC 17 SCAR 18.9
CC
17
Cov
89%
process_args
17.8
__ANON__
2.0
__ANON__
2.0
CRAP 6.6
« HTML/Parser.pm ↑ Summary HTML/Compiler.pm »
1 package DSL::HTML::STL;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use DSL::HTML;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Scalar::Util qw/reftype/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 our @CARP_NOT = qw/DSL::HTML DSL::HTML::Template DSL::HTML::Rendering/;
11  
12 2 ▶template dl {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
13 1 my ($class, $keys, $data) = process_args(@_);
14
15 2 ▶ tag dl(class => $class) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
16 1 for my $key ( @$keys ) {
17 2 ▶ tag dt { $key }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
18 2 ▶ tag dd { $data->{$key} }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
19 }
20 1 }
21 2 }
22  
23 2 ▶template ol {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
24 1 my ($class, $items) = process_args(@_);
25  
26 2 ▶ tag ol(class => $class) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
27 1 for my $item (@$items) {
28 2 ▶ tag li { $item }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
29 }
30 1 }
31 2 }
32  
33 2 ▶template ul {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
34 1 my ($class, $items) = process_args(@_);
35  
36 2 ▶ tag ul(class => $class) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
37 1 for my $item (@$items) {
38 2 ▶ tag li { $item }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
39 }
40 1 }
41 2 }
42  
43 3 ▶sub process_args {
Subroutine process_args: called CC=14 SCAR=28.8
Pod undocumented
44 3 my ($class, $data, $sort, $keys);
45
46 3 for my $arg ( @_ ) {
47 6 my $type = reftype $arg;
48  
49 6 ▶ if (!$type) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $type) { } 1 5 6
elsif ($type eq 'HASH') { } 1 4 5
elsif ($type eq 'ARRAY') { } 3 1 4
elsif ($type eq 'CODE') { } 1 0 1
50 1 ▶ $class //= $arg;
Condition33%1/3
$class //= $arg
l!l&&r!l&&!r
010
MC/DC0%0/2
$class //= $arg
$class $arg
Truth table33%1/3
A //= B
A= $classB= $arg
ABresult
1X1
011
000
51 }
52 elsif( $type eq 'HASH' ) {
53 1 ▶ $data //= $arg;
Condition33%1/3
$data //= $arg
l!l&&r!l&&!r
010
MC/DC0%0/2
$data //= $arg
$data $arg
Truth table33%1/3
A //= B
A= $dataB= $arg
ABresult
1X1
011
000
54 }
55 elsif( $type eq 'ARRAY' ) {
56 3 ▶ $keys //= $arg;
Condition33%1/3
$keys //= $arg
l!l&&r!l&&!r
030
MC/DC0%0/2
$keys //= $arg
$keys $arg
Truth table33%1/3
A //= B
A= $keysB= $arg
ABresult
1X1
011
000
57 }
58 elsif( $type eq 'CODE' ) {
59 1 ▶ $sort //= $arg;
Condition33%1/3
$sort //= $arg
l!l&&r!l&&!r
010
MC/DC0%0/2
$sort //= $arg
$sort $arg
Truth table33%1/3
A //= B
A= $sortB= $arg
ABresult
1X1
011
000
60 }
61 else {
62 0 croak "Not sure what to do with '$arg'";
63 }
64 }
65  
66 3 ▶ $data //= {};
Condition100%2/2
$data //= {}
l!l
12
MC/DC100%1/1
$data //= {}
$data
Truth table100%2/2
A
A= $data
Aresult
11
00
67 3 ▶ $keys //= [ keys %$data ];
Condition50%1/2
$keys //= [keys %$data]
l!l
30
MC/DC0%0/1
$keys //= [keys %$data]
$keys
Truth table50%1/2
A
A= $keys
Aresult
11
00
68 3 ▶ $keys = [ sort $sort @$keys ] if $sort;
Branch: 1 branch
BranchTrueFalseTotal
if $sort 1 2 3
69  
70 3 ▶ return ($class || "", $keys, $data);
Condition100%2/2
$class || ''
l!l
12
MC/DC100%1/1
$class || ''
$class
Truth table100%2/2
A
A= $class
Aresult
11
00
71 }
72  
73 2 1;
74  
75 __END__
« HTML/Parser.pm ↑ Summary HTML/Compiler.pm »