blib/lib/Bootylicious/ArticlePager.pm

filter: Statementstmt 97.8% 46 / 47 Branchbran 90.0% 18 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 5 totaltotal 90.1% 73 / 81 CC 11 SCAR 10.7
CC
11
Cov
96%
articles
5.0
prev
3.0
next
3.0
CRAP 2.9
« blib/lib/Bootylicious/Plugin/HttpCache.pm ↑ Summary blib/lib/Bootylicious/Page.pm »
1 package Bootylicious::ArticlePager;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base 'Mojo::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Bootylicious::Timestamp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 __PACKAGE__->attr('timestamp');
11 2 __PACKAGE__->attr(limit => 10);
12 2 __PACKAGE__->attr('iterator');
13  
14 sub prev {
15 3 ▶ my $self = shift;
Subroutine prev: called CC=3 SCAR=11.0
Pod undocumented
16  
17 3 my $i = $self->iterator;
18  
19 3 my $first = $self->articles->first;
20  
21 3 $i->rewind;
22 3 ▶ while (my $article = $i->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $article = $i->next) 5 1 6
23 5 ▶ if ($article->created->epoch == $first->created->epoch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($article->created->epoch == $first->created->epoch) 2 3 5
24 2 return $i->prev($self->limit)->last;
25 }
26 }
27  
28 1 return;
29 }
30  
31 sub prev_timestamp {
32 2 ▶ my $self = shift;
Subroutine prev_timestamp: called CC=2 SCAR=7.6
Pod undocumented
33  
34 2 my $prev = $self->prev;
35 2 ▶ return '' unless $prev;
Branch: 1 branch
BranchTrueFalseTotal
unless $prev 2 0 2
36  
37 0 return $prev->created->timestamp;
38 }
39  
40 sub next {
41 3 ▶ my $self = shift;
Subroutine next: called CC=3 SCAR=11.0
Pod undocumented
42  
43 3 my $i = $self->iterator;
44  
45 3 my $last = $self->articles->last;
46  
47 3 $i->rewind;
48 3 ▶ while (my $article = $i->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $article = $i->next) 9 1 10
49 9 ▶ last if $article->created->epoch == $last->created->epoch;
Branch: 1 branch
BranchTrueFalseTotal
if $article->created->epoch == $last->created->epoch 2 7 9
50 }
51  
52 3 return $i->next;
53 }
54  
55 sub next_timestamp {
56 2 ▶ my $self = shift;
Subroutine next_timestamp: called CC=2 SCAR=6.9
Pod undocumented
57  
58 2 my $next = $self->next;
59 2 ▶ return '' unless $next;
Branch: 1 branch
BranchTrueFalseTotal
unless $next 1 1 2
60  
61 1 return $next->created->timestamp;
62 }
63  
64 sub articles {
65 15 ▶ my $self = shift;
Subroutine articles: called CC=5 SCAR=16.1
Pod undocumented
66  
67 15 ▶ return $self->{articles} if $self->{articles};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"articles"} 11 4 15
68  
69 4 my $i = $self->iterator;
70  
71 4 ▶ if ($self->timestamp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->timestamp) 1 3 4
72 1 ▶ while (my $article = $i->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $article = $i->next) 4 0 4
73 last
74 4 ▶ if $article->created->epoch
Branch: 1 branch
BranchTrueFalseTotal
if $article->created->epoch <= "Bootylicious::Timestamp"->new("timestamp", $self->timestamp)->epoch 1 3 4
75 <= Bootylicious::Timestamp->new(timestamp => $self->timestamp)->epoch;
76 }
77 }
78  
79 4 $i->prev;
80  
81 4 return $self->{articles} = $i->next($self->limit);
82 }
83  
84 2 1;
« blib/lib/Bootylicious/Plugin/HttpCache.pm ↑ Summary blib/lib/Bootylicious/Page.pm »