File Coverage

blib/lib/CPAN/Releases/Latest/ReleaseIterator.pm
Criterion Covered Total %
statement 15 22 68.1
branch 1 4 25.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 21 32 65.6


line stmt bran cond sub pod time code
1             package CPAN::Releases::Latest::ReleaseIterator;
2             $CPAN::Releases::Latest::ReleaseIterator::VERSION = '0.07';
3 2     2   49 use 5.006;
  2         7  
4 2     2   10 use Moo;
  2         3  
  2         14  
5 2     2   722 use CPAN::Releases::Latest;
  2         4  
  2         51  
6 2     2   1163 use CPAN::Releases::Latest::Release;
  2         4  
  2         440  
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 2781 my $self = shift;
19 2         4 my $fh;
20              
21 2 50       25 if (not defined($fh = $self->_fh)) {
22 2         12 $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;