File Coverage

blib/lib/Email/Sender/Transport/Print.pm
Criterion Covered Total %
statement 20 20 100.0
branch 1 2 50.0
condition 1 2 50.0
subroutine 5 5 100.0
pod 0 1 0.0
total 27 30 90.0


line stmt bran cond sub pod time code
1             package Email::Sender::Transport::Print 2.500;
2             # ABSTRACT: print email to a filehandle (like stdout)
3              
4 2     2   2040 use Moo;
  2         2944  
  2         12  
5             with 'Email::Sender::Transport';
6              
7             #pod =head1 DESCRIPTION
8             #pod
9             #pod When this transport is handed mail, it prints it to a filehandle. By default,
10             #pod it will print to STDOUT, but it can be given any L object to print
11             #pod to as its C attribute.
12             #pod
13             #pod =cut
14              
15 2     2   2490 use IO::Handle;
  2         6589  
  2         95  
16 2     2   566 use MooX::Types::MooseLike::Base qw(InstanceOf);
  2         7227  
  2         578  
17              
18             has 'fh' => (
19             is => 'ro',
20             isa => InstanceOf['IO::Handle'],
21             required => 1,
22             default => sub { IO::Handle->new_from_fd(fileno(STDOUT), 'w') },
23             );
24              
25             sub send_email {
26 1     1 0 4 my ($self, $email, $env) = @_;
27              
28 1         6 my $fh = $self->fh;
29              
30 1   50     2 $fh->printf("ENVELOPE TO : %s\n", join(q{, }, @{ $env->{to} }) || '-');
31 1 50       19 $fh->printf("ENVELOPE FROM: %s\n", defined $env->{from} ? $env->{from} : '-');
32 1         11 $fh->print(q{-} x 10 . " begin message\n");
33              
34 1         12 $fh->print( $email->as_string );
35              
36 1         157 $fh->print(q{-} x 10 . " end message\n");
37              
38 1         6 return $self->success;
39             }
40              
41 2     2   17 no Moo;
  2         4  
  2         20  
42             1;
43              
44             __END__