From: Chris Nehren Date: Mon, 25 Jul 2011 19:42:28 +0000 (-0400) Subject: move to Email::MIME, clean up test to use cmp_ok X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e15a8a0901098f0838aba47e12c6e0562941c04;p=p5sagit%2FEmail-Archive.git move to Email::MIME, clean up test to use cmp_ok --- diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..8de40ec --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,2 @@ +^(?!script/|examples/|lib/|inc/|t/.+\.t|t/dist/\w+/(\w+\.PL|lib/\w+\.pm)|Makefile.PL$|README$|MANIFEST$|Changes$|META.yml$) +.svn diff --git a/lib/Email/Archive.pm b/lib/Email/Archive.pm index e7f5257..382e3c3 100644 --- a/lib/Email/Archive.pm +++ b/lib/Email/Archive.pm @@ -2,6 +2,8 @@ package Email::Archive; use Moose; use Email::Archive::Storage::DBI; +our $VERSION = '0.02'; + has storage => ( is => 'rw', does => 'Email::Archive::Storage', @@ -15,3 +17,24 @@ has storage => ( ); 1; + + +__END__ + +=head1 NAME + +Email::Archive - write emails to a database, fetch them + +=head1 WARNING! + +I only uploaded this to get it out there and kick myself into making it more +useful. As you can see it's not documented or tested yet. I put this together +mostly in one evening in a coffeeshop. It shows in some ways. caveat programmer. + +=head1 LICENSE + +This library may be used under the same terms as Perl itself. + +=head1 AUTHOR AND COPYRIGHT + +Copyright (c) 2010, 2011 Chris Nehren C. diff --git a/lib/Email/Archive/Storage/DBI.pm b/lib/Email/Archive/Storage/DBI.pm index 793eeed..9f6baa4 100644 --- a/lib/Email/Archive/Storage/DBI.pm +++ b/lib/Email/Archive/Storage/DBI.pm @@ -4,7 +4,7 @@ use Carp; use DBI; use File::ShareDir 'module_file'; use File::Slurp 'read_file'; -use Email::Simple::Creator; +use Email::MIME; use Email::Abstract; use SQL::Abstract; use autodie; @@ -62,7 +62,7 @@ sub search { my $sth = $self->prepare($sql); $sth->execute(@bind); my ($message) = $sth->fetchrow_hashref; - return Email::Simple->create( + return Email::MIME->create( header => [ From => $message->{from_addr}, To => $message->{to_addr}, diff --git a/test_run b/t/email-archive.t similarity index 59% rename from test_run rename to t/email-archive.t index a8b52ad..8f959f5 100644 --- a/test_run +++ b/t/email-archive.t @@ -1,12 +1,13 @@ #!/usr/bin/perl use strict; use warnings; -use Email::Simple; -use Email::Simple::Creator; +use Email::MIME; + +use Test::More; use Email::Archive; -my $email = Email::Simple->create( +my $email = Email::MIME->create( header => [ From => 'foo@example.com', To => 'drain@example.com', @@ -17,9 +18,12 @@ my $email = Email::Simple->create( ); my $e = Email::Archive->new(); -$e->connect('dbi:SQLite:dbname=test.db'); -print "sending @{[$email->as_string]}\n"; +$e->connect('dbi:SQLite:dbname=t/test.db'); $e->store($email); my $found = $e->retrieve('helloworld'); -print $found->as_string; +cmp_ok($found->header('subject'), 'eq', "Message in a bottle", + "can find stored message by ID"); + +done_testing; +unlink 't/test.db';