SMTP/Connection.pm

filter: Statementstmt 32.0% 17 / 53 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 26.3% 5 / 19 Podpod 22.2% 2 / 9 totaltotal 26.9% 24 / 89 CC 5 SCAR 13.3
CC
5
Cov
28%
on_read
12.0
configure
6.0
starttls
6.0
CRAP 3.8
« SMTP/Client.pm ↑ Summary SMTP.pm »
1 package Net::Async::SMTP::Connection;
2 2 $Net::Async::SMTP::Connection::VERSION = '0.002';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent qw(IO::Async::Stream);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Net::Async::SMTP::Connection - stream subclass for dealing with SMTP connections
10  
11 =head1 VERSION
12  
13 version 0.002
14  
15 =head1 DESCRIPTION
16  
17 Used internally by L<Net::Async::SMTP>. No user-serviceable parts inside.
18  
19 =cut
20  
21 2 ▶use IO::Socket::SSL qw(SSL_VERIFY_NONE);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use Protocol::SMTP::Client;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 sub configure {
25 0 ▶ my $self = shift;
Subroutine configure: not called CC=2 SCAR=17.9
Pod documented
26 0 my %args = @_;
27 0 ▶ $self->{auth} = delete $args{auth} if exists $args{auth};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"auth"} 0 0 0
28 0 $self->SUPER::configure(%args)
29 }
30  
31 sub _add_to_loop {
32 0 ▶ my ($self, $loop) = @_;
Subroutine _add_to_loop: not called CC=1 SCAR=6.9
33 $self->{protocol} = Protocol::SMTP::Client->new(
34 0 ▶ future_factory => sub { $loop->new_future },
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 ▶ writer => sub { $self->write(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 0 auth_mechanism_override => $self->auth,
37 );
38 0 $self->protocol->startup;
39 0 $self->SUPER::_add_to_loop($loop);
40 }
41  
42 0 ▶sub auth { shift->{auth} }
Subroutine auth: not called CC=1 SCAR=6.9
Pod undocumented
43 0 ▶sub protocol { shift->{protocol} }
Subroutine protocol: not called CC=1 SCAR=6.9
Pod undocumented
44  
45 sub send_greeting {
46 0 ▶ my $self = shift;
Subroutine send_greeting: not called CC=1 SCAR=6.9
Pod undocumented
47 # Start with our greeting, which should receive back a nice list of features
48 0 $self->protocol->send_greeting;
49 }
50  
51 sub starttls {
52 0 ▶ my $self = shift;
Subroutine starttls: not called CC=2 SCAR=17.9
Pod undocumented
53 0 my %args = @_;
54 0 $self->debug_printf("STARTTLS");
55 0 ▶ die "This server does not support TLS" unless $self->has_feature('STARTTLS');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_feature("STARTTLS") 0 0 0
56  
57 0 require IO::Async::SSL;
58 $self->protocol->starttls->then(sub {
59 $self->loop->SSL_upgrade(
60 handle => $self,
61 # SSL_verify_mode => SSL_VERIFY_NONE,
62 %args,
63 )->on_done(sub {
64 0 ▶ $self->debug_printf("STARTTLS successful");
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 })
66 ->then($self->curry::send_greeting)
67 0 ▶ ->transform(done => sub { $self });
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 0 });
69 }
70  
71 sub on_read {
72 0 ▶ my ($self, $buffref) = @_;
Subroutine on_read: not called CC=3 SCAR=24.8
Pod documented
73 0 ▶ while( $$buffref =~ s/^(.*)\x0D\x0A// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$buffref =~ s/^(.*)\x0D\x0A//) 0 0 0
74 0 my $line = $1;
75 0 ▶ if($self->{sending_content}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sending_content'}) { } 0 0 0
76 0 warn "- this is awkward; we shouldn't have anything because we're in the middle of sending: $1";
77 } else {
78 0 $self->protocol->handle_line($line);
79 }
80 }
81 0 return 0;
82 }
83  
84 0 ▶sub has_feature { my $self = shift; $self->protocol->has_feature(@_) }
Subroutine has_feature: not called CC=1 SCAR=6.9
Pod undocumented
85 0 ▶sub send { my $self = shift; $self->protocol->send(@_) }
Subroutine send: not called CC=1 SCAR=6.9
Pod undocumented
86 0 ▶sub login { my $self = shift; $self->protocol->login(@_) }
Subroutine login: not called CC=1 SCAR=6.9
Pod undocumented
87  
88 2 1;
89  
90 =head1 AUTHOR
91  
92 Tom Molesworth <cpan@entitymodel.com>
93  
94 =head1 LICENSE
95  
96 Copyright Tom Molesworth 2012-2014. Licensed under the same terms as Perl itself.
« SMTP/Client.pm ↑ Summary SMTP.pm »