about summary refs log tree commit diff
path: root/lib/jitterbug/Emailer.pm
diff options
context:
space:
mode:
authorJonathan "Duke" Leto <jonathan@leto.net>2011-01-18 15:30:02 -0500
committerJonathan "Duke" Leto <jonathan@leto.net>2011-01-18 15:30:02 -0500
commitdddeaba05015d4040ab1aeb502a81e291e9c56a4 (patch)
tree41d31dc19e0c1f533bd1c8a7068ce464c20308af /lib/jitterbug/Emailer.pm
parentAllow placeholders for project name and SHA1 in build failure emails (diff)
downloadjitterbug-dddeaba05015d4040ab1aeb502a81e291e9c56a4.tar.gz
Refactor jitterbug::Emailer to get rid of some warnings and improve tests
Diffstat (limited to 'lib/jitterbug/Emailer.pm')
-rw-r--r--lib/jitterbug/Emailer.pm31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm
index ab9bedb..60837d6 100644
--- a/lib/jitterbug/Emailer.pm
+++ b/lib/jitterbug/Emailer.pm
@@ -16,12 +16,29 @@ sub new {
     return $self;
 }
 
+sub _make_body {
+    my ($header, $message, $tap, $footer) = @_;
+
+    no warnings 'uninitialized';
+    return <<BODY;
+$header
+
+Commit Message:
+$message
+
+TAP Output:
+$tap
+
+$footer
+BODY
+
+}
 sub run {
     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 $tap        = $self->{'tap_output'};
     my $sha1       = $task->commit->sha256;
     my $shortsha1  = substr($sha1, 0, 8);
     my $desc       = JSON::decode_json( $task->commit->content );
@@ -29,18 +46,8 @@ sub run {
     my $message    = $desc->{'message'};
     my $header     = $buildconf->{'on_failure_header'};
     my $footer     = $buildconf->{'on_failure_footer'};
+    my $body       = _make_body($header,$message, $tap, $footer);
 
-    my $body = <<BODY;
-$header
-
-Commit Message:
-$message
-
-TAP Output:
-$tap_output
-
-$footer
-BODY
     # Expand placeholders in our on_failure header and footer
     $body =~ s/%%PROJECT%%/$project/g;
     $body =~ s/%%SHA1%%/$sha1/g;