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   20 use strict;
  5         9  
  5         177  
4 5     5   18 use warnings;
  5         7  
  5         119  
5              
6 5     5   21 use base 'Bootylicious::ArticleArchiveBase';
  5         8  
  5         4775  
7              
8 5     5   31 use Bootylicious::Iterator;
  5         6  
  5         36  
9 5     5   10657 use Bootylicious::Year;
  5         94  
  5         38  
10              
11             sub build {
12 5     5 0 10 my $self = shift;
13              
14 5         11 my $years = {};
15 5         38 while (my $article = $self->articles->next) {
16 8         27 my $year = $article->created->year;
17              
18 8 100 100     551 next if $self->year && $self->year != $year;
19              
20 7   100     85 $years->{$year} ||= [];
21 7         8 push @{$years->{$year}}, $article;
  7         25  
22             }
23              
24 5         10 my @years;
25 5         29 foreach my $year (sort { $b <=> $a } keys %$years) {
  1         5  
26 5         35 push @years,
27             Bootylicious::Year->new(
28             year => $year,
29             articles => Bootylicious::Iterator->new(
30             elements => $years->{$year}
31             )
32             );
33             }
34              
35             $self->articles(
36 5         44 Bootylicious::Iterator->new(elements => [@years]));
37              
38 5         52 return $self;
39             }
40              
41 4     4 0 83 sub is_yearly {1}
42 0     0 0   sub is_monthly {0}
43              
44             1;