line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::Role::Scoring; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
8392
|
use Moose::Role; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
133
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.23'; # VERSION |
6
|
|
|
|
|
|
|
# ABSTRACT: role for plugins using scoring |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'score_field' => ( |
9
|
|
|
|
|
|
|
is => 'ro', isa => 'Str', default => 'score', |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _get_score { |
13
|
22
|
|
|
22
|
|
51
|
my ( $self, $r ) = @_; |
14
|
22
|
|
|
|
|
1047
|
my $session = $r->session; |
15
|
22
|
100
|
|
|
|
1042
|
if( defined $session->{$self->score_field} ) { |
16
|
16
|
|
|
|
|
764
|
return $session->{$self->score_field}; |
17
|
|
|
|
|
|
|
} |
18
|
6
|
|
|
|
|
20
|
return 0; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _set_score { |
22
|
19
|
|
|
19
|
|
44
|
my ( $self, $r, $value ) = @_; |
23
|
19
|
|
|
|
|
771
|
my $session = $r->session; |
24
|
19
|
|
|
|
|
866
|
return $session->{$self->score_field} = $value; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _push_score_detail { |
28
|
19
|
|
|
19
|
|
57
|
my ( $self, $r, $string ) = @_; |
29
|
19
|
|
|
|
|
785
|
my $session = $r->session; |
30
|
19
|
|
|
|
|
931
|
my $field = $self->score_field . '_detail'; |
31
|
19
|
100
|
|
|
|
89
|
if( ! defined $session->{$field} ) { |
32
|
6
|
|
|
|
|
19
|
$session->{$field} = $string; |
33
|
6
|
|
|
|
|
19
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
13
|
|
|
|
|
256
|
$session->{$field} .= ', '.$string; |
36
|
13
|
|
|
|
|
156
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _get_score_detail { |
40
|
3
|
|
|
3
|
|
5
|
my ( $self, $r ) = @_; |
41
|
3
|
|
|
|
|
118
|
my $field = $self->score_field . '_detail'; |
42
|
3
|
|
|
|
|
124
|
return( $r->session->{$field} ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub add_score { |
46
|
19
|
|
|
19
|
0
|
1407
|
my ( $self, $r, $key, $value ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
19
|
|
|
|
|
96
|
my $score = $self->_get_score($r); |
49
|
19
|
|
|
|
|
52
|
$score += $value; |
50
|
19
|
|
|
|
|
85
|
$self->_set_score($r, $score); |
51
|
|
|
|
|
|
|
|
52
|
19
|
|
|
|
|
168
|
$self->_push_score_detail($r, $key.'='.$value); |
53
|
|
|
|
|
|
|
|
54
|
19
|
|
|
|
|
78
|
return $score; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding UTF-8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Mail::MtPolicyd::Plugin::Role::Scoring - role for plugins using scoring |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
version 1.23 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is free software, licensed under: |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |