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