File Coverage

blib/lib/Bootylicious/PingbackIterator.pm
Criterion Covered Total %
statement 30 30 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 1 2 50.0
total 41 42 97.6


line stmt bran cond sub pod time code
1             package Bootylicious::PingbackIterator;
2              
3 15     15   15088 use strict;
  15         31  
  15         331  
4 15     15   67 use warnings;
  15         30  
  15         361  
5              
6 15     15   66 use base 'Bootylicious::Iterator';
  15         26  
  15         2951  
7              
8             __PACKAGE__->attr('path');
9              
10 15     15   712 use Bootylicious::Pingback;
  15         33  
  15         78  
11 15     15   818 use Bootylicious::Timestamp;
  15         32  
  15         68  
12              
13             sub new {
14 13     13 1 1513 my $self = shift->SUPER::new(@_);
15              
16 13         40 return $self->load;
17             }
18              
19             sub load {
20 13     13 0 24 my $self = shift;
21              
22 13 100   4   70 open my $fh, '<:encoding(UTF-8)', $self->path or return $self;
  4         155  
  4         10  
  4         24  
23              
24 8         9097 my @pingbacks;
25 8         144 while (my $line = <$fh>) {
26 8         95 chomp $line;
27              
28 8         37 my ($created, $source_uri) = split ' ' => $line;
29              
30 8         43 $created = Bootylicious::Timestamp->new(timestamp => $created);
31              
32 8         45 push @pingbacks,
33             Bootylicious::Pingback->new(
34             created => $created,
35             source_uri => $source_uri
36             );
37             }
38              
39 8         133 $self->elements([@pingbacks]);
40              
41 8         174 return $self;
42             }
43              
44             1;