MtPolicyd/Plugin.pm

filter: Statementstmt 84.2% 16 / 19 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 2 / 2 totaltotal 81.4% 22 / 27 CC 2 SCAR 4.9
CC
2
Cov
81%
log
2.1
run
2.0
BEGIN
1.0
CRAP 1.6
« MtPolicyd/Result.pm ↑ Summary MtPolicyd/Plugin/Role/PluginChain.pm »
1 package Mail::MtPolicyd::Plugin;
2  
3 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 our $VERSION = '1.11'; # VERSION
7 # ABSTRACT: a base class for plugins
8  
9  
10 10 has 'name' => ( is => 'rw', isa => 'Str', required => 1 );
11 10 has 'log_level' => ( is => 'ro', isa => 'Int', default => 4 );
12 10 has 'vhost_name' => ( is => 'ro', isa => 'Maybe[Str]' );
13  
14  
15 sub run {
16 0 ▶ my ( $self, $r ) = @_;
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
17 0 die('plugin did not implement run method!');
18 }
19  
20 sub log {
21 12 ▶ my ($self, $r, $msg) = @_;
Subroutine log: called CC=2 SCAR=7.4
Pod documented
22 12 ▶ if( defined $self->vhost_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->vhost_name) 0 12 12
23 0 $msg = $self->vhost_name.': '.$msg;
24 }
25 12 $r->log($self->log_level, $msg);
26  
27 12 return;
28 }
29  
30 10 __PACKAGE__->meta->make_immutable;
31  
32 10 1;
33  
34  
35 __END__
36 =pod
37  
38 =head1 NAME
39  
40 Mail::MtPolicyd::Plugin - a base class for plugins
41  
42 =head1 VERSION
43  
44 version 1.11
45  
46 =head1 ATTRIBUTES
47  
48 =head2 name
49  
50 Contains a string with the name of this plugin as specified in the configuration.
51  
52 =head2 log_level (default: 4)
53  
54 The log_level used when the plugin calls $self->log( $r, $msg ).
55  
56 =head1 METHODS
57  
58 =head2 run( $r )
59  
60 This method has be implemented by the plugin which inherits from this base class.
61  
62 =head2 log( $r, $msg )
63  
64 This method could be used by the plugin to log something.
65  
66 Since this is mostly for debugging the default is to log plugin specific
67 messages with log_level=4. (see log_level attribute)
68  
69 =head1 AUTHOR
70  
71 Markus Benning <ich@markusbenning.de>
72  
73 =head1 COPYRIGHT AND LICENSE
74  
75 This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
76  
77 This is free software, licensed under:
78  
79 The GNU General Public License, Version 2, June 1991
80  
81 =cut
82  
« MtPolicyd/Result.pm ↑ Summary MtPolicyd/Plugin/Role/PluginChain.pm »