r3225 - in /packages/libemail-send-perl/branches/upstream/current: ./ lib/Email/ lib/Email/Send/ t/ t/lib/ t/lib/Email/ t/lib/Email/Send/ util/

eloy at users.alioth.debian.org eloy at users.alioth.debian.org
Thu Jul 6 12:23:13 UTC 2006


Author: eloy
Date: Thu Jul  6 12:23:12 2006
New Revision: 3225

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=3225
Log:
Load /tmp/tmp.uMVHI30027/libemail-send-perl-2.11 into
packages/libemail-send-perl/branches/upstream/current.

Added:
    packages/libemail-send-perl/branches/upstream/current/t/foreign-mailer.t
    packages/libemail-send-perl/branches/upstream/current/t/lib/
    packages/libemail-send-perl/branches/upstream/current/t/lib/Email/
    packages/libemail-send-perl/branches/upstream/current/t/lib/Email/Send/
    packages/libemail-send-perl/branches/upstream/current/t/lib/Email/Send/OK.pm
    packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailer.pm
    packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailerOO.pm
    packages/libemail-send-perl/branches/upstream/current/t/no-import.t
    packages/libemail-send-perl/branches/upstream/current/t/object-mailer.t
Modified:
    packages/libemail-send-perl/branches/upstream/current/Changes
    packages/libemail-send-perl/branches/upstream/current/MANIFEST
    packages/libemail-send-perl/branches/upstream/current/META.yml
    packages/libemail-send-perl/branches/upstream/current/Makefile.PL
    packages/libemail-send-perl/branches/upstream/current/lib/Email/Send.pm
    packages/libemail-send-perl/branches/upstream/current/lib/Email/Send/IO.pm
    packages/libemail-send-perl/branches/upstream/current/t/sendmail.t
    packages/libemail-send-perl/branches/upstream/current/util/executable   (props changed)
    packages/libemail-send-perl/branches/upstream/current/util/sendmail   (props changed)

Modified: packages/libemail-send-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/Changes?rev=3225&op=diff
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/Changes (original)
+++ packages/libemail-send-perl/branches/upstream/current/Changes Thu Jul  6 12:23:12 2006
@@ -1,3 +1,16 @@
+2.11    2006-07-05
+
+  - fixed bug introduced in 2.10; message modifiers were broken
+    thanks ABH
+
+2.10    2006-07-03
+
+  - improve portability of sendmail.t (rjbs)
+  - fix bugs with plugins outside Email::Send:: (rjbs)
+  - allow objects as mailers (rjbs)
+  - clarify documentation (rjbs)
+  - improve backwards compat with Email::Send 1 (see no-import.t) (rjbs)
+
 2.05    2006-04-20
 
   - Removed UNIVERSAL::require use.

Modified: packages/libemail-send-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/MANIFEST?rev=3225&op=diff
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/MANIFEST (original)
+++ packages/libemail-send-perl/branches/upstream/current/MANIFEST Thu Jul  6 12:23:12 2006
@@ -14,8 +14,14 @@
 t/classic.t
 t/email-send-test.t
 t/email-send.t
+t/foreign-mailer.t
+t/no-import.t
+t/object-mailer.t
 t/sendmail.t
 t/test.t
+t/lib/Email/Send/OK.pm
+t/lib/OKMailer.pm
+t/lib/OKMailerOO.pm
 util/executable
 util/not-executable
 util/sendmail

Modified: packages/libemail-send-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/META.yml?rev=3225&op=diff
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/META.yml (original)
+++ packages/libemail-send-perl/branches/upstream/current/META.yml Thu Jul  6 12:23:12 2006
@@ -1,16 +1,17 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Email-Send
-version:      2.05
+version:      2.11
 version_from: lib/Email/Send.pm
 installdirs:  site
 requires:
     Class::Accessor::Fast:         0.19
     Email::Address:                1.80
     Email::Simple:                 1.92
-    Module::Pluggable:             2.8
+    Module::Pluggable:             2.97
     Return::Value:                 1.28
+    Scalar::Util:                  1.02
     Test::More:                    0.47
 
 distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+generated_by: ExtUtils::MakeMaker version 6.30

