From: Mugen Kenichi Date: Tue, 27 Sep 2011 11:18:33 +0000 (+0200) Subject: fixed namespaces X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ec4130876d118bdfbccb7aeb383f31085eb921f0;p=p5sagit%2FEmail-Archive.git fixed namespaces --- diff --git a/lib/Email/Archive/Storage/DBIC.pm b/lib/Email/Archive/Storage/DBIC.pm index 1dcf8a7..0875c1a 100644 --- a/lib/Email/Archive/Storage/DBIC.pm +++ b/lib/Email/Archive/Storage/DBIC.pm @@ -1,9 +1,9 @@ -package Email::Archive::Storage::DBI; +package Email::Archive::Storage::DBIC; use Moo; use Carp; use Email::MIME; use Email::Abstract; -use Email::Archive::Schema; +use Email::Archive::Storage::DBIC::Schema; use autodie; use Try::Tiny; with q/Email::Archive::Storage/; @@ -11,7 +11,7 @@ with q/Email::Archive::Storage/; has schema => ( is => 'rw', isa => sub { - ref $_[0] eq 'Email::Archive::Schema' or die "schema must be a Email::Archive schema", + ref $_[0] eq 'Email::Archive::Storage::DBIC::Schema' or die "schema must be a Email::Archive::Storage::DBIC schema", }, ); @@ -67,9 +67,9 @@ sub _deployed { return $deployed; } -sub storage_connect_dbic { +sub storage_connect { my ($self, $dsn) = @_; - $self->schema(Email::Archive::Schema->connect($dsn)); + $self->schema(Email::Archive::Storage::DBIC::Schema->connect($dsn)); my $deployed = $self->_deployed; $self->_deploy unless $deployed; } diff --git a/lib/Email/Archive/Storage/DBIC/Schema.pm b/lib/Email/Archive/Storage/DBIC/Schema.pm index bb26edd..0ebef2a 100644 --- a/lib/Email/Archive/Storage/DBIC/Schema.pm +++ b/lib/Email/Archive/Storage/DBIC/Schema.pm @@ -1,4 +1,4 @@ -package Email::Archive::Schema; +package Email::Archive::Storage::DBIC::Schema; use strict; use warnings; diff --git a/lib/Email/Archive/Storage/DBIC/Schema/Result/Messages.pm b/lib/Email/Archive/Storage/DBIC/Schema/Result/Messages.pm index d6e9796..7f738d3 100644 --- a/lib/Email/Archive/Storage/DBIC/Schema/Result/Messages.pm +++ b/lib/Email/Archive/Storage/DBIC/Schema/Result/Messages.pm @@ -1,4 +1,4 @@ -package Email::Archive::Schema::Result::Messages; +package Email::Archive::Storage::DBIC::Schema::Result::Messages; use strict; use warnings; diff --git a/lib/Email/Archive/Storage/DBIC/Schema/Result/Metadata.pm b/lib/Email/Archive/Storage/DBIC/Schema/Result/Metadata.pm index aede4af..f6acfce 100644 --- a/lib/Email/Archive/Storage/DBIC/Schema/Result/Metadata.pm +++ b/lib/Email/Archive/Storage/DBIC/Schema/Result/Metadata.pm @@ -1,4 +1,4 @@ -package Email::Archive::Schema::Result::Metadata; +package Email::Archive::Storage::DBIC::Schema::Result::Metadata; use strict; use warnings; diff --git a/t/basic.t b/t/basic.t index 8f959f5..4dbdc75 100644 --- a/t/basic.t +++ b/t/basic.t @@ -6,6 +6,7 @@ use Email::MIME; use Test::More; use Email::Archive; +use Email::Archive::Storage::DBIC; my $email = Email::MIME->create( header => [ @@ -25,5 +26,17 @@ my $found = $e->retrieve('helloworld'); cmp_ok($found->header('subject'), 'eq', "Message in a bottle", "can find stored message by ID"); +my $e_dbic = Email::Archive->new( + storage => Email::Archive::Storage::DBIC->new, +); +$e_dbic->connect('dbi:SQLite:dbname=t/test_dbic.db'); +$e_dbic->store($email); + +$found = $e_dbic->retrieve('helloworld'); +cmp_ok($found->header('subject'), 'eq', "Message in a bottle", + "can find stored message by ID"); + + done_testing; unlink 't/test.db'; +unlink 't/dbic_test.db';