| 1 | package SpamMonkey::Result; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | SpamMonkey::Result - Result object for spam test | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | if ($result->is_spam) { | ||
| 10 | $result->rewrite; | ||
| 11 | print $result->email->as_string; | ||
| 12 | } | ||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | This class provides utility methods for dealing with the results of a | ||
| 17 | SpamMonkey test. | ||
| 18 | |||
| 19 | =head1 METHODS | ||
| 20 | |||
| 21 | =head2 is_spam | ||
| 22 | |||
| 23 | Returns true if the message scores more than the required threshold. | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | sub is_spam { | ||
| 28 | my $self = shift; | ||
| 29 | $self->{score} > $self->{monkey}{conf}{settings}{required_score}; | ||
| 30 | } | ||
| 31 | |||
| 32 | =head2 hits | ||
| 33 | |||
| 34 | Returns a list of the names of rules that matched. | ||
| 35 | |||
| 36 | =head2 describe_hits | ||
| 37 | |||
| 38 | Returns a list of the descriptions of rules that matched. | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | sub hits { | ||
| 43 | my $self = shift; | ||
| 44 | @{$self->{matched}||[]}; | ||
| 45 | } | ||
| 46 | |||
| 47 | sub describe_hits { | ||
| 48 | my $self = shift; | ||
| 49 | map { $self->{monkey}{conf}{descriptions}{$_} || $_ } $self->hits | ||
| 50 | } | ||
| 51 | |||
| 52 | =head2 score | ||
| 53 | |||
| 54 | Returns the score for this test. | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | sub score { shift->{score} } | ||
| 59 | |||
| 60 | 1; |