File Coverage

blib/lib/Bootylicious/ArticleArchiveSimple.pm
Criterion Covered Total %
statement 21 24 87.5
branch 0 2 0.0
condition 0 6 0.0
subroutine 7 7 100.0
pod 1 2 50.0
total 29 41 70.7


line stmt bran cond sub pod time code
1             package Bootylicious::ArticleArchiveSimple;
2              
3 4     4   14 use strict;
  4         4  
  4         94  
4 4     4   12 use warnings;
  4         7  
  4         87  
5              
6 4     4   12 use base 'Mojo::Base';
  4         6  
  4         234  
7              
8 4     4   14 use Bootylicious::Iterator;
  4         4  
  4         19  
9 4     4   69 use Bootylicious::Year;
  4         5  
  4         14  
10              
11             __PACKAGE__->attr('articles');
12              
13             sub new {
14 1     1 1 6 my $self = shift->SUPER::new(@_);
15              
16 1         8 return $self->build;
17             }
18              
19             sub build {
20 1     1 0 1 my $self = shift;
21              
22 1         3 my @archive = ();
23 1         4 while (my $article = $self->articles->next) {
24 0         0 my $year = $article->created->year;
25 0         0 my $month = $article->created->month;
26              
27 0 0 0     0 push @archive, [$year, $month]
      0        
28             if !@archive
29             || ($archive[-1]->[0] != $year || $archive[-1]->[1] != $month);
30             }
31              
32 1         7 return [@archive];
33             }
34              
35             1;