File Coverage

blib/lib/Mail/Karmasphere/Parser/RBL/Mixed.pm
Criterion Covered Total %
statement 22 25 88.0
branch 3 4 75.0
condition n/a
subroutine 6 7 85.7
pod 0 2 0.0
total 31 38 81.5


line stmt bran cond sub pod time code
1             package Mail::Karmasphere::Parser::RBL::Mixed;
2              
3 2     2   2361 use strict;
  2         5  
  2         80  
4 2     2   11 use warnings;
  2         3  
  2         227  
5 2     2   12 use base 'Mail::Karmasphere::Parser::RBL::Base';
  2         3  
  2         775  
6 2     2   12 use Mail::Karmasphere::Parser::Record;
  2         4  
  2         386  
7              
8 1     1   11 sub _streams { qw(ip4 domain) }
9              
10 0     0 0 0 sub my_format { "rbl.mixed" } # if the source table's "magic" field is rbl.mixed, this module deals with it.
11              
12             sub tweaks {
13 12     12 0 13 my $self = shift;
14 12         13 my $identity = shift;
15             # if it's a domain identity, we output to the domain stream.
16             # if it's an ip4 identity, we output to the ip4 stream.
17 12         32 my $type = Mail::Karmasphere::Parser::Record::guess_identity_type($identity);
18 12         17 my $stream;
19 12 100       24 if ($type eq "ip4") {
    50          
20 6         13 $stream = 0;
21             # in an rbl.mixed input file, we'll find things like "4.3.2.1".
22             # we want to return "1.2.3.4".
23 6         20 $identity = join ".", reverse split /\./, $identity;
24             }
25             elsif ($type eq "domain") {
26 6         7 $stream = 1;
27             }
28             else {
29 0         0 $self->warning("guessed type=$type for identity=$identity, skipping.");
30 0         0 return;
31             }
32              
33 12         49 return ($type, $stream, $identity);
34             }
35              
36              
37             1;