rev 1473 - in trunk/mariachi: . lib/Mariachi

[prev] [thread] [next] [lurker] [Date index for 2003/11/27]

From: richardc
Subject: rev 1473 - in trunk/mariachi: . lib/Mariachi
Date: 16:05 on 27 Nov 2003
Author: richardc
Date: 2003-11-27 16:05:31 +0000 (Thu, 27 Nov 2003)
New Revision: 1473

Removed:
   trunk/mariachi/lib/Mariachi/DBI.pm
Modified:
   trunk/mariachi/Build.PL
   trunk/mariachi/TODO
   trunk/mariachi/lib/Mariachi/Message.pm
   trunk/mariachi/mariachi
Log:
put the main branch back how it was

Modified: trunk/mariachi/Build.PL
===================================================================
--- trunk/mariachi/Build.PL	2003-11-27 16:02:04 UTC (rev 1472)
+++ trunk/mariachi/Build.PL	2003-11-27 16:05:31 UTC (rev 1473)
@@ -11,10 +11,8 @@
         'Test::More'      => 0,
     },
     requires     => {
-        'perl'            => '5.006',
         'AppConfig'       => '1.55',
         'Class::Accessor' => 0,
-        'Class::Delay'    => 0,
         'Date::Parse'     => 0,
         'Email::Folder'   => '0.5',
         'Email::Thread'   => 0,

Modified: trunk/mariachi/TODO
===================================================================
--- trunk/mariachi/TODO	2003-11-27 16:02:04 UTC (rev 1472)
+++ trunk/mariachi/TODO	2003-11-27 16:05:31 UTC (rev 1473)
@@ -9,18 +9,3 @@
 with mhonarc/pipermail.  a logo.  how to install with your existing
 mailman system.  finished templates
 
-
-=head1 Class::DBI groovyness
-
-SQLite, drop it in the directory of output chmod 600, or let that get
-overridden (and maybe be another database altogether like mysql)
-
-main problem is set_up_table will want to have a table there at
-requite Mariachi::Message time, but we won't know where to put one
-until after argument parsing is done
-
-mark the threading columns as Essential so that they get pulled in all
-at once
-
-dynamic page generation via a cgi?
-

Deleted: trunk/mariachi/lib/Mariachi/DBI.pm
===================================================================
--- trunk/mariachi/lib/Mariachi/DBI.pm	2003-11-27 16:02:04 UTC (rev 1472)
+++ trunk/mariachi/lib/Mariachi/DBI.pm	2003-11-27 16:05:31 UTC (rev 1473)
@@ -1,15 +0,0 @@
-use strict;
-package Mariachi::DBI;
-use base 'Class::DBI::SQLite';
-
-# create table, for slackers
-sub slacker_table {
-    my $self = shift;
-
-    # id goes without saying, so don't make me say it
-    my $sql = "CREATE TABLE ".$self->moniker. " ( "
-      . join(", ", "id INTEGER PRIMARY KEY", @_ ) . " )";
-    #warn $sql;
-    $self->db_Main->do( $sql )
-}
-1;

Modified: trunk/mariachi/lib/Mariachi/Message.pm
===================================================================
--- trunk/mariachi/lib/Mariachi/Message.pm	2003-11-27 16:02:04 UTC (rev 1472)
+++ trunk/mariachi/lib/Mariachi/Message.pm	2003-11-27 16:05:31 UTC (rev 1473)
@@ -7,16 +7,11 @@
 use Text::Original ();
 use Memoize;
 
-use base 'Mariachi::DBI::Delay';
-__PACKAGE__->slacker_table( qw(
-    hdr_message_id hdr_from hdr_subject hdr_date
-    hdr_references hdr_in_reply_to
-    body epoch_date day month year
-  ));
-__PACKAGE__->set_up_table( __PACKAGE__->moniker );
-__PACKAGE__->columns( TEMP => qw( prev next root ) );
+use base qw(Class::Accessor::Fast);
+__PACKAGE__->mk_accessors(qw( body _header next prev root
+                              epoch_date day month year ymd linked
+                            ));
 
-
 =head1 NAME
 
 Mariachi::Message - representation of a mail message
@@ -31,39 +26,42 @@
 
 =cut
 
-
-sub _header_column {
-    my $thing = shift;
-    $thing =~ tr/-/_/;
-    return "hdr_" . lc $thing;
-}
-
-
 sub new {
     my $class = shift;
+    my $source = shift;
 
-    my $mail  = Email::Simple->new(shift) or return;
-    my $msgid = $mail->header('message-id') or die "gotta have a message-id";
-    my ($old) = $class->search({ hdr_message_id => $msgid });
-    return $old if $old;
+    my $self = $class->SUPER::new;
+    my $mail = Email::Simple->new($source) or return;
 
-    my $data = {};
-    $data->{ _header_column $_ } = $mail->header($_) for
+    $self->linked({});
+    $self->_header({});
+    $self->header_set( $_, $mail->header($_) ) for
       qw( message-id from subject date references in-reply-to );
+    $self->body( $mail->body );
 
-    $data->{body}       = $mail->body;
-    $data->{epoch_date} = str2time( $data->{hdr_date} ) || 0;
+    $self->header_set('message-id', $self->_make_fake_id)
+      unless $self->header('message-id');
 
-    my @date = localtime $data->{epoch_date};
+    # this is a bit ugly to be here but much quicker than making it a
+    # memoized lookup
+    my @date = localtime $self->epoch_date(str2time( $self->header('date') )
+                                             || 0);
     my @ymd = ( $date[5] + 1900, $date[4] + 1, $date[3] );
-    $data->{day}   = sprintf "%04d/%02d/%02d", @ymd;
-    $data->{month} = sprintf "%04d/%02d", @ymd;
-    $data->{year}  = sprintf "%04d", @ymd;
+    $self->ymd(\@ymd);
+    $self->day(   sprintf "%04d/%02d/%02d", @ymd );
+    $self->month( sprintf "%04d/%02d", @ymd );
+    $self->year(  sprintf "%04d", @ymd );
 
-    return $class->create($data);
+    return $self;
 }
 
 
+sub _make_fake_id {
+    my $self = shift;
+    my $hash = substr( md5_hex( $self->header('from').$self->date ), 0, 8 );
+    return "$hash\@made_up";
+}
+
 =head2 ->body
 
 =head2 ->header
@@ -71,24 +69,21 @@
 =head2 ->header_set
 
 C<body>, C<header>, and C<header_set> are provided for interface
-compatibility with Email::Simple.  Note that only a small subset of
-headers are available.
+compatibility with Email::Simple
 
 =cut
 
 sub header {
     my $self = shift;
-    my $meth = _header_column shift;
-    $self->$meth();
+    $self->_header->{ lc shift() };
 }
 
 sub header_set {
     my $self = shift;
-    my $meth = _header_column shift;
-    $self->$meth( shift );
+    my $hdr = shift;
+    $self->_header->{ lc $hdr } = shift;
 }
 
-
 =head2 ->first_lines
 
 =head2 ->first_paragraph
@@ -115,7 +110,6 @@
     return Text::Original::first_sentence( $self->body );
 }
 
