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