Class: Jackal::Nellie::Formatter::GithubCommitStatus

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

Constant Summary collapse

SOURCE =

Source service

:nellie
DESTINATION =

Destination service

:github_kit

Instance Method Summary collapse

Methods included from MessageExtract

#failure_message, #success_message

Instance Method Details

#format(payload) ⇒ Object

Format payload to provide output status to GitHub

Parameters:

  • payload (Smash)


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

def format(payload)
  if(payload.get(:data, :nellie, :status))
    payload.set(:data, :github_kit, :status,
      Smash.new(
        :repository => [
          payload.get(:data, :code_fetcher, :info, :owner),
          payload.get(:data, :code_fetcher, :info, :name)
        ].join('/'),
        :reference => payload.get(:data, :code_fetcher, :info, :commit_sha),
        :state => payload.get(:data, :nellie, :status) == 'success' ? 'success' : 'failure',
        :extras => {
          :context => 'nellie',
          :description => payload.get(:data, :nellie, :status) == 'success' ?
            "#{app_config.fetch(:branding, :name, 'Nellie')} completed successfully" :
            "#{app_config.fetch(:branding, :name, 'Nellie')} failed to complete"
        }
      )
    )
  end
end