File Coverage

blib/lib/Bootylicious/ArticleArchiveYearly.pm
Criterion Covered Total %
statement 30 31 96.7
branch 2 2 100.0
condition 5 5 100.0
subroutine 7 8 87.5
pod 0 3 0.0
total 44 49 89.8


line stmt bran cond sub pod time code
1             package Bootylicious::ArticleArchiveYearly;
2              
3 5     5   17 use strict;
  5         5  
  5         118  
4 5     5   12 use warnings;
  5         7  
  5         129  
5              
6 5     5   16 use base 'Bootylicious::ArticleArchiveBase';
  5         5  
  5         1627  
7              
8 5     5   23 use Bootylicious::Iterator;
  5         5  
  5         23  
9 5     5   1698 use Bootylicious::Year;
  5         8  
  5         75  
10              
11             sub build {
12 5     5 0 6 my $self = shift;
13              
14 5         6 my $years = {};
15 5         45 while (my $article = $self->articles->next) {
16 8         21 my $year = $article->created->year;
17              
18 8 100 100     681 next if $self->year && $self->year != $year;
19              
20 7   100     85 $years->{$year} ||= [];
21 7         9 push @{$years->{$year}}, $article;
  7         27  
22             }
23              
24 5         7 my @years;
25 5         18 foreach my $year (sort { $b <=> $a } keys %$years) {
  1         5  
26             push @years,
27             Bootylicious::Year->new(
28             year => $year,
29             articles => Bootylicious::Iterator->new(
30 5         21 elements => $years->{$year}
31             )
32             );
33             }
34              
35             $self->articles(
36 5         33 Bootylicious::Iterator->new(elements => [@years]));
37              
38 5         38 return $self;
39             }
40              
41 4     4 0 54 sub is_yearly {1}
42 0     0 0   sub is_monthly {0}
43              
44             1;