File Coverage

blib/lib/Mail/Message/Head/Partial.pm
Criterion Covered Total %
statement 29 72 40.2
branch 2 20 10.0
condition 2 6 33.3
subroutine 7 11 63.6
pod 6 6 100.0
total 46 115 40.0


line stmt bran cond sub pod time code
1             # Copyrights 2001-2023 by [Mark Overmeer ].
2             # For other contributors see ChangeLog.
3             # See the manual pages for details on the licensing terms.
4             # Pod stripped from pm file by OODoc 2.03.
5             # This code is part of distribution Mail-Message. Meta-POD processed with
6             # OODoc into POD and HTML manual-pages. See README.md
7             # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8              
9             package Mail::Message::Head::Partial;
10 38     38   265 use vars '$VERSION';
  38         78  
  38         2094  
11             $VERSION = '3.013';
12              
13 38     38   295 use base 'Mail::Message::Head::Complete';
  38         131  
  38         4430  
14              
15 38     38   538 use strict;
  38         112  
  38         1029  
16 38     38   235 use warnings;
  38         86  
  38         1350  
17              
18 38     38   250 use Scalar::Util 'weaken';
  38         127  
  38         27565  
19              
20              
21             sub removeFields(@)
22 89     89 1 163 { my $self = shift;
23 89         634 my $known = $self->{MMH_fields};
24              
25 89         210 foreach my $match (@_)
26             {
27 176 100       377 if(ref $match)
28 88   66     827 { $_ =~ $match && delete $known->{$_} foreach keys %$known }
29 88         230 else { delete $known->{lc $match} }
30             }
31              
32 89         255 $self->cleanupOrderedFields;
33             }
34              
35              
36             sub removeFieldsExcept(@)
37 0     0 1 0 { my $self = shift;
38 0         0 my $known = $self->{MMH_fields};
39 0         0 my %remove = map { ($_ => 1) } keys %$known;
  0         0  
40              
41 0         0 foreach my $match (@_)
42 0 0       0 { if(ref $match)
43 0   0     0 { $_ =~ $match && delete $remove{$_} foreach keys %remove;
44             }
45 0         0 else { delete $remove{lc $match} }
46             }
47              
48 0         0 delete @$known{ keys %remove };
49              
50 0         0 $self->cleanupOrderedFields;
51             }
52              
53              
54             sub removeResentGroups()
55 0     0 1 0 { my $self = shift;
56 0         0 require Mail::Message::Head::ResentGroup;
57              
58 0         0 my $known = $self->{MMH_fields};
59 0         0 my $found = 0;
60 0         0 foreach my $name (keys %$known)
61 0 0       0 { next unless Mail::Message::Head::ResentGroup
62             ->isResentGroupFieldName($name);
63 0         0 delete $known->{$name};
64 0         0 $found++;
65             }
66              
67 0         0 $self->cleanupOrderedFields;
68 0 0       0 $self->modified(1) if $found;
69 0         0 $found;
70             }
71              
72              
73             sub removeListGroup()
74 0     0 1 0 { my $self = shift;
75 0         0 require Mail::Message::Head::ListGroup;
76              
77 0         0 my $known = $self->{MMH_fields};
78 0         0 my $found = 0;
79 0         0 foreach my $name (keys %$known)
80 0 0       0 { next unless Mail::Message::Head::ListGroup->isListGroupFieldName($name);
81 0         0 delete $known->{$name};
82 0         0 $found++;
83             }
84              
85 0 0       0 $self->cleanupOrderedFields if $found;
86 0 0       0 $self->modified(1) if $found;
87 0         0 $found;
88             }
89              
90              
91             sub removeSpamGroups()
92 0     0 1 0 { my $self = shift;
93 0         0 require Mail::Message::Head::SpamGroup;
94              
95 0         0 my $known = $self->{MMH_fields};
96 0         0 my $found = 0;
97 0         0 foreach my $name (keys %$known)
98 0 0       0 { next unless Mail::Message::Head::SpamGroup->isSpamGroupFieldName($name);
99 0         0 delete $known->{$name};
100 0         0 $found++;
101             }
102              
103 0 0       0 $self->cleanupOrderedFields if $found;
104 0 0       0 $self->modified(1) if $found;
105 0         0 $found;
106             }
107              
108              
109             sub cleanupOrderedFields()
110 89     89 1 155 { my $self = shift;
111 89         137 my @take = grep { defined $_ } @{$self->{MMH_order}};
  267         598  
  89         218  
112 89         435 weaken($_) foreach @take;
113 89         236 $self->{MMH_order} = \@take;
114 89         251 $self;
115             }
116              
117             #------------------------------------------
118              
119              
120             1;