File Coverage

blib/lib/Email/Folder/MH.pm
Criterion Covered Total %
statement 35 36 97.2
branch 9 16 56.2
condition 2 3 66.6
subroutine 8 8 100.0
pod 1 1 100.0
total 55 64 85.9


line stmt bran cond sub pod time code
1 1     1   4 use strict;
  1         1  
  1         27  
2 1     1   4 use warnings;
  1         1  
  1         45  
3             package Email::Folder::MH;
4             {
5             $Email::Folder::MH::VERSION = '0.860';
6             }
7             # ABSTRACT: reads raw RFC822 mails from an mh folder
8              
9 1     1   4 use Carp;
  1         1  
  1         52  
10 1     1   477 use IO::File;
  1         7704  
  1         130  
11 1     1   389 use Email::Folder::Reader;
  1         2  
  1         26  
12 1     1   419 use parent 'Email::Folder::Reader';
  1         296  
  1         5  
13              
14              
15             sub _what_is_there {
16 1     1   1 my $self = shift;
17 1         2 my $dir = $self->{_file};
18              
19 1 50       15 croak "$dir does not exist" unless (-e $dir);
20 1 50       8 croak "$dir is not a directory" unless (-d $dir);
21              
22 1         1 my @messages;
23 1 50       18 opendir(DIR,"$dir") or croak "Could not open '$dir'";
24 1         9 foreach my $file (readdir DIR) {
25 6 50       10 if ($^O eq 'VMS'){
26 0 0       0 next unless $file =~ /\A\d+\.\Z/;
27             } else {
28 6 100       18 next unless $file =~ /\A\d+\Z/;
29             }
30 4         8 push @messages, "$dir/$file";
31             }
32              
33 1         7 $self->{_messages} = \@messages;
34             }
35              
36             sub next_message {
37 5     5 1 5 my $self = shift;
38 5   66     13 my $what = $self->{_messages} || $self->_what_is_there;
39              
40 5 100       16 my $file = shift @$what or return;
41 4         6 local *FILE;
42 4 50       79 open FILE, $file or croak "couldn't open '$file' for reading";
43 4         129 join '', ;
44             }
45              
46             1;
47              
48             __END__