Modified: packages/libemail-send-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/Makefile.PL?rev=3225&op=diff
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/Makefile.PL (original)
+++ packages/libemail-send-perl/branches/upstream/current/Makefile.PL Thu Jul  6 12:23:12 2006
@@ -1,16 +1,17 @@
 use ExtUtils::MakeMaker;
 
 WriteMakefile (
-               AUTHOR        => 'Casey West <casey at geeknest.com>',
-               ABSTRACT      => "Simply Sending Email",
-               NAME          => 'Email::Send',
-               PREREQ_PM     => {
-                                 'Class::Accessor::Fast' => '0.19',
-                                 'Email::Address' => '1.80',
-                                 'Email::Simple' => '1.92',
-                                 'Module::Pluggable' => '2.8',
-                                 'Return::Value' => '1.28',
-                                 'Test::More' => '0.47',
-                                },
-               VERSION_FROM  => 'lib/Email/Send.pm',
-              );
+  AUTHOR        => 'Casey West <casey at geeknest.com>',
+  ABSTRACT      => "Simply Sending Email",
+  NAME          => 'Email::Send',
+  PREREQ_PM     => {
+    'Class::Accessor::Fast' => '0.19',
+    'Email::Address'    => '1.80',
+    'Email::Simple'     => '1.92',
+    'Module::Pluggable' => '2.97', # topic safety
+    'Return::Value'     => '1.28',
+    'Scalar::Util'      => '1.02',
+    'Test::More'        => '0.47',
+  },
+  VERSION_FROM  => 'lib/Email/Send.pm',
+);

Modified: packages/libemail-send-perl/branches/upstream/current/lib/Email/Send.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/lib/Email/Send.pm?rev=3225&op=diff
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/lib/Email/Send.pm (original)
+++ packages/libemail-send-perl/branches/upstream/current/lib/Email/Send.pm Thu Jul  6 12:23:12 2006
@@ -1,14 +1,14 @@
 package Email::Send;
-# $Id: Send.pm,v 1.17 2006/04/20 15:39:06 cwest Exp $
 use strict;
 
 use vars qw[$VERSION];
-$VERSION   = '2.05';
+$VERSION   = '2.11';
 
 use base qw[Class::Accessor::Fast];
 use Email::Simple;
 use Module::Pluggable search_path => 'Email::Send';
 use Return::Value;
+use Scalar::Util ();
 
 =head1 NAME
 
@@ -56,7 +56,7 @@
 
 =item new()
 
