File Coverage

blib/lib/App/SpamcupNG/Warning.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 4 4 100.0
pod 2 2 100.0
total 32 32 100.0


line stmt bran cond sub pod time code
1             package App::SpamcupNG::Warning;
2 13     13   107714 use strict;
  13         36  
  13         351  
3 13     13   66 use warnings;
  13         28  
  13         3357  
4              
5             our $VERSION = '0.016'; # VERSION
6              
7             =head1 NAME
8              
9             App::SpamcupNG::Warning - representation of warnings messages parsed from
10             Spamcop website HTML.
11              
12             =head1 SYNOPSIS
13              
14             use parent 'App::SpamcupNG::Warning';
15              
16             =head1 DESCRIPTION
17              
18             This is a superclass for warning messages parsed from Spamcop website HTML.
19              
20             =head1 METHODS
21              
22             =head2 new
23              
24             Creates a new instance of a warning. Shouldn't be used directly, instead look
25             for subclasses of C<App::SpamcupNG::Warning>.
26              
27             Expects as parameter an array reference containing the associated strings.
28              
29             =cut
30              
31             sub new {
32 6     6 1 2430 my ( $class, $message_ref ) = @_;
33              
34             die 'message must be an array reference with length of at least 1'
35             unless ( ( ref($message_ref) eq 'ARRAY' )
36 6 100 100     50 and ( scalar( @{$message_ref} ) > 0 ) );
  5         30  
37              
38 4         8 my @trimmed;
39              
40 4         8 foreach my $msg ( @{$message_ref} ) {
  4         11  
41 5         26 $msg =~ s/^\s+//;
42 5         72 $msg =~ s/(\s+)?\.?$//;
43 5         20 push( @trimmed, $msg );
44             }
45              
46 4         17 my $self = { message => \@trimmed };
47 4         10 bless( $self, $class );
48 4         23 return $self;
49             }
50              
51             =head2 message
52              
53             Returns the associated message as a string.
54              
55             =cut
56              
57             sub message {
58 2     2 1 1043 my $self = shift;
59 2         5 return join( '. ', @{ $self->{message} } ) . '.';
  2         21  
60             }
61              
62             =head1 AUTHOR
63              
64             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>
65              
66             =head1 COPYRIGHT AND LICENSE
67              
68             This software is copyright (c) 2018 of Alceu Rodrigues de Freitas Junior,
69             E<lt>arfreitas@cpan.orgE<gt>
70              
71             This file is part of App-SpamcupNG distribution.
72              
73             App-SpamcupNG is free software: you can redistribute it and/or modify it under
74             the terms of the GNU General Public License as published by the Free Software
75             Foundation, either version 3 of the License, or (at your option) any later
76             version.
77              
78             App-SpamcupNG is distributed in the hope that it will be useful, but WITHOUT
79             ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
80             FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
81              
82             You should have received a copy of the GNU General Public License along with
83             App-SpamcupNG. If not, see <http://www.gnu.org/licenses/>.
84              
85             =cut
86              
87             1;