lib/Kwiki/BreadCrumbs.pm

filter: Statementstmt 32.0% 16 / 50 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 4 / 8 Podpod 25.0% 1 / 4 totaltotal 28.7% 21 / 73 CC 6 SCAR 25.7
CC
6
Cov
27%
init
30.0
html
6.0
register
2.0
CRAP 13.1
↑ Summary
1 package Kwiki::BreadCrumbs;
2 1 ▶use Kwiki::Plugin -Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use mixin 'Kwiki::Installer';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.12';
5  
6 1 const class_id => 'bread_crumbs';
7  
8 1 field trail => [];
9  
10 0 ▶sub init {
Subroutine init: not called CC=5 SCAR=34.0
Pod documented
11 0 ▶ return unless $self->is_in_cgi;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_in_cgi 0 0 0
12 0 super;
13 0 ▶ my $bread_crumbs = $self->hub->cookie->jar->{bread_crumbs} || [];
Condition0%0/2
$self->hub->cookie->jar->{'bread_crumbs'} || []
l!l
00
MC/DC0%0/1
$self->hub->cookie->jar->{'bread_crumbs'} || []
$self->hub->cookie->jar->{'bread_crumbs'}
Truth table0%0/2
A
A= $self->hub->cookie->jar->{'bread_crumbs'}
Aresult
11
00
14 0 ▶ if ($self->hub->action eq 'display') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->hub->action eq "display") 0 0 0
15 0 my $page_id = $self->pages->current->id;
16 0 @$bread_crumbs = grep { $_ ne $page_id } @$bread_crumbs;
17 0 unshift @$bread_crumbs, $page_id;
18 }
19 0 ▶ splice @$bread_crumbs, 10
Branch: 1 branch
BranchTrueFalseTotal
if @$bread_crumbs > 10 0 0 0
20 if @$bread_crumbs > 10;
21 0 $self->trail($bread_crumbs);
22 0 $self->hub->cookie->jar->{bread_crumbs} = $bread_crumbs;
23 }
24  
25 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod undocumented
26 0 my $registry = shift;
27 0 $registry->add(status => 'bread_crumbs',
28 template => 'bread_crumbs.html',
29 show_if_preference => 'show_bread_crumbs',
30 );
31 0 $registry->add(preference => $self->show_bread_crumbs);
32 }
33  
34 0 ▶sub show_bread_crumbs {
Subroutine show_bread_crumbs: not called CC=1 SCAR=6.9
Pod undocumented
35 0 my $p = $self->new_preference('show_bread_crumbs');
36 0 $p->query('Show How Many Bread Crumbs?');
37 0 $p->type('pulldown');
38 0 my $choices = [
39 0 => 0,
40 4 => 4,
41 6 => 6,
42 8 => 8,
43 10 => 10,
44 ];
45 0 $p->choices($choices);
46 0 $p->default(0);
47 0 return $p;
48 }
49  
50 0 ▶sub html {
Subroutine html: not called CC=2 SCAR=17.9
Pod undocumented
51 0 my @trail = @{$self->trail};
52 0 my $show = $self->preferences->show_bread_crumbs->value;
53 0 ▶ splice @trail, $show
Branch: 1 branch
BranchTrueFalseTotal
if @trail > $show 0 0 0
54 if @trail > $show;
55 0 my $script_name = $self->config->script_name;
56 0 my $pages = $self->hub->pages;
57 "<hr />" . join ' &lt; ',
58 map {
59 0 my $page = $pages->new_page($_);
60 0 sprintf "<a href=\"%s?%s\">%s</a>\n",
61 $script_name,
62 $page->uri,
63 $page->title;
64 } @trail;
65 }
66  
67 1 __DATA__
↑ Summary