Permalink
Browse files

SprintUS syntax fixes

  • Loading branch information...
Zbigniew Lukasiak
Zbigniew Lukasiak committed Aug 31, 2011
1 parent 462de6c commit a67c1bbaf6e8f678d2fe2551489777d8ba8a01f9
Showing with 17 additions and 10 deletions.
  1. +1 −0 lib/Courriel/MMS.pm
  2. +4 −7 lib/Courriel/MMS/SprintUS.pm
  3. +1 −1 lib/Courriel/MMS/TmobileUS.pm
  4. +11 −2 t/test.t
View
@@ -14,6 +14,7 @@ my @subclasses = qw(
Courriel::MMS::MymtsRu
Courriel::MMS::TmobileUK
Courriel::MMS::TmobileUS
+Courriel::MMS::SprintUS
);
# --- Attributes ---
@@ -1,7 +1,7 @@
use strict;
use warnings;
-package Courriel::MMS::TmobileUK;
+package Courriel::MMS::SprintUS;
use namespace::autoclean;
use Moose;
use WWW::Mechanize;
@@ -16,7 +16,7 @@ sub match {
my $class = shift;
my $email = shift;
- return 1 if $email->from =~ /pm\.sprint\.com//;
+ return 1 if $email->from =~ /pm\.sprint\.com/;
return;
}
@@ -74,14 +74,11 @@ override 'get_mms_images' => sub {
$mech->get( $image_url ); # get the actual picture (can't use mechanize's follow_link stuff since the image is in a popup)
if( $mech->success && $mech->ct =~ m#^image/jpe?g# ) {
- push @images [ 'image.jpg' => $mech->content ];
+ push @images, [ 'image.jpg' => $mech->content ];
}
}
return @images;
-}
-
-
};
__PACKAGE__->meta()->make_immutable();
@@ -94,7 +91,7 @@ __END__
=head1 NAME
-Courriel::MMS::TmobileUK - L<Courriel> extension for dealing with MMS messages from T-mobile UK
+Courriel::MMS::SprintUS - L<Courriel> extension for dealing with MMS messages from Sprint US.
=head1 SYNOPSIS
@@ -37,7 +37,7 @@ __END__
=head1 NAME
-Courriel::MMS::TmobileUK - L<Courriel> extension for dealing with MMS messages from T-mobile UK
+Courriel::MMS::TmobileUS - L<Courriel> extension for dealing with MMS messages from T-mobile US
=head1 SYNOPSIS
View
@@ -16,18 +16,27 @@ is( scalar( @images ), 1, 'Logo filtered out' );
ok( $email->create_random_image_name( 'image/jpeg' ) =~ /\.jpg$/, 'random image extension' );
-$email = build_email(
+my $c_email = build_email(
subject('aaa'),
from('aaa@tmomail.net'),
to( 'example@example.com' ),
plain_body( 'test' ),
attach( file => 't/data/cool.gif', filename => 'masthead.gif' ),
);
-$email = Courriel::MMS->parse( text => $email->as_string );
+$email = Courriel::MMS->parse( text => $c_email->as_string );
isa_ok( $email, 'Courriel::MMS::TmobileUS', 'MMS from tmomail.net' );
@images = $email->get_mms_images;
is( scalar( @images ), 0, 'Logo filtered out' );
+$c_email = build_email(
+ subject('aaa'),
+ from( 'aaa@pm.sprint.com' ),
+ to( 'example@example.com' ),
+ plain_body( 'test' ),
+);
+$email = Courriel::MMS->parse( text => $c_email->as_string );
+isa_ok( $email, 'Courriel::MMS::SprintUS', 'MMS from sprint' );
+
done_testing();

0 comments on commit a67c1bb

Please sign in to comment.