Class: Jackal::Nellie::Formatter::SlackComment

Inherits:
Formatter
  • Object
show all
Includes:
MessageExtract
Defined in:
lib/jackal-nellie/formatter/slack_comment.rb

Constant Summary collapse

SOURCE =

Source service

:nellie
DESTINATION =

Destination service

:slack

Instance Method Summary collapse

Methods included from MessageExtract

#failure_message, #success_message

Instance Method Details

#format(payload) ⇒ Object

Format payload to provide output comment to GitHub

Parameters:

  • payload (Smash)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jackal-nellie/formatter/slack_comment.rb', line 19

def format(payload)
  if(payload.get(:data, :nellie, :result))
    msgs = payload.fetch(:data, :slack, :messages, [])
    if(payload.get(:data, :nellie, :result, :complete))
      msgs << Smash.new(
        :description => "#{app_config.fetch(:branding, :name, 'Nellie')} job result:",
        :message => success_message(payload),
        :color => :good
      )
    else
      msgs << Smash.new(
        :description => "#{app_config.fetch(:branding, :name, 'Nellie')} job result:",
        :message => failure_message(payload),
        :color => :bad
      )
    end
    payload.set(:data, :slack, :messages, msgs)
  end
end