-  my $mailer = Email::Send->new({
+  my $sender = Email::Send->new({
       mailer      => 'NNTP',
       mailer_args => [ Host => 'nntp.example.com' ],
   });
@@ -113,7 +113,7 @@
 
 =item send()
 
-  my $result = $mailer->send($message, @modifier_args);
+  my $result = $sender->send($message, @modifier_args);
 
 Send a message using the predetermined mailer and mailer arguments. If you
 have defined a C<message_modifier> it will be called prior to sending.
@@ -128,11 +128,12 @@
 =cut
 
 sub send {
-    my ($self, $message, @args) = @_;
-    my $simple = $self->_objectify_message($message);
-    return failure "No message found." unless $simple;
-
-	$self->message_modifier(
+  goto &_send_function unless eval { $_[0]->isa('Email::Send') };
+  my ($self, $message, @args) = @_;
+  my $simple = $self->_objectify_message($message);
+  return failure "No message found." unless $simple;
+
+	$self->message_modifier->(
 		$self, $simple,
 		@args,
 	) if $self->message_modifier;
@@ -146,7 +147,7 @@
 
 =item all_mailers()
 
-  my @available = $mailer->all_mailers;
+  my @available = $sender->all_mailers;
 
 Returns a list of availabe mailers. These are mailers that are
 installed on your computer and register themselves as available.
@@ -165,8 +166,8 @@
 =item mailer_available()
 
   # is SMTP over SSL avaialble?
-  $mailer->mailer('SMTP')
-    if $mailer->mailer_available('SMTP', ssl => 1);
+  $sender->mailer('SMTP')
+    if $sender->mailer_available('SMTP', ssl => 1);
 
 Given the name of a mailer, such as C<SMTP>, determine if it is
 available. Any additional arguments passed to this method are passed
@@ -177,16 +178,18 @@
 =cut
 
 sub mailer_available {
-	my ($self, $mailer, @args) = @_;
-	if ( my $package = $self->_plugin_list->{$mailer} ) {
-	    eval "CORE::require $package" or return failure $@;
-	    $package->can('is_available')
-	      or return failure "Mailer $mailer doesn't report availability.";
-		my $test = $package->is_available(@args);
-		return $test unless $test;
-		return success;
-	}
-	return failure "Mailer $mailer not found.";
+  my ($self, $mailer, @args) = @_;
+
+  my $invocant = $self->_mailer_invocant($mailer);
+
+  return $invocant unless $invocant;
+
+  $invocant->can('is_available')
+    or return failure "Mailer $mailer doesn't report availability.";
+
+  my $test = $invocant->is_available(@args);
+  return $test unless $test;
+  return success;
 }
 
 sub _objectify_message {
@@ -199,14 +202,29 @@
     return undef;
 }
 
+sub _mailer_invocant {
+  my ($self, $mailer) = @_;
+
+  return $mailer if Scalar::Util::blessed($mailer);
+
+  # is the mailer a plugin given by short name?
+  my $package = exists $self->_plugin_list->{$mailer}
+               ? $self->_plugin_list->{$mailer}
+               : $mailer;
+
+  eval "require $package" or return failure "$@";
+
+  return $package;
+}
+
 sub _send_it {
-	my ($self, $mailer, $message) = @_;
-	my $test = $self->mailer_available($mailer);
-	return $test unless $test;
-
-    my $package = $self->_plugin_list->{$mailer};
-    eval "CORE::require $package" or return failure;
-	return $package->send($message, @{$self->mailer_args});
+    my ($self, $mailer, $message) = @_;
+    my $test = $self->mailer_available($mailer);
+    return $test unless $test;
+
+    my $invocant = $self->_mailer_invocant($mailer);
+
+    return $invocant->send($message, @{$self->mailer_args});
 }
 
 sub _try_all {
@@ -259,7 +277,7 @@
 to implement a single function, C<send>. It will be called from
 C<Email::Send> exactly like this.
 
-  Your::Sending::Package::send($message, @args);
+  Your::Sending::Package->send($message, @args);
 
 C<$message> is an Email::Simple object, C<@args> are the extra
 arguments passed into C<Email::Send::send>.
@@ -277,7 +295,7 @@
   }
 
   sub send {
-      my ($message, @args);
+      my ($class, $message, @args);
 
 	  use LWP::UserAgent;
 
@@ -296,12 +314,12 @@
 This example will keep a UserAgent singleton unless new arguments are
 passed to C<send>. It is used by calling C<Email::Send::send>.
 
-  my $mailer = Email::Send->new({ mailer => 'HTTP::Post' });
-  
-  $mailer->mailer_args([ 'http://example.com/incoming', 'message' ]);
-
-  $mailer->send($message);
-  $mailer->send($message2); # uses saved $URL and $FIELD
+  my $sender = Email::Send->new({ mailer => 'HTTP::Post' });
+  
+  $sender->mailer_args([ 'http://example.com/incoming', 'message' ]);
+
+  $sender->send($message);
+  $sender->send($message2); # uses saved $URL and $FIELD
 
 =head1 SEE ALSO
 

Modified: packages/libemail-send-perl/branches/upstream/current/lib/Email/Send/IO.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/lib/Email/Send/IO.pm?rev=3225&op=diff
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/lib/Email/Send/IO.pm (original)
+++ packages/libemail-send-perl/branches/upstream/current/lib/Email/Send/IO.pm Thu Jul  6 12:23:12 2006
@@ -1,5 +1,4 @@
 package Email::Send::IO;
-# $Id: IO.pm,v 1.7 2006/04/20 15:39:06 cwest Exp $
 use strict;
 
 use Return::Value;

Added: packages/libemail-send-perl/branches/upstream/current/t/foreign-mailer.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/t/foreign-mailer.t?rev=3225&op=file
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/t/foreign-mailer.t (added)
+++ packages/libemail-send-perl/branches/upstream/current/t/foreign-mailer.t Thu Jul  6 12:23:12 2006
@@ -1,0 +1,27 @@
+use Test::More qw[no_plan];
+# $Id: classic.t,v 1.1 2006/01/17 22:11:38 cwest Exp $
+use strict;
+$^W =1;
+
+BEGIN {
+  use_ok 'Email::Send';
+}
+
+use Email::Send;
+use lib 't/lib';
+
+my $message = <<'.';
+From: rjbs at foo.bar
+To: rjbs at baz.boo
+Subject: test message
+Date: Thu, 2 Feb 2006 21:51:53 -0500
+
+This is a test, a what, a test, a what, a test, oh, a test!
+.
+
+my $sender = Email::Send->new({ mailer => 'OKMailer' });
+
+my $rv = $sender->send($message);
+
+ok($rv, "message sending returned success");
+

Added: packages/libemail-send-perl/branches/upstream/current/t/lib/Email/Send/OK.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/t/lib/Email/Send/OK.pm?rev=3225&op=file
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/t/lib/Email/Send/OK.pm (added)
+++ packages/libemail-send-perl/branches/upstream/current/t/lib/Email/Send/OK.pm Thu Jul  6 12:23:12 2006
@@ -1,0 +1,14 @@
+package Email::Send::OK;
+
+use Test::More;
+
+use strict;
+use warnings;
+
+sub is_available { 1 }
+
+sub send {
+  ok(1, "send message $_[0]");
+}
+
+1;

Added: packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailer.pm?rev=3225&op=file
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailer.pm (added)
+++ packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailer.pm Thu Jul  6 12:23:12 2006
@@ -1,0 +1,13 @@
+## our out-of-namespace mailer:
+package OKMailer;
+use Test::More;
+
+sub is_available { 1 }
+
+sub send {
+  my ($mailer, $message) = @_;
+
+  ok(1, "send $message");
+}
+
+1;

Added: packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailerOO.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailerOO.pm?rev=3225&op=file
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailerOO.pm (added)
+++ packages/libemail-send-perl/branches/upstream/current/t/lib/OKMailerOO.pm Thu Jul  6 12:23:12 2006
@@ -1,0 +1,17 @@
+## our out-of-namespace mailer:
+package OKMailerOO;
+use Test::More;
+
+sub new { return bless {} => shift; }
+
+sub is_available { 1 }
+
+sub send {
+  my ($self, $message) = @_;
+
+  ok(1, "mailer $self sent $message");
+
+  return 0 + $self;
+}
+
+1;

Added: packages/libemail-send-perl/branches/upstream/current/t/no-import.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/t/no-import.t?rev=3225&op=file
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/t/no-import.t (added)
+++ packages/libemail-send-perl/branches/upstream/current/t/no-import.t Thu Jul  6 12:23:12 2006
@@ -1,0 +1,20 @@
+#!perl
+use strict;
+use warnings;
+
+use lib 't/lib';
+
+use Test::More 'no_plan';
+
+BEGIN { use_ok('Email::Send', ()); }
+
+my $message = <<'.';
+To: casey at geeknest.com
+From: foo at example.com
+
+Blah
+.
+
+my $rv = Email::Send::send OK => $message;
+
+ok($rv, "sender reports success");

Added: packages/libemail-send-perl/branches/upstream/current/t/object-mailer.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/t/object-mailer.t?rev=3225&op=file
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/t/object-mailer.t (added)
+++ packages/libemail-send-perl/branches/upstream/current/t/object-mailer.t Thu Jul  6 12:23:12 2006
@@ -1,0 +1,38 @@
+use Test::More qw[no_plan];
+# $Id: classic.t,v 1.1 2006/01/17 22:11:38 cwest Exp $
+use strict;
+$^W =1;
+
+BEGIN {
+  use_ok 'Email::Send';
+}
+
+use Email::Send;
+use lib 't/lib';
+
+my $message = <<'.';
+From: rjbs at foo.bar
+To: rjbs at baz.boo
+Subject: test message
+Date: Thu, 2 Feb 2006 21:51:53 -0500
+
+This is a test, a what, a test, a what, a test, oh, a test!
+.
+
+require OKMailerOO;
+
+my $mailer1 = OKMailerOO->new;
+my $mailer2 = OKMailerOO->new;
+
+my $sender1 = Email::Send->new({ mailer => $mailer1 });
+my $sender2 = Email::Send->new({ mailer => $mailer2 });
+
+my $rv1 = $sender1->send($message);
+ok($rv1, "first message sender returned success");
+
+my $rv2 = $sender2->send($message);
+ok($rv2, "second message sender returned success");
+
+cmp_ok($rv1, '==', $mailer1, "first sender result was first mailer refaddr");
+cmp_ok($rv2, '==', $mailer2, "second sender result was second mailer refaddr");
+cmp_ok($rv1, '!=', $rv2,     "...and of course the two are distinct objects");

Modified: packages/libemail-send-perl/branches/upstream/current/t/sendmail.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-send-perl/branches/upstream/current/t/sendmail.t?rev=3225&op=diff
==============================================================================
--- packages/libemail-send-perl/branches/upstream/current/t/sendmail.t (original)
+++ packages/libemail-send-perl/branches/upstream/current/t/sendmail.t Thu Jul  6 12:23:12 2006
@@ -50,12 +50,31 @@
   like( $return, qr/cannot execute/, 'error message says what we expect' );
 }
 
+my $has_FileTemp = eval { require File::Temp; };
+
 SKIP:
 {
-  skip 'Cannot run this test unless current perl is at /usr/bin/perl', 1
-    unless -x '/usr/bin/perl' && $^X eq '/usr/bin/perl';
+  skip 'Cannot run this test unless current perl is -x', 1 unless -x $^X;
 
-  local $Email::Send::Sendmail::SENDMAIL = './util/executable';
+  skip 'Cannot run this test without File::Temp', 1 unless $has_FileTemp;
+  my $tempdir = File::Temp::tempdir();
+
+  require File::Spec;
+
+  my $error = "can't prepare executable test script";
+
+  my $filename = File::Spec->catfile($tempdir, "executable");
+  open my $fh, ">", $filename or skip $error, 1;
+
+  open my $exec, "<", './util/executable' or skip $error, 1;
+
+  print {$fh} "#!$^X\n" or skip $error, 1;
+  print {$fh} <$exec>   or skip $error, 1;
+  close $fh             or skip $error, 1;
+
+  chmod 0755, $filename;
+
+  local $Email::Send::Sendmail::SENDMAIL = $filename;
   my $sender = Email::Send->new({mailer => 'Sendmail'});
   my $return = $sender->send($email);
   ok( $return, 'send() succeeded with executable $SENDMAIL' );
@@ -63,10 +82,26 @@
 
 SKIP:
 {
-  skip 'Cannot run this test unless current perl is at /usr/bin/perl', 2
-    unless -x '/usr/bin/perl' && $^X eq '/usr/bin/perl';
+  skip 'Cannot run this test unless current perl is -x', 1 unless -x $^X;
 
-  local $ENV{PATH} = './util';
+  skip 'Cannot run this test without File::Temp', 1 unless $has_FileTemp;
+  my $tempdir = File::Temp::tempdir();
+
+  require File::Spec;
+
+  my $error = "can't prepare executable test script";
+
+  my $filename = File::Spec->catfile($tempdir, "sendmail");
+  open my $sendmail_fh, ">", $filename or skip $error, 1;
+  open my $template_fh, "<", './util/sendmail' or skip $error, 1;
+
+  print {$sendmail_fh} "#!$^X\n"      or skip $error, 1;
+  print {$sendmail_fh} <$template_fh> or skip $error, 1;
+  close $sendmail_fh                  or skip $error, 1;
+
+  chmod 0755, $filename;
+
+  local $ENV{PATH} = $tempdir;
   my $sender = Email::Send->new({mailer => 'Sendmail'});
   my $return = $sender->send($email);
   ok( $return, 'send() succeeded with executable sendmail in path' );

Propchange: packages/libemail-send-perl/branches/upstream/current/util/executable
------------------------------------------------------------------------------
--- svn:executable (original)
+++ svn:executable Thu Jul  6 12:23:12 2006
@@ -1,0 +1,1 @@
+*

Propchange: packages/libemail-send-perl/branches/upstream/current/util/sendmail
------------------------------------------------------------------------------
--- svn:executable (original)
+++ svn:executable Thu Jul  6 12:23:12 2006
@@ -1,0 +1,1 @@
+*




More information about the Pkg-perl-cvs-commits mailing list