blib/lib/MMS/Mail/Provider/UKVodafone.pm

filter: Statementstmt 37.7% 20 / 53 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 31.0% 27 / 87 CC 17 SCAR 54.2
CC
17
Cov
27%
parse
306.0
BEGIN
1.0
BEGIN
1.0
CRAP 226.4
↑ Summary
1 package MMS::Mail::Provider::UKVodafone;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base 'MMS::Mail::Provider';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use MIME::Entity;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use MMS::Mail::Message::Parsed;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use HTML::TableExtract;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 NAME
13  
14 MMS::Mail::Provider::UKVodafone - This provides a class for parsing an MMS::Mail::Message object that has been sent via the UK Vodafone network.
15  
16 =head1 VERSION
17  
18 Version 0.07
19  
20 =cut
21  
22 2 our $VERSION = '0.07';
23  
24 =head1 SYNOPSIS
25  
26 This class provides a parse method for parsing an MMS::Mail::Message object into an MMS::Mail::Message::Parsed object for MMS messages sent from the UK Vodafone network.
27  
28 =head1 METHODS
29  
30 The following are the top-level methods of the MMS::Mail::Parser::UKVodafone class.
31  
32 =head2 Constructor
33  
34 =over
35  
36 =item C<new()>
37  
38 Return a new MMS::Mail::Provider::UKVodafone object.
39  
40 =back
41  
42 =head2 Regular Methods
43  
44 =over
45  
46 =item C<parse> MMS::Mail::Message
47  
48 The C<parse> method is called as an instance method. It parses the MMS::Mail::Message object and returns an MMS::Mail::Message::Parsed object.
49  
50 =back
51  
52 =head1 AUTHOR
53  
54 Rob Lee, C<< <robl at robl.co.uk> >>
55  
56 =head1 BUGS
57  
58 Please report any bugs or feature requests to
59 C<bug-mms-mail-provider-ukvodafone@rt.cpan.org>, or through the web interface at
60 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MMS-Mail-Provider-UKVodafone>.
61 I will be notified, and then you'll automatically be notified of progress on
62 your bug as I make changes.
63  
64 =head1 NOTES
65  
66 Please read the Perl artistic license ('perldoc perlartistic') :
67  
68 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
69 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
70 OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
71  
72 =head1 ACKNOWLEDGEMENTS
73  
74 As per usual this module is sprinkled with a little Deb magic.
75  
76 =head1 COPYRIGHT & LICENSE
77  
78 Copyright 2005 Rob Lee, all rights reserved.
79  
80 This program is free software; you can redistribute it and/or modify it
81 under the same terms as Perl itself.
82  
83 =head1 SEE ALSO
84  
85 L<MMS::Mail::Message>, L<MMS::Mail::Message::Parsed>, L<MMS::Mail::Provider>
86  
87 =cut
88  
89 0 ▶sub parse {
Subroutine parse: not called CC=17 SCAR=57.2
Pod documented
90  
91 0 my $self = shift;
92 0 my $message = shift;
93  
94 0 ▶ unless (defined $message) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $message) 0 0 0
95 0 return undef;
96 }
97  
98 0 my $parsed = new MMS::Mail::Message::Parsed(message=>$message);
99  
100 0 my $htmltext=undef;
101 0 foreach my $element (@{$parsed->attachments}) {
102 0 ▶ if ($element->mime_type eq 'text/html') {
Branch: 3 branches
BranchTrueFalseTotal
if ($element->mime_type eq 'text/html') { } 0 0 0
elsif ($element->mime_type =~ /jpeg$/) { } 0 0 0
elsif ($element->mime_type =~ /^video/) { } 0 0 0
103 0 $htmltext = $element->bodyhandle->as_string;
104 } elsif ($element->mime_type =~ /jpeg$/) {
105 0 my $header = $element->head;
106 0 ▶ if ($header->recommended_filename() !~ /(images\/vf3\.jpg|images\/vf4\.jpg|images\/vf6\.jpg)/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($header->recommended_filename =~ m[(images/vf3\.jpg|images/vf4\.jpg|images/vf6\.jpg)]) 0 0 0
107 0 $parsed->add_image($element);
108 }
109 } elsif ($element->mime_type =~ /^video/) {
110 0 $parsed->add_video($element);
111 }
112 }
113  
114 0 ▶ unless (defined $htmltext) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $htmltext) 0 0 0
115 0 return undef;
116 }
117  
118 0 my $te1 = new HTML::TableExtract( depth => 0, count => 3 );
119 0 $te1->parse($htmltext);
120 0 foreach my $ts1 ($te1->table_states) {
121 0 foreach my $row1 ($ts1->rows) {
122 0 foreach my $ele (@$row1) {
123 0 ▶ if ((defined $ele) && ($ele ne '')) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ele and $ele ne "") 0 0 0
Condition0%0/3
defined $ele and $ele ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ele and $ele ne ""
defined $ele $ele ne ""
Truth table0%0/3
A and B
A= defined $eleB= $ele ne ""
ABresult
0X0
100
111
124 0 $parsed->header_subject($ele);
125 }
126 }
127 }
128 }
129  
130 0 my $te2 = new HTML::TableExtract( depth => 1, count => 0 );
131 0 $te2->parse($htmltext);
132 0 my $text;
133 0 foreach my $ts2 ($te2->table_states) {
134 0 foreach my $row2 ($ts2->rows) {
135 0 $text = join('\n', @$row2);
136 }
137 0 ▶ if ((defined $text) && $text ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $text and $text ne "") 0 0 0
Condition0%0/3
defined $text and $text ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $text and $text ne ""
defined $text $text ne ""
Truth table0%0/3
A and B
A= defined $textB= $text ne ""
ABresult
0X0
100
111
138 0 $parsed->body_text($text);
139 }
140 }
141  
142 # Set mobile number property to a VALID number
143 0 $parsed->phone_number($self->retrieve_phone_number($parsed->header_from));
144 0 return $parsed;
145  
146 }
147  
148  
149 2 1; # End of MMS::Mail::Provider::UKVodafone
↑ Summary