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, source_ref) ⇒ SlackMessage

Returns a new instance of SlackMessage.



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

def initialize(build, config, source_ref)
  @build = build
  @config = config
  @source_ref = source_ref
  @short_hash, @author_name, @author_email,
    @committer_email, @commit_message_subject = git_info
end

Instance Attribute Details

#author_emailObject (readonly)

Returns the value of attribute author_email.



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

def author_email
  @author_email
end

#author_nameObject (readonly)

Returns the value of attribute author_name.



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

def author_name
  @author_name
end

#buildObject (readonly)

Returns the value of attribute build.



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

def build
  @build
end

#commit_message_subjectObject (readonly)

Returns the value of attribute commit_message_subject.



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

def commit_message_subject
  @commit_message_subject
end

#committer_emailObject (readonly)

Returns the value of attribute committer_email.



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

def committer_email
  @committer_email
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

#short_hashObject (readonly)

Returns the value of attribute short_hash.



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

def short_hash
  @short_hash
end

#source_refObject (readonly)

Returns the value of attribute source_ref.



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

def source_ref
  @source_ref
end

Instance Method Details

#additional_channelObject



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

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

#payloadObject



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

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

#recipientsObject



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

def recipients
  [author_email, committer_email].uniq
end