blib/lib/Kwiki/CachedDisplay.pm

filter: Statementstmt 30.7% 12 / 39 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 60.0% 3 / 5 Podpod 100% 2 / 2 totaltotal 22.6% 17 / 75 CC 11 SCAR 45.8
CC
11
Cov
20%
check_cached
132.0
register
2.0
BEGIN
1.0
CRAP 97.1
↑ Summary
1 package Kwiki::CachedDisplay;
2 2 ▶use Kwiki::Plugin -Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶our $VERSION = '0.07';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 const class_id => 'cached_display';
6  
7 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod documented
8 0 my $reg = shift;
9 0 $reg->add(hook => 'display:display', pre => 'check_cached');
10 }
11  
12 0 ▶sub check_cached {
Subroutine check_cached: not called CC=11 SCAR=48.8
Pod documented
13 0 my $hook = pop;
14 0 my $display = $self;
15 0 $self = $display->hub->cached_display;
16 0 my $page = $self->pages->current;
17 0 ▶ return unless $page->exists;
Branch: 1 branch
BranchTrueFalseTotal
unless $page->exists 0 0 0
18 return if (defined $self->config->can('cached_display_ignore') and
19 0 ▶ grep {$page->id} @{$self->config->cached_display_ignore});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->config->can("cached_display_ignore") and grep {$page->id;} @{$self->config->cached_display_ignore;} 0 0 0
Condition0%0/3
defined $self->config->can("cached_display_ignore") and grep {$page->id;} @{$self->config->cached_display_ignore;}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->config->can("cached_display_ignore") and grep {$page->id;} @{$self->config->cached_display_ignore;}
defined $self->config->can("cached_display_ignore") grep {$page->id;} @{$self->config->cached_display_ignore;}
Truth table0%0/3
A and B
A= defined $self->config->can("cached_display_ignore")B= grep {$page->id;} @{$self->config->cached_display_ignore;}
ABresult
0X0
100
111
20 0 my $html = io->catfile($self->plugin_directory,$page->id)->utf8;
21 0 my $content;
22  
23 0 my $depup = 0;
24 0 ▶ if (defined $self->config->can('cached_display_dependencies')){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->config->can("cached_display_dependencies")) 0 0 0
25 0 for (@{$self->config->cached_display_dependencies}){
26 0 my $deppage = $self->pages->new_page($_);
27 0 ▶ $depup = 1 if $deppage->modified_time > $html->mtime;
Branch: 1 branch
BranchTrueFalseTotal
if $deppage->modified_time > $html->mtime 0 0 0
28 }
29 }
30  
31 0 ▶ if($depup or
Branch: 1 branch
BranchTrueFalseTotal
if ($depup or not $html->exists or $page->modified_time > $html->mtime) 0 0 0
Condition0%0/6
$depup or not $html->exists or $page->modified_time > $html->mtime
l!l&&r!l&&!r
000
$depup or not $html->exists
l!l&&r!l&&!r
000
MC/DC0%0/3
$depup or not $html->exists or $page->modified_time > $html->mtime
$depup not $html->exists $page->modified_time > $html->mtime
Truth table0%0/4
A or not(B) or C
A= $depupB= not $html->existsC= $page->modified_time > $html->mtime
ABCresult
1XX1
01X1
0011
0000
32 !$html->exists or
33 ($page->modified_time > $html->mtime)) {
34 0 my $code = $hook->code;
35 0 $content = $code->($display);
36 0 $html->print($content);
37 }
38 0 ▶ $content ||= $html->all;
Condition0%0/3
$content ||= $html->all
l!l&&r!l&&!r
000
MC/DC0%0/2
$content ||= $html->all
$content $html->all
Truth table0%0/3
A ||= B
A= $contentB= $html->all
ABresult
1X1
011
000
39 0 $hook->cancel;
40 0 return $content;
41 }
42  
43 2 __END__
↑ Summary