package SVN::Hooks::Wham;

use strict;
use warnings;
use SVN::Hooks;

use Exporter ();
my $HOOK = 'WHAM';
our @EXPORT = qw/WHAM/;

our $VERSION = $SVN::Hooks::VERSION;

sub WHAM {
  my $conf = $SVN::Hooks::Confs->{$HOOK};
  die 'Bad arguments' if @_ % 2;
  $conf->{'post-commit'} = \&whamit;
}

$SVN::Hooks::Inits{$HOOK} = sub {
    return { options => [] };
};

use MIME::Entity;
use Email::Address;

sub post_commit {
  my $self = shift;
  my $svnlook = shift;
  my $msg = MIME::Entity->build
    (
     To => Email::Address->new('Lawrence Statton', 'lawrence@cluon.com')->format,
     From => Email::Address->new('WHAM Robot', 'nobody@barkani.com', '(Autopush Tool)')->format,
     Subject => 'SVN Rev ' . $svnlook->rev . ' in WHAM',
     Data => Data::Dumper->Dump([$self, $svnlook],[qw/self svnlook /]),
     Type => 'TEXT'
    );
  $msg->send();
}
  


1;
