summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonathan "Duke" Leto <jonathan@leto.net>2011-01-12 10:56:48 -0800
committerJonathan "Duke" Leto <jonathan@leto.net>2011-01-12 10:56:48 -0800
commitb2fe2456e476962c19cceb74b1d17fb0f22c3c3e (patch)
treec06b3412b7cbbad799a012953771fd1484feee8e /lib
parentAdd Test::MockObject as a dep (diff)
downloadjitterbug-b2fe2456e476962c19cceb74b1d17fb0f22c3c3e.tar.gz
More tests for jitterbug::Emailer
Diffstat (limited to 'lib')
-rw-r--r--lib/jitterbug/Emailer.pm26
1 files changed, 15 insertions, 11 deletions
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 = <<BODY;
$tap_output
BODY
- Email::Stuff->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;
}