Obj2HTML/Plugin/SemanticUITabs.pm

filter: Statementstmt 23.8% 16 / 67 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 2 / 8 Podpod n/a totaltotal 20.6% 18 / 87 SCAR 37.0
CC
8
Cov
20%
__ANON__
20.0
__ANON__
12.0
__ANON__
6.0
CRAP 40.5
« Obj2HTML/Plugin/DB2PO.pm ↑ Summary Obj2HTML/Plugin/Base.pm »
1 package HTML::Obj2HTML::Plugin::SemanticUI;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 my @tabs = ();
7 1 my @content = ();
8 HTML::Obj2HTML::register_extension("tabsection", {
9 tag => "",
10 before => sub {
11 0 ▶ my $obj = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
12 0 @tabs = ();
13 0 @content = ();
14 0 return HTML::Obj2HTML::gen($obj);
15 },
16 after => sub {
17 0 ▶ my $obj = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
18 0 my $divinner = {
19 class => "ui tabular menu",
20 _ => \@tabs
21 };
22 0 ▶ if (ref $obj eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $obj eq 'HASH') { } 0 0 0
23 0 foreach my $k (%{$obj}) {
24 0 ▶ if (defined $divinner->{$k}) { $divinner->{$k} .= " ".$obj->{$k}; } else { $divinner->{$k} = $obj->{$k}; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $divinner->{$k}) { } 0 0 0
25 }
26 0 return HTML::Obj2HTML::gen([ div => $divinner, \@content ]);
27 } else {
28 0 return HTML::Obj2HTML::gen([ div => { class => "ui top attached tabular menu", _ => \@tabs }, \@content ]);
29 }
30 }
31 1 });
32 HTML::Obj2HTML::register_extension("tab", {
33 tag => "",
34 before => sub {
35 0 ▶ my $obj = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
36 0 ▶ if ($obj->{class}) { $obj->{class} .= " "; }
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{"class"}) 0 0 0
37 0 ▶ if ($obj->{active}) { $obj->{class} .= "active "; }
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{"active"}) 0 0 0
38 0 push(@tabs, div => { class => $obj->{class}."item", "data-tab" => $obj->{tab}, _ => $obj->{label} });
39 0 push(@content, div => { class => $obj->{class}."ui bottom attached tab segment", "data-tab" => $obj->{tab}, _ => $obj->{content} });
40 0 return "";
41 }
42 1 });
43  
44 1 my $stepcontent = {};
45 1 my $steplabels = {};
46 1 my $curstepid;
47 HTML::Obj2HTML::register_extension("steps", {
48 tag => "",
49 before => sub {
50 0 ▶ my $o = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 0 my $content = $o->{_};
52 0 $stepcontent->{$o->{id}} = [];
53 0 $steplabels->{$o->{id}} = [];
54 0 $curstepid = $o->{id};
55 0 HTML::Obj2HTML::gen($content); # This processes it, but it doesn't actually generate anything, that's handled by the after()
56 },
57 after => sub {
58 0 ▶ my $o = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
59 0 my $id = "";
60 0 ▶ if (ref $o eq "HASH") { $id = $o->{id}; }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $o eq "HASH") 0 0 0
61 0 my $cls = HTML::Obj2HTML::combineClasses("ui steps", $o->{class});
62 0 my $ccls = HTML::Obj2HTML::combineClasses("stepcontent", $o->{contentclass});
63 return [
64 0 div => { "data-stepid" => $id, class => $cls, _ => \@{$steplabels->{$o->{id}}} },
65 0 div => { "data-stepid" => $id, class => $ccls, _ => \@{$stepcontent->{$o->{id}}} }
66 ];
67 }
68 1 });
69 HTML::Obj2HTML::register_extension("step", {
70 tag => "",
71 before => sub {
72 0 ▶ my $o = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
73 0 my @steplabels = @{$steplabels->{$curstepid}};
74 0 my $cnt = (($#steplabels+1)/2)+1; # -1 = no steps, start count from 1, therefore +2.
75 0 ▶ if (!@steplabels) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @steplabels) { } 0 0 0
76 0 push(@{$steplabels->{$curstepid}}, div => { "data-stepid" => $curstepid, class => 'active step', "data-stepnum" => $cnt, _ => $o->{label} });
77 0 push(@{$stepcontent->{$curstepid}}, div => { "data-stepid" => $curstepid, "data-stepnum" => $cnt, _ => $o->{_} });
78 } else {
79 0 push(@{$steplabels->{$curstepid}}, div => { "data-stepid" => $curstepid, class => 'step', "data-stepnum" => $cnt, _ => $o->{label} });
80 0 push(@{$stepcontent->{$curstepid}}, div => { "data-stepid" => $curstepid, "data-stepnum" => $cnt, style => 'display: none;', _ => $o->{_} });
81 }
82 0 return;
83 }
84 1 });
85 1 1;
« Obj2HTML/Plugin/DB2PO.pm ↑ Summary Obj2HTML/Plugin/Base.pm »