diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-08-17 13:15:20 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-08-17 13:15:20 +0300 |
commit | fa0624fc6409d84373f3e06275e936c9e5171b79 (patch) | |
tree | e884a367f605548365c6e3745f1a7a4457afe487 /lib/gitlab/downtime_check/message.rb | |
parent | 88a0c984fc0bdbe0951b02c4e1d4b749dce88a24 (diff) |
Better formatting for downtime check messages
This removes excessive whitespace from the messages (e.g. leading
whitespace) and ensures the message is more clearly visible.
Diffstat (limited to 'lib/gitlab/downtime_check/message.rb')
-rw-r--r-- | lib/gitlab/downtime_check/message.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/gitlab/downtime_check/message.rb b/lib/gitlab/downtime_check/message.rb index fd85f087c03..40a4815a9a0 100644 --- a/lib/gitlab/downtime_check/message.rb +++ b/lib/gitlab/downtime_check/message.rb @@ -1,7 +1,7 @@ module Gitlab class DowntimeCheck class Message - attr_reader :path, :offline, :reason + attr_reader :path, :offline OFFLINE = "\e[31moffline\e[0m" ONLINE = "\e[32monline\e[0m" @@ -19,10 +19,21 @@ module Gitlab label = offline ? OFFLINE : ONLINE message = "[#{label}]: #{path}" - message += ": #{reason}" if reason + + if reason? + message += ":\n\n#{reason}\n\n" + end message end + + def reason? + @reason.present? + end + + def reason + @reason.strip.lines.map(&:strip).join("\n") + end end end end |