-
 =head2 ->body_sigless
 
 Returns the body with the signature (defined as anything
@@ -130,7 +124,6 @@
     return $body;
 }
 
-
 =head2 ->sig
 
 Returns the stripped sig.
@@ -145,6 +138,7 @@
 }
 
 
+
 =head2 ->from
 
 A privacy repecting version of the From: header.
@@ -163,7 +157,6 @@
 }
 memoize('from');
 
-
 =head2 ->subject
 
 =head2 ->date
@@ -200,6 +193,8 @@
 
 The date header pared into epoch seconds
 
+=head2 ->ymd
+
 =head2 ->day
 
 =head2 ->month

Modified: trunk/mariachi/mariachi
===================================================================
--- trunk/mariachi/mariachi	2003-11-27 16:02:04 UTC (rev 1472)
+++ trunk/mariachi/mariachi	2003-11-27 16:05:31 UTC (rev 1473)
@@ -55,18 +55,17 @@
 =cut
 
 # define the command line options
-my $config = AppConfig->new({
-    PEDANTIC => 1,
-    GLOBAL   => {
-        ARGCOUNT => ARGCOUNT_ONE,
-    },
-    ERROR    => sub {
-        my $format = shift;
-        $format = "mariachi: $format\n";
-        print STDERR sprintf $format, @_;
-        exit;
-    },
-});
+my $config = AppConfig->new({ PEDANTIC => 1,
+                              GLOBAL   => {
+                                  ARGCOUNT => ARGCOUNT_ONE,
+                              },
+                              ERROR    => sub {
+                                  my $format = shift;
+                                  $format = "mariachi: $format\n";
+                                  print STDERR sprintf $format, @_;
+                                  exit;
+                              },
+                             });
 
 $config->define("input", { ALIAS => 'i' });
 
@@ -200,9 +199,6 @@
     $config->name("no list name");
 }
 
-Mariachi::DBI::Delay->set_db(
-    Main => 'dbi:SQLite:'.$config->output.'/mariachi.db'
-   );
 $config->class->new( config  => $config,
                      threads_per_page => 20,
                     )

Generated at 13:57 on 01 Jul 2004 by mariachi 0.52