Class: CodeBuildNotifier::SlackMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/codebuild-notifier/slack_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build, config) ⇒ SlackMessage

Returns a new instance of SlackMessage.



25
26
27
28
# File 'lib/codebuild-notifier/slack_message.rb', line 25

def initialize(build, config)
  @build = build
  @config = config
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



20
21
22
# File 'lib/codebuild-notifier/slack_message.rb', line 20

def build
  @build
end

#configObject (readonly)

Returns the value of attribute config.



20
21
22
# File 'lib/codebuild-notifier/slack_message.rb', line 20

def config
  @config
end

Instance Method Details

#additional_channelObject



43
44
45
# File 'lib/codebuild-notifier/slack_message.rb', line 43

def additional_channel
  !build.for_pr? && config.additional_channel
end

#payloadObject



30
31
32
33
34
35
36
37
# File 'lib/codebuild-notifier/slack_message.rb', line 30

def payload
  {
    color: slack_color,
    fallback: [title, body].join("\n"),
    title: title,
    text: body
  }
end

#recipientsObject



39
40
41
# File 'lib/codebuild-notifier/slack_message.rb', line 39

def recipients
  [author_email, committer_email].uniq
end