| 1 | package Mail::Abuse::Filter; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 4 | require 5.005_62; | |||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 4 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | # The code below should be in a single line | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 4 | our $VERSION = do { my @r = (q$Revision: 1.5 $ =~ /\d+/g); sprintf " %d."."%03d" x $#r, @r }; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =pod | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | Mail::Abuse::Filter - Filter incidents depending on various criteria | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | package Mail::Abuse::Filter::MyFilter; | ||||||||||||||||||||
| 22 | use Mail::Abuse::Filter; | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | use base 'Mail::Abuse::Filter'; | ||||||||||||||||||||
| 25 | sub criteria { ... } | ||||||||||||||||||||
| 26 | package main; | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | my $f = new Mail::Abuse::Filter::MyFilter; | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | $report->filter([$f]); | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | This class allows for the specification of a set of restrictions | ||||||||||||||||||||
| 35 | placed on the C<Mail::Abuse::Incidents> that are considered | ||||||||||||||||||||
| 36 | interesting. Anything not interesting will be removed from a report. | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | The following functions are provided for the customization of the | ||||||||||||||||||||
| 39 | behavior of the class. | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =cut | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | sub new | ||||||||||||||||||||
| 44 | 9 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||
| 45 | 9 | my $type = shift; | |||||||||||||||||||
| 46 | 9 | ▶ | my $class = ref($type) || $type; | ||||||||||||||||||
|
Condition33%1/3
ref $type || $type
MC/DC0%0/2
ref $type || $type
ref $type
$type
Truth table33%1/3
A || B
A= ref $typeB= $type
| |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 9 | ▶ | croak "Invalid call to Mail::Abuse::Filter::new" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | unless $class; | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 9 | bless {}, $class; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =pod | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | =over | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =item C<criteria($report, $incident)> | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | This function receives a C<Mail::Abuse::Report> and a | ||||||||||||||||||||
| 61 | C<Mail::Abuse::Incident> object. It returns a true value if the | ||||||||||||||||||||
| 62 | incident should be handled or false otherwise. This function will be | ||||||||||||||||||||
| 63 | generally called by the C<Mail::Abuse::Report> object when requested | ||||||||||||||||||||
| 64 | to filter its events. | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | Derived classes must override this method. | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | sub criteria | ||||||||||||||||||||
| 71 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
criteria: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 72 | 0 | croak "Mail::Abuse::Filter is a virtual class"; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | sub AUTOLOAD | ||||||||||||||||||||
| 76 | 7 | ▶ | { | ||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 77 | 4 | ▶ | no strict "refs"; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 78 | 4 | ▶ | use vars qw($AUTOLOAD); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 79 | 7 | my $method = $AUTOLOAD; | |||||||||||||||||||
| 80 | 7 | $method =~ s/^.*:://; | |||||||||||||||||||
| 81 | *$method = sub | ||||||||||||||||||||
| 82 | 120 | ▶ | { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 83 | 120 | my $self = shift; | |||||||||||||||||||
| 84 | 120 | my $ret = $self->{$method}; | |||||||||||||||||||
| 85 | 120 | ▶ | if (@_) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 86 | { | ||||||||||||||||||||
| 87 | 10 | $ret = $self->{$method}; | |||||||||||||||||||
| 88 | 10 | $self->{$method} = shift; | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | 120 | return $ret; | |||||||||||||||||||
| 91 | 7 | }; | |||||||||||||||||||
| 92 | 7 | goto \&$method; | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | __END__ | ||||||||||||||||||||