File Coverage

blib/lib/App/dategrep/Iterator/Fh.pm
Criterion Covered Total %
statement 25 28 89.2
branch 8 12 66.6
condition 4 9 44.4
subroutine 5 5 100.0
pod 0 1 0.0
total 42 55 76.3


line stmt bran cond sub pod time code
1             package App::dategrep::Iterator::Fh;
2 8     8   2890 use strict;
  8         9  
  8         255  
3 8     8   37 use warnings;
  8         10  
  8         160  
4 8     8   54 use Moo;
  8         9  
  8         37  
5 8     8   1367 use FileHandle;
  8         11  
  8         37  
6             extends 'App::dategrep::Iterator';
7              
8             has fh => ( is => 'ro', required => 1 );
9             has end_passed => ( is => 'rw', default => sub { 0 } );
10              
11             sub get_entry_unbuffered {
12 25     25 0 24 my $self = shift;
13              
14 25 50 33     429 return if $self->end_passed || $self->fh->eof;
15              
16             LINE:
17 25         1528 while ( my $entry = $self->getline() ) {
18              
19 36 100       1250 if ( $self->multiline ) {
20 4   66     11 while (!$self->fh->eof
      33        
21             && !$self->end_passed
22             && !$self->next_line_has_date )
23             {
24 9         22 $entry .= $self->getline();
25             }
26             }
27 36         100 my ( $epoch, $error ) = $self->to_epoch($entry);
28 36 50       7275 if ( !$epoch ) {
29 0 0       0 next LINE if $self->skip_unparsable;
30 0         0 die "Unparsable line: $entry\n";
31             }
32 36 100       129 if ( $epoch >= $self->end ) {
33 7         27 $self->end_passed(1);
34 7         84 return;
35             }
36              
37 29 100       103 next LINE if $epoch < $self->start;
38              
39 18         81 return $entry;
40             }
41 0           return;
42              
43             }
44              
45             1;