File Coverage

blib/lib/CPAN/Changes/Utils.pm
Criterion Covered Total %
statement 28 28 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 39 39 100.0


line stmt bran cond sub pod time code
1             package CPAN::Changes::Utils;
2              
3 3     3   470642 use base qw(Exporter);
  3         6  
  3         465  
4 3     3   20 use strict;
  3         7  
  3         128  
5 3     3   31 use warnings;
  3         7  
  3         217  
6              
7 3     3   19 use List::Util qw(max min);
  3         9  
  3         446  
8 3     3   1930 use Readonly;
  3         15804  
  3         912  
9              
10             # Constants.
11             Readonly::Array our @EXPORT => qw(construct_copyright_years);
12              
13             our $VERSION = 0.02;
14              
15             sub construct_copyright_years {
16 6     6 1 390174 my $changes = shift;
17              
18 6         13 my $copyright_years;
19 5         25 my @years = map { $_->date =~ m/^(\d{4})/ms; $1 }
  5         18  
20 6         27 grep { defined $_->date }
  7         185  
21             $changes->releases;
22 6         132 my $year_from = min(@years);
23 6         16 my $year_to = max(@years);
24 6 100       23 if (defined $year_from) {
25 3         7 $copyright_years = $year_from;
26 3 100       10 if ($year_from != $year_to) {
27 2         6 $copyright_years .= '-'.$year_to;
28             }
29             }
30              
31 6         23 return $copyright_years;
32             }
33              
34             1;
35              
36             __END__