| 1 | package Net::SMTP::Verify::ResultSet; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | our $VERSION = '1.04'; # VERSION | |||||||||
| 6 | # ABSTRACT: resultset for Net::SMTP::Verify checks | ||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Net::SMTP::Verify::Result; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | has 'results' => ( | ||||||||||
| 15 | is => 'ro', isa => 'HashRef[Net::SMTP::Verify::Result]', lazy => 1, | ||||||||||
| 16 | 4 | ▶ | default => sub { {} }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 2 | traits => [ 'Hash' ], | |||||||||
| 18 | handles => { | ||||||||||
| 19 | 'recipient' => 'get', | ||||||||||
| 20 | 'recipients' => 'keys', | ||||||||||
| 21 | 'entries' => 'values', | ||||||||||
| 22 | 'count' => 'count', | ||||||||||
| 23 | }, | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | # install shortcuts | ||||||||||
| 27 | 2 | *rcpt = \&recipient; | |||||||||
| 28 | 2 | *rcpts = \&recipients; | |||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | 12 | ▶ | sub add_result { | ||||||||
|
Subroutine
add_result: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | 12 | my ( $self, $result ) = @_; | |||||||||
| 33 | 12 | $self->results->{$result->address} = $result; | |||||||||
| 34 | 12 | return; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | 24 | ▶ | sub set { | ||||||||
|
Subroutine
set: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 39 | 24 | my ( $self, $rcpts, $field, @params ) = @_; | |||||||||
| 40 | 24 | ▶ | if( ! ref $rcpts ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 18 | $rcpts = [ $rcpts ]; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 24 | foreach my $rcpt ( @$rcpts ) { | |||||||||
| 45 | 36 | my $result = $self->rcpt( $rcpt ); | |||||||||
| 46 | 36 | ▶ | if( ! defined $result ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 12 | $result = Net::SMTP::Verify::Result->new( | |||||||||
| 48 | address => $rcpt, | ||||||||||
| 49 | ); | ||||||||||
| 50 | 12 | $self->add_result( $result ); | |||||||||
| 51 | } | ||||||||||
| 52 | 36 | $result->$field( @params ); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 24 | return; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | sub dump { | ||||||||
|
Subroutine
dump: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 60 | 0 | my $self = shift; | |||||||||
| 61 | 0 | print Dumper $self->entries; | |||||||||
| 62 | 0 | return; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub dump_json { | ||||||||
|
Subroutine
dump_json: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 67 | 0 | my $self = shift; | |||||||||
| 68 | 0 | foreach my $rcpt ( $self->entries ) { | |||||||||
| 69 | 0 | print to_json { %$rcpt }, { | |||||||||
| 70 | pretty => 1, | ||||||||||
| 71 | }; | ||||||||||
| 72 | } | ||||||||||
| 73 | 0 | return; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub print_text { | ||||||||
|
Subroutine
print_text: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 78 | 0 | my $self = shift; | |||||||||
| 79 | |||||||||||
| 80 | 0 | foreach my $rcpt ( $self->entries ) { | |||||||||
| 81 | 0 | print $rcpt->{'address'}.":\n"; | |||||||||
| 82 | 0 | foreach my $field ( keys %$rcpt ) { | |||||||||
| 83 | 0 | ▶ | if( $field eq 'address') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 0 | next; | |||||||||
| 85 | } | ||||||||||
| 86 | 0 | print " $field: ".$rcpt->{$field}."\n"; | |||||||||
| 87 | } | ||||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 0 | return; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | |||||||||||
| 94 | 4 | ▶ | sub is_all_success { | ||||||||
|
Subroutine
is_all_success: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 95 | 4 | my $self = shift; | |||||||||
| 96 | |||||||||||
| 97 | 4 | foreach my $rcpt ( $self->entries ) { | |||||||||
| 98 | 10 | ▶ | if( ! $rcpt->is_success ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 2 | return 0; | |||||||||
| 100 | } | ||||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | 2 | return 1; | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | |||||||||||
| 107 | 3 | ▶ | sub successfull_rcpts { | ||||||||
|
Subroutine
successfull_rcpts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 108 | 3 | return grep { $_->is_success } shift->entries; | |||||||||
| 109 | } | ||||||||||
| 110 | 2 | *success_rcpts = \&successfull_rcpts; | |||||||||
| 111 | 0 | ▶ | sub error_rcpts { | ||||||||
|
Subroutine
error_rcpts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 112 | 0 | return grep { $_->is_error } shift->entries; | |||||||||
| 113 | } | ||||||||||
| 114 | 0 | ▶ | sub temp_error_rcpts { | ||||||||
|
Subroutine
temp_error_rcpts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 115 | 0 | return grep { $_->is_temp_error } shift->entries; | |||||||||
| 116 | } | ||||||||||
| 117 | 2 | ▶ | sub perm_error_rcpts { | ||||||||
|
Subroutine
perm_error_rcpts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 118 | 2 | return grep { $_->is_perm_error } shift->entries; | |||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | 2 | 1; | |||||||||
| 122 | |||||||||||
| 123 | __END__ | ||||||||||