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   6 use strict;
  1         2  
  1         37  
2 1     1   5 use warnings;
  1         2  
  1         48  
3             package Email::Folder::MH;
4             # ABSTRACT: reads raw RFC822 mails from an mh folder
5             $Email::Folder::MH::VERSION = '0.859';
6 1     1   6 use Carp;
  1         2  
  1         82  
7 1     1   939 use IO::File;
  1         12048  
  1         191  
8 1     1   654 use Email::Folder::Reader;
  1         3  
  1         30  
9 1     1   815 use parent 'Email::Folder::Reader';
  1         291  
  1         6  
10              
11             #pod =head1 SYNOPSIS
12             #pod
13             #pod This isa Email::Folder::Reader - read about its API there.
14             #pod
15             #pod =head1 DESCRIPTION
16             #pod
17             #pod It's yet another email folder reader! It reads MH folders.
18             #pod
19             #pod =cut
20              
21             sub _what_is_there {
22 1     1   2 my $self = shift;
23 1         2 my $dir = $self->{_file};
24              
25 1 50       27 croak "$dir does not exist" unless (-e $dir);
26 1 50       12 croak "$dir is not a directory" unless (-d $dir);
27              
28 1         1 my @messages;
29 1 50       43 opendir(DIR,"$dir") or croak "Could not open '$dir'";
30 1         17 foreach my $file (readdir DIR) {
31 6 50       15 if ($^O eq 'VMS'){
32 0 0       0 next unless $file =~ /\A\d+\.\Z/;
33             } else {
34 6 100       21 next unless $file =~ /\A\d+\Z/;
35             }
36 4         9 push @messages, "$dir/$file";
37             }
38              
39 1         8 $self->{_messages} = \@messages;
40             }
41              
42             sub next_message {
43 5     5 1 8 my $self = shift;
44 5   66     22 my $what = $self->{_messages} || $self->_what_is_there;
45              
46 5 100       15 my $file = shift @$what or return;
47 4         8 local *FILE;
48 4 50       137 open FILE, $file or croak "couldn't open '$file' for reading";
49 4         214 join '', ;
50             }
51              
52             1;
53              
54             __END__