lib/Kwiki/Archive.pm

filter: Statementstmt 36.7% 18 / 49 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 41.6% 5 / 12 Podpod 11.1% 1 / 9 totaltotal 29.8% 26 / 87 CC 9 SCAR 19.0
CC
9
Cov
32%
page_properties
20.0
commit_hook
6.0
commit_all
6.0
CRAP 6.7
« lib/Kwiki/Pages.pm ↑ Summary lib/Kwiki/Plugin.pm »
1 package Kwiki::Archive;
2 2 ▶use Kwiki::Plugin -Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 const class_id => 'archive';
5 2 const class_title => 'Page Archive';
6 2 const show_revisions => 1;
7  
8 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my $registry = shift;
10 0 $registry->add(hook => 'page:store', post => 'commit_hook');
11 }
12  
13 1 ▶sub init {
Subroutine init: called CC=2 SCAR=9.2
Pod documented
14 1 ▶ if ($self->empty) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->empty) 0 1 1
15 0 $self->generate;
16 0 $self->commit_all;
17 };
18 }
19  
20 1 ▶sub empty {
Subroutine empty: called CC=2 SCAR=7.1
Pod undocumented
21 1 my $dir = io($self->plugin_directory);
22 1 ▶ $dir->exists and $dir->empty;
Branch: 1 branch
BranchTrueFalseTotal
$dir->exists and $dir->empty 0 1 1
23 }
24  
25 0 ▶sub generate {
Subroutine generate: not called CC=1 SCAR=6.9
Pod undocumented
26 0 my $dir = $self->plugin_directory;
27 0 umask 0000;
28 0 chmod 0777, $dir;
29 }
30  
31 0 ▶sub commit_hook {
Subroutine commit_hook: not called CC=2 SCAR=17.9
Pod undocumented
32 0 my $hook = pop;
33 0 ▶ return unless $hook->returned_true;
Branch: 1 branch
BranchTrueFalseTotal
unless $hook->returned_true 0 0 0
34 0 my $page = $self;
35 0 $self = $page->hub->archive;
36 0 $self->commit($page);
37 }
38  
39 0 ▶sub commit_all {
Subroutine commit_all: not called CC=2 SCAR=17.9
Pod undocumented
40 0 for my $page ($self->pages->all) {
41 0 $self->commit($page);
42 }
43 }
44  
45 0 ▶sub page_properties {
Subroutine page_properties: not called CC=4 SCAR=30.0
Pod undocumented
46 0 my $page = shift;
47 0 my $properties = $page->metadata->to_hash;
48 0 ▶ $properties->{edit_by} ||= '';
Condition0%0/2
$properties->{"edit_by"} ||= ""
l!l
00
MC/DC0%0/1
$properties->{"edit_by"} ||= ""
$properties->{"edit_by"}
Truth table0%0/2
A
A= $properties->{"edit_by"}
Aresult
11
00
49 0 ▶ $properties->{edit_time} ||= scalar(gmtime);
Condition0%0/2
$properties->{"edit_time"} ||= scalar gmtime
l!l
00
MC/DC0%0/1
$properties->{"edit_time"} ||= scalar gmtime
$properties->{"edit_time"}
Truth table0%0/2
A
A= $properties->{"edit_time"}
Aresult
11
00
50 0 ▶ $properties->{edit_unixtime} ||= scalar(time);
Condition0%0/2
$properties->{"edit_unixtime"} ||= scalar time
l!l
00
MC/DC0%0/1
$properties->{"edit_unixtime"} ||= scalar time
$properties->{"edit_unixtime"}
Truth table0%0/2
A
A= $properties->{"edit_unixtime"}
Aresult
11
00
51 0 return $properties;
52 }
53  
54 0 ▶sub revision_number {
Subroutine revision_number: not called CC=2 SCAR=17.9
Pod undocumented
55 0 ▶ $self->history(shift)->[0]->{revision_id} || 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->history(shift())->[0]{"revision_id"} or 0 0 0 0
56 }
57  
58 0 ▶sub revision_numbers {
Subroutine revision_numbers: not called CC=1 SCAR=6.9
Pod undocumented
59 0 my $page = shift;
60 0 [map $_->{revision_id}, @{$self->history($page)}];
61 }
62  
63 2 __DATA__
« lib/Kwiki/Pages.pm ↑ Summary lib/Kwiki/Plugin.pm »