File Coverage

blib/lib/CPAN/Releases/Latest/ReleaseIterator.pm
Criterion Covered Total %
statement 16 23 69.5
branch 1 4 25.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 22 33 66.6


line stmt bran cond sub pod time code
1             package CPAN::Releases::Latest::ReleaseIterator;
2             $CPAN::Releases::Latest::ReleaseIterator::VERSION = '0.06';
3 2     2   47 use 5.006;
  2         8  
  2         158  
4 2     2   11 use Moo;
  2         4  
  2         43  
5 2     2   759 use CPAN::Releases::Latest;
  2         4  
  2         60  
6 2     2   1207 use CPAN::Releases::Latest::Release;
  2         4  
  2         462  
7              
8             has 'latest' =>
9             (
10             is => 'ro',
11             default => sub { CPAN::Releases::Latest->new() },
12             );
13              
14             has _fh => (is => 'rw');
15              
16             sub next_release
17             {
18 2     2 0 3779 my $self = shift;
19 2         4 my $fh;
20              
21 2 50       31 if (not defined($fh = $self->_fh)) {
22 2         17 $fh = $self->latest->_open_file();
23 0           $self->_fh($fh);
24             }
25              
26 0           my $line = <$fh>;
27 0 0         if (defined($line)) {
28 0           chomp($line);
29 0           my ($distname, $path, $time, $size) = split(/\s+/, $line);
30 0           return CPAN::Releases::Latest::Release->new(
31             distname => $distname,
32             path => $path,
33             timestamp => $time,
34             size => $size,
35             );
36             }
37             else {
38 0           return undef;
39             }
40              
41             }
42              
43             1;