Wiki/CatalogKeeper.pm

filter: Statementstmt 100% 58 / 58 Branchbran 95.8% 23 / 24 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 98.9% 95 / 96 CC 17 SCAR 25.9
CC
17
Cov
99%
contents
17.0
BEGIN
1.0
BEGIN
1.0
CRAP 13.4
↑ Summary Wiki/Plugin/Block/CopyAndPaste.pm »
1 package Text::Livedoor::Wiki::CatalogKeeper;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 my $NO_SETTING = " ";
8  
9 92 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
10 92 my $class =shift;
11 92 my $self = bless {} ,$class;
12 92 $self->{data} = [];
13 92 return $self;
14 }
15 58 ▶sub append {
Subroutine append: called CC=1 SCAR=0.0
Pod documented
16 58 my $self = shift;
17 58 my $args = shift;
18 58 push @{$self->{data}} , $args;
19 }
20  
21 76 ▶sub contents {
Subroutine contents: called CC=17 SCAR=28.3
Pod documented
22 76 my $self = shift;
23  
24 # div¤Ç¤³¤Î¤¦¤¨¤ò°Ï¤ï¤Ê¤¤
25 76 my $prev = 0;
26 76 my $contents = qq|<div class="wiki-catalog">\n<div class="wiki-catalog-inner">\n<ul>\n|;
27 76 ▶ for ( my $i = 0 ; $i < scalar @{ $self->{data} } ; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->{"data"};}) 40 76 116
28 40 my $flg = 1;
29 40 my $item = $self->{data}[$i];
30 40 ▶ my $next = scalar @{$self->{data}} != $i+1 ? $self->{data}[$i+1]{level} : 0;
Branch: 1 branch
BranchTrueFalseTotal
scalar @{$self->{'data'};} != $i + 1 ? : 26 14 40
31 40 ▶ while( $flg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flg) 46 40 86
32 46 ▶ if( $item->{level} > $prev + 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item->{"level"} > $prev + 1) 6 40 46
33 6 $prev++;
34 #my $n = $prev == $item->{level} ? $next : $prev+1;
35 6 my $n = $next ;
36 6 $contents .= sprintf( qq|<li class="list-%s">$NO_SETTING| , $prev );
37  
38 6 ▶ if( $prev == $n ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($prev == $n) { } 2 4 6
elsif ($prev > $n) { } 1 3 4
elsif ($prev < $n) { } 3 0 3
39 2 $contents .= "</li>\n";
40 }
41 elsif( $prev > $n ) {
42 1 my $diff= $item->{level} - $n;
43 1 $contents .= "</li>\n";
44 1 for(1..$diff) {
45 3 $contents .= "</ul>\n</li>\n";
46 }
47 }
48 elsif( $prev < $n ) {
49 3 $contents .= "\n<ul>\n";
50 }
51  
52 6 next;
53 }
54 40 ▶ $prev= 1 if $prev== 0;
Branch: 1 branch
BranchTrueFalseTotal
if $prev == 0 11 29 40
55 40 $flg = 0;
56 }
57 40 $contents .= sprintf( qq|<li class="list-%s"><a href="#%s">%s</a>| , $item->{level} , $item->{id} , $item->{label} );
58  
59 40 ▶ if( $item->{level} == $next ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($item->{'level'} == $next) { } 5 35 40
elsif ($next != 0 and $item->{'level'} > $next) { } 7 28 35
elsif ($item->{'level'} < $next) { } 14 14 28
60 5 $contents .= "</li>\n";
61 }
62 ▶ elsif( $next != 0 && $item->{level} > $next ) {
Condition100%3/3
$next != 0 and $item->{"level"} > $next
!ll&&!rl&&r
14147
MC/DC100%2/2
$next != 0 and $item->{"level"} > $next
$next != 0 $item->{"level"} > $next
Truth table100%3/3
A and B
A= $next != 0B= $item->{"level"} > $next
ABresult
0X0
100
111
63 7 my $diff= $item->{level} - $next;
64 7 $contents .= "</li>\n";
65 7 for(1..$diff) {
66 10 $contents .= "</ul>\n</li>\n";
67 }
68 }
69 elsif( $item->{level} < $next ) {
70 14 $contents .= "\n<ul>\n";
71 }
72  
73 40 ▶ if( $next == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next == 0) 14 26 40
74 14 $contents .= "</li>\n";
75 14 for(1..($item->{level}-1)) {
76 10 $contents .= "</ul>\n</li>";
77 }
78 }
79  
80 40 $prev = $item->{level};
81 }
82  
83 76 $contents .= "\n</ul>\n</div>\n</div>";
84  
85 76 return $contents;
86 }
87  
88 10 1;
89  
90 =head1 NAME
91  
92 Text::Livedoor::Wiki::CatalogKeeper - Catalog Keeper
93  
94 =head1 DESCRIPTION
95  
96 keep h3,h4,h5 catalog
97  
98 =head1 METHOD
99  
100 =head2 append
101  
102 =head2 contents
103  
104 =head2 new
105  
106 =head1 AUTHOR
107  
108 polocky
109  
110 =cut
↑ Summary Wiki/Plugin/Block/CopyAndPaste.pm »