line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::Role::Scoring; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
5878
|
use Moose::Role; |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
122
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '2.02'; # 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
|
|
37
|
my ( $self, $r ) = @_; |
14
|
22
|
|
|
|
|
620
|
my $session = $r->session; |
15
|
22
|
100
|
|
|
|
692
|
if( defined $session->{$self->score_field} ) { |
16
|
16
|
|
|
|
|
423
|
return $session->{$self->score_field}; |
17
|
|
|
|
|
|
|
} |
18
|
6
|
|
|
|
|
16
|
return 0; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _set_score { |
22
|
19
|
|
|
19
|
|
32
|
my ( $self, $r, $value ) = @_; |
23
|
19
|
|
|
|
|
479
|
my $session = $r->session; |
24
|
19
|
|
|
|
|
821
|
return $session->{$self->score_field} = $value; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _push_score_detail { |
28
|
19
|
|
|
19
|
|
33
|
my ( $self, $r, $string ) = @_; |
29
|
19
|
|
|
|
|
477
|
my $session = $r->session; |
30
|
19
|
|
|
|
|
520
|
my $field = $self->score_field . '_detail'; |
31
|
19
|
100
|
|
|
|
70
|
if( ! defined $session->{$field} ) { |
32
|
6
|
|
|
|
|
15
|
$session->{$field} = $string; |
33
|
6
|
|
|
|
|
12
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
13
|
|
|
|
|
139
|
$session->{$field} .= ', '.$string; |
36
|
13
|
|
|
|
|
113
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _get_score_detail { |
40
|
3
|
|
|
3
|
|
4
|
my ( $self, $r ) = @_; |
41
|
3
|
|
|
|
|
94
|
my $field = $self->score_field . '_detail'; |
42
|
3
|
|
|
|
|
69
|
return( $r->session->{$field} ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub add_score { |
46
|
19
|
|
|
19
|
0
|
1043
|
my ( $self, $r, $key, $value ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
19
|
|
|
|
|
57
|
my $score = $self->_get_score($r); |
49
|
19
|
|
|
|
|
34
|
$score += $value; |
50
|
19
|
|
|
|
|
57
|
$self->_set_score($r, $score); |
51
|
|
|
|
|
|
|
|
52
|
19
|
|
|
|
|
119
|
$self->_push_score_detail($r, $key.'='.$value); |
53
|
|
|
|
|
|
|
|
54
|
19
|
|
|
|
|
48
|
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 2.02 |
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 |