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   16396 use strict;
  15         19  
  15         324  
4 15     15   44 use warnings;
  15         14  
  15         318  
5              
6 15     15   43 use base 'Bootylicious::Iterator';
  15         13  
  15         3083  
7              
8             __PACKAGE__->attr('path');
9              
10 15     15   721 use Bootylicious::Pingback;
  15         17  
  15         75  
11 15     15   857 use Bootylicious::Timestamp;
  15         16  
  15         59  
12              
13             sub new {
14 13     13 1 1353 my $self = shift->SUPER::new(@_);
15              
16 13         31 return $self->load;
17             }
18              
19             sub load {
20 13     13 0 15 my $self = shift;
21              
22 13 100   4   61 open my $fh, '<:encoding(UTF-8)', $self->path or return $self;
  4         144  
  4         4  
  4         24  
23              
24 8         8576 my @pingbacks;
25 8         132 while (my $line = <$fh>) {
26 8         78 chomp $line;
27              
28 8         50 my ($created, $source_uri) = split ' ' => $line;
29              
30 8         40 $created = Bootylicious::Timestamp->new(timestamp => $created);
31              
32 8         37 push @pingbacks,
33             Bootylicious::Pingback->new(
34             created => $created,
35             source_uri => $source_uri
36             );
37             }
38              
39 8         118 $self->elements([@pingbacks]);
40              
41 8         131 return $self;
42             }
43              
44             1;