From b2fe2456e476962c19cceb74b1d17fb0f22c3c3e Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 12 Jan 2011 10:56:48 -0800 Subject: More tests for jitterbug::Emailer --- lib/jitterbug/Emailer.pm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 648c72f..4bf2e51 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -3,6 +3,7 @@ package jitterbug::Emailer; use strict; use warnings; use Email::Stuff; +use JSON; sub new { my $self = bless {} => shift; @@ -16,30 +17,33 @@ sub new { } sub run { - my $self = shift; - my $task = $self->{'task'}; - my $buildconf = $self->{'conf'}->{'jitterbug'}{'build_process'}; - my $project = $task->project->name; + my $self = shift; + my $task = $self->{'task'}; + my $buildconf = $self->{'conf'}->{'jitterbug'}{'build_process'}; + my $project = $task->project->name; my $tap_output = $self->{'tap_output'}; - my $sha1 = $task->commit->sha256; - my $desc = JSON::decode_json( $task->commit->content ); - my $email = $desc->{'author'}{'email'}; + my $sha1 = $task->commit->sha256; + my $desc = JSON::decode_json( $task->commit->content ); + my $email = $desc->{'author'}{'email'}; my $body = <from($buildconf->{'on_failure_from_email'}) - ->to($email) + my $stuff = Email::Stuff->from($buildconf->{'on_failure_from_email'}) + # bug in Email::Stuff brakes chaining if $email is empty + ->to($email || " ") ->cc($buildconf->{'on_failure_cc_email'}) ->text_body($body) ->subject( $buildconf->{'on_failure_subject_prefix'} . "$project @ $sha1" - ) + ); # Should we attach a build log for convenience? # ->attach(io('dead_bunbun_faked.gif')->all, # filename => 'dead_bunbun_proof.gif') - ->send; + $self->{'last_email_sent'} = $stuff; + + $stuff->send; return $self; } -- cgit 1.4.1