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   21 use strict;
  4         6  
  4         165  
4 4     4   21 use warnings;
  4         8  
  4         144  
5              
6 4     4   21 use base 'Mojo::Base';
  4         86  
  4         337  
7              
8 4     4   22 use Bootylicious::Iterator;
  4         6  
  4         26  
9 4     4   87 use Bootylicious::Year;
  4         7  
  4         25  
10              
11             __PACKAGE__->attr('articles');
12              
13             sub new {
14 1     1 1 7 my $self = shift->SUPER::new(@_);
15              
16 1         9 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         6 return [@archive];
33             }
34              
35             1;