line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::SpamcupNG::Warning::Factory; |
2
|
12
|
|
|
12
|
|
79
|
use strict; |
|
12
|
|
|
|
|
28
|
|
|
12
|
|
|
|
|
340
|
|
3
|
12
|
|
|
12
|
|
74
|
use warnings; |
|
12
|
|
|
|
|
37
|
|
|
12
|
|
|
|
|
323
|
|
4
|
12
|
|
|
12
|
|
59
|
use Exporter 'import'; |
|
12
|
|
|
|
|
37
|
|
|
12
|
|
|
|
|
382
|
|
5
|
|
|
|
|
|
|
|
6
|
12
|
|
|
12
|
|
4870
|
use App::SpamcupNG::Warning; |
|
12
|
|
|
|
|
34
|
|
|
12
|
|
|
|
|
354
|
|
7
|
12
|
|
|
12
|
|
4827
|
use App::SpamcupNG::Warning::Yum; |
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
1872
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.016'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
App::SpamcupNG::Warning::Factory - a factory design pattern to create warnings. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use App::SpamcupNG::Warning::Factory qw(create_warning); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This is a factory to create warnings. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
It should be used instead of creating new instances manually. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT_OK = qw(create_warning); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $yum_regex = qr/^Yum/; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 EXPORTS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Only C<create_warning> is exported by request. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 FUNCTIONS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 create_warning |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Creates a new instance of App::SpamcupNG::Warning or one of it's subclasses. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Expects as parameters an array reference with the warning message lines. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Returns the instance. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub create_warning { |
49
|
2
|
|
|
2
|
1
|
4
|
my $message_ref = shift; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
die 'message must be an array reference' |
52
|
|
|
|
|
|
|
unless ( ( ref($message_ref) eq 'ARRAY' ) |
53
|
2
|
50
|
33
|
|
|
9
|
and ( scalar( @{$message_ref} ) > 0 ) ); |
|
2
|
|
|
|
|
8
|
|
54
|
|
|
|
|
|
|
|
55
|
2
|
100
|
|
|
|
35
|
return App::SpamcupNG::Warning::Yum->new($message_ref) |
56
|
|
|
|
|
|
|
if ( $message_ref->[0] =~ $yum_regex ); |
57
|
1
|
|
|
|
|
11
|
return App::SpamcupNG::Warning->new($message_ref); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This software is copyright (c) 2018 of Alceu Rodrigues de Freitas Junior, |
67
|
|
|
|
|
|
|
E<lt>arfreitas@cpan.orgE<gt> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This file is part of App-SpamcupNG distribution. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
App-SpamcupNG is free software: you can redistribute it and/or modify it under |
72
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
73
|
|
|
|
|
|
|
Foundation, either version 3 of the License, or (at your option) any later |
74
|
|
|
|
|
|
|
version. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
App-SpamcupNG is distributed in the hope that it will be useful, but WITHOUT |
77
|
|
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
78
|
|
|
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
81
|
|
|
|
|
|
|
App-SpamcupNG. If not, see <http://www.gnu.org/licenses/>. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |