Subject: | PATCH: integrate Email::Reply and Email::Filter |
With Mail::Audit, replying works like this:
$m->reply(%options);
With the PEP tools, it currently seems to be:
Email::Send->new->send(reply(to => $m->simple, %options));
which sucketh.
This patch brings some sanity and simplicity, supporting this:
Email::Send->new->send( $m->reply(%options) );
I hope a version of this can be accepted, even if you find my current
implementation evil instead of clever.
There's already a ton of PEP modules. I'm not sure it's worth spawning
Email::Filter::Plugin::Reply to create a solution that is cleaner in a
software sense, but even more of a PITA to involve one more module from
user's perspective.
Mark
Subject: | reply_filter.patch |
Thu Mar 22 23:21:35 EDT 2007 Mark Stosberg <mark@summersault.com>
* integrate Email::Reply with Email::Filter
diff -rN -u old-Email-Reply-1.201/Changes new-Email-Reply-1.201/Changes
--- old-Email-Reply-1.201/Changes 2007-03-22 23:22:01.000000000 -0400
+++ new-Email-Reply-1.201/Changes 2007-03-22 23:22:01.000000000 -0400
@@ -1,3 +1,5 @@
+ New feature: Automatically provides "reply()" mix-in method for Email::Filter now.
+
1.201 2007-02-15
tests should not reply on super-exact stringifications
diff -rN -u old-Email-Reply-1.201/lib/Email/Reply.pm new-Email-Reply-1.201/lib/Email/Reply.pm
--- old-Email-Reply-1.201/lib/Email/Reply.pm 2007-03-22 23:22:01.000000000 -0400
+++ new-Email-Reply-1.201/lib/Email/Reply.pm 2007-03-22 23:22:01.000000000 -0400
@@ -31,6 +31,11 @@
return $reply->{message} ? $reply->_mime : $reply->_simple;
}
+sub Email::Filter::reply {
+ my $filter = shift;
+ return reply( to => $filter->simple, @_ );
+}
+
sub _new {
my ($class, %args) = @_;
my $self = {};
@@ -188,11 +193,18 @@
Thanks for the message, I'll be glad to explain...
__RESPONSE__
-
=head1 DESCRIPTION
This software takes the hard out of generating replies to email messages.
+=head2 Methods
+
+This module adds a reply() method to L<Email::Filter>-based objects.
+The use automatically takes care of populating the "to" parameter with the
+Email::Filter source message. So it's simply:
+
+ $filter->reply(%options);
+
=head2 Functions
=over 4
diff -rN -u old-Email-Reply-1.201/MANIFEST new-Email-Reply-1.201/MANIFEST
--- old-Email-Reply-1.201/MANIFEST 2007-03-22 23:22:01.000000000 -0400
+++ new-Email-Reply-1.201/MANIFEST 2007-03-22 23:22:01.000000000 -0400
@@ -6,5 +6,6 @@
t/pod.t
t/pod-coverage.t
t/test.t
+t/email_filter.t
LICENSE
META.yml Module meta-data (added by MakeMaker)
diff -rN -u old-Email-Reply-1.201/t/email_filter.t new-Email-Reply-1.201/t/email_filter.t
--- old-Email-Reply-1.201/t/email_filter.t 1969-12-31 19:00:00.000000000 -0500
+++ new-Email-Reply-1.201/t/email_filter.t 2007-03-22 23:22:01.000000000 -0400
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+use Test::More;
+
+if( eval 'require Email::Filter;') {
+ plan 'no_plan';
+}
+else {
+ plan skip_all => 'missing Email::Filter';
+}
+
+use Email::Reply;
+
+my $filter = Email::Filter->new( data =>
+'To: mark@summersault.com
+From: bob@overthere.com
+Subject: Memo
+
+About that fried chicken...
+
+');
+
+my $reply = $filter->reply( body => 'I was wondering about that chicken, too.');
+
+isa_ok($reply, 'Email::Simple', "got back Email::Simple object");
+like($reply->as_string, qr/chicken/, "reality check content of reply");