File Coverage

blib/lib/Email/Abstract/MIMEEntity.pm
Criterion Covered Total %
statement 11 29 37.9
branch 3 6 50.0
condition n/a
subroutine 4 8 50.0
pod 1 5 20.0
total 19 48 39.5


line stmt bran cond sub pod time code
1 3     3   5329 use strict;
  3         7  
  3         183  
2             package Email::Abstract::MIMEEntity;
3             # ABSTRACT: Email::Abstract wrapper for MIME::Entity
4             $Email::Abstract::MIMEEntity::VERSION = '3.008';
5 3     3   1208 use Email::Abstract::Plugin;
  3         6  
  3         112  
6 3     3   1007 BEGIN { @Email::Abstract::MIMEEntity::ISA = 'Email::Abstract::MailInternet' };
7              
8             my $is_avail;
9             sub is_available {
10 4 100   4 1 2390 return $is_avail if defined $is_avail;
11 3         6 eval { require MIME::Entity; MIME::Entity->VERSION(5.501); 1 };
  3         712  
  0         0  
  0         0  
12 3 50       24 return $is_avail = $@ ? 0 : 1;
13             }
14              
15 0     0 0   sub target { "MIME::Entity" }
16              
17             sub construct {
18 0     0 0   require MIME::Parser;
19 0           my $parser = MIME::Parser->new;
20 0           $parser->output_to_core(1);
21 0           my ($class, $rfc822) = @_;
22 0           $parser->parse_data($rfc822);
23             }
24              
25             sub get_body {
26 0     0 0   my ($self, $obj) = @_;
27 0           my $handle = $obj->bodyhandle;
28 0 0         return $handle ? $handle->as_string : join('', @{ $obj->body });
  0            
29             }
30              
31             sub set_body {
32 0     0 0   my ($class, $obj, $body) = @_;
33 0           my @lines = split /\n/, $body;
34 0           my $io = $obj->bodyhandle->open("w");
35 0           foreach (@lines) { $io->print($_."\n") }
  0            
36 0           $io->close;
37             }
38              
39             1;
40              
41             #pod =head1 DESCRIPTION
42             #pod
43             #pod This module wraps the MIME::Entity mail handling library with an
44             #pod abstract interface, to be used with L
45             #pod
46             #pod =head1 SEE ALSO
47             #pod
48             #pod L, L.
49             #pod
50             #pod =cut
51              
52             __END__