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

filter: Statementstmt 35.9% 14 / 39 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 27.5% 19 / 69 CC 11 SCAR 45.8
CC
11
Cov
24%
parse
132.0
BEGIN
1.0
BEGIN
1.0
CRAP 97.1
↑ Summary
1 package MMS::Mail::Provider::UKVirgin;
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 MMS::Mail::Message::Parsed;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 MMS::Mail::Provider::UKVirgin - This provides a class for parsing an MMS::Mail::Message object that has been sent via the UK Virgin network.
13  
14 =head1 VERSION
15  
16 Version 0.05
17  
18 =cut
19  
20 2 our $VERSION = '0.05';
21  
22 =head1 SYNOPSIS
23  
24 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 Virgin network.
25  
26 =head1 METHODS
27  
28 The following are the top-level methods of the MMS::Mail::Parser::UKVirgin class.
29  
30 =head2 Constructor
31  
32 =over
33  
34 =item C<new()>
35  
36 Return a new MMS::Mail::Provider::UKVirgin object.
37  
38 =back
39  
40 =head2 Regular Methods
41  
42 =over
43  
44 =item C<parse> MMS::Mail::Message
45  
46 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.
47  
48 =back
49  
50 =head1 AUTHOR
51  
52 Rob Lee, C<< <robl at robl.co.uk> >>
53  
54 =head1 BUGS
55  
56 Please report any bugs or feature requests to
57 C<bug-mms-mail-provider-ukvirgin at rt.cpan.org>, or through the web interface at
58 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MMS-Mail-Provider-UKVirgin>.
59 I will be notified, and then you'll automatically be notified of progress on
60 your bug as I make changes.
61  
62 =head1 SUPPORT
63  
64 You can find documentation for this module with the perldoc command.
65  
66 perldoc MMS::Mail::Provider::UKVirgin
67  
68 You can also look for information at:
69  
70 =over 4
71  
72 =item * AnnoCPAN: Annotated CPAN documentation
73  
74 L<http://annocpan.org/dist/MMS-Mail-Provider-UKVirgin>
75  
76 =item * CPAN Ratings
77  
78 L<http://cpanratings.perl.org/d/MMS-Mail-Provider-UKVirgin>
79  
80 =item * RT: CPAN's request tracker
81  
82 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MMS-Mail-Provider-UKVirgin>
83  
84 =item * Search CPAN
85  
86 L<http://search.cpan.org/dist/MMS-Mail-Provider-UKVirgin>
87  
88 =back
89  
90 =head1 ACKNOWLEDGEMENTS
91  
92 =head1 COPYRIGHT & LICENSE
93  
94 Copyright 2006 Rob Lee, all rights reserved.
95  
96 This program is free software; you can redistribute it and/or modify it
97 under the same terms as Perl itself.
98  
99 =cut
100  
101 0 ▶sub parse {
Subroutine parse: not called CC=11 SCAR=48.8
Pod documented
102  
103 0 my $self = shift;
104 0 my $message = shift;
105  
106 0 ▶ unless (defined $message) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $message) 0 0 0
107 0 return undef;
108 }
109  
110 0 my $parsed = new MMS::Mail::Message::Parsed(message=>$message);
111  
112 0 my $text=undef;
113 0 foreach my $element (@{$parsed->attachments}) {
114 0 ▶ if ($element->mime_type eq 'text/plain') {
Branch: 3 branches
BranchTrueFalseTotal
if ($element->mime_type eq 'text/plain') { } 0 0 0
elsif ($element->mime_type =~ /jpeg$/) { } 0 0 0
elsif ($element->mime_type =~ /^video/) { } 0 0 0
115 0 my $header = $element->head;
116 0 ▶ if ((defined $header->recommended_filename) && ($header->recommended_filename eq 'mms.txt')) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $header->recommended_filename and $header->recommended_filename eq "mms.txt") 0 0 0
Condition0%0/3
defined $header->recommended_filename and $header->recommended_filename eq "mms.txt"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $header->recommended_filename and $header->recommended_filename eq "mms.txt"
defined $header->recommended_filename $header->recommended_filename eq "mms.txt"
Truth table0%0/3
A and B
A= defined $header->recommended_filenameB= $header->recommended_filename eq "mms.txt"
ABresult
0X0
100
111
117 0 $text = $element->bodyhandle->as_string;
118 }
119 } elsif ($element->mime_type =~ /jpeg$/) {
120 0 my $header = $element->head;
121 0 ▶ if ( (defined $header->recommended_filename) && ($header->recommended_filename ne '')) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $header->recommended_filename and $header->recommended_filename ne "") 0 0 0
Condition0%0/3
defined $header->recommended_filename and $header->recommended_filename ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $header->recommended_filename and $header->recommended_filename ne ""
defined $header->recommended_filename $header->recommended_filename ne ""
Truth table0%0/3
A and B
A= defined $header->recommended_filenameB= $header->recommended_filename ne ""
ABresult
0X0
100
111
122 0 $parsed->add_image($element);
123 }
124 } elsif ($element->mime_type =~ /^video/) {
125 0 $parsed->add_video($element);
126 }
127 }
128  
129 0 ▶ unless (defined $text) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $text) 0 0 0
130 0 return undef;
131 }
132  
133 0 $parsed->header_subject($message->header_subject);
134 0 $parsed->body_text($text);
135  
136 # Cleanup the header_from and set phone number
137 0 $parsed->header_from =~ /\"(.+)\"/;
138 0 $parsed->header_from($1);
139 0 my ($num,undef) = split(/@/, $parsed->header_from);
140 0 $parsed->phone_number($num);
141  
142 0 return $parsed;
143  
144 }
145  
146  
147 2 1; # End of MMS::Mail::Provider::UKVirgin
↑ Summary