blib/lib/App/Pods2Site/SiteBuilder/BasicFramesSimpleTOC.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 12 | 52 | 23.0 |
branch | 0 | 12 | 0.0 |
condition | 0 | 2 | 0.0 |
subroutine | 4 | 6 | 66.6 |
pod | n/a | ||
total | 16 | 72 | 22.2 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package App::Pods2Site::SiteBuilder::BasicFramesSimpleTOC; | ||||||
2 | |||||||
3 | 2 | 2 | 11 | use strict; | |||
2 | 4 | ||||||
2 | 48 | ||||||
4 | 2 | 2 | 9 | use warnings; | |||
2 | 4 | ||||||
2 | 92 | ||||||
5 | |||||||
6 | our $VERSION = '1.003'; | ||||||
7 | my $version = $VERSION; | ||||||
8 | $VERSION = eval $VERSION; | ||||||
9 | |||||||
10 | 2 | 2 | 18 | use base qw(App::Pods2Site::SiteBuilder::AbstractBasicFrames); | |||
2 | 4 | ||||||
2 | 791 | ||||||
11 | |||||||
12 | 2 | 2 | 12 | use App::Pods2Site::Util qw(slashify); | |||
2 | 3 | ||||||
2 | 817 | ||||||
13 | |||||||
14 | sub _getCategoryTOC | ||||||
15 | { | ||||||
16 | 0 | 0 | my $self = shift; | ||||
17 | 0 | my $groupName = shift; | |||||
18 | 0 | my $podInfo = shift; | |||||
19 | 0 | my $sitedir = shift; | |||||
20 | |||||||
21 | 0 | my $toc = ''; | |||||
22 | 0 | my %tree; | |||||
23 | 0 | foreach my $podName (sort(keys(%$podInfo))) | |||||
24 | { | ||||||
25 | 0 | my $treeloc = \%tree; | |||||
26 | 0 | for my $level (split(/::/, $podName)) | |||||
27 | { | ||||||
28 | 0 | 0 | $treeloc->{$level} = {} unless exists($treeloc->{$level}); | ||||
29 | 0 | $treeloc = $treeloc->{$level}; | |||||
30 | } | ||||||
31 | } | ||||||
32 | 0 | $self->_genRefs($sitedir, \$toc, $podInfo, \%tree); | |||||
33 | 0 | chomp($toc); | |||||
34 | 0 | 0 | my $groupnameelem = $groupName ? "$groupName \n" : ''; |
||||
35 | 0 | 0 | $toc = qq($groupnameelem$toc ) if $toc; |
||||
36 | |||||||
37 | 0 | return $toc; | |||||
38 | } | ||||||
39 | |||||||
40 | sub _genRefs | ||||||
41 | { | ||||||
42 | 0 | 0 | my $self = shift; | ||||
43 | 0 | my $sitedir = shift; | |||||
44 | 0 | my $ref = shift; | |||||
45 | 0 | my $podInfo = shift; | |||||
46 | 0 | my $treeloc = shift; | |||||
47 | 0 | 0 | my $depth = shift || 0; | ||||
48 | 0 | my $n = shift; | |||||
49 | 0 | my $np = shift; | |||||
50 | |||||||
51 | 0 | my $r = ''; | |||||
52 | 0 | 0 | if ($n) | ||||
53 | { | ||||||
54 | 0 | $r = "${n}::"; | |||||
55 | 0 | 0 | $$ref .= (' ' x ($depth - 1)) if $depth > 1; | ||||
56 | 0 | my $p = $podInfo->{$n}->{htmlfile}; | |||||
57 | 0 | 0 | if ($p) | ||||
58 | { | ||||||
59 | 0 | $p =~ s#\Q$sitedir\E.##; | |||||
60 | 0 | $p = slashify($p, '/'); | |||||
61 | 0 | $$ref .= qq($np \n); |
|||||
62 | } | ||||||
63 | else | ||||||
64 | { | ||||||
65 | 0 | $$ref .= qq($np \n); |
|||||
66 | } | ||||||
67 | } | ||||||
68 | 0 | foreach my $subnp (sort { lc($a) cmp lc($b) } (keys(%$treeloc))) | |||||
0 | |||||||
69 | { | ||||||
70 | 0 | my $subn = "$r$subnp"; | |||||
71 | |||||||
72 | 0 | $depth++; | |||||
73 | 0 | $self->_genRefs($sitedir, $ref, $podInfo, $treeloc->{$subnp}, $depth, $subn, $subnp); | |||||
74 | 0 | $depth--; | |||||
75 | } | ||||||
76 | } | ||||||
77 | |||||||
78 | 1; |