class Changelog::Notifier::Adapters::Slack

Slack adapter sends the release note in a Slack channel.

Public Instance Methods

configured?() click to toggle source
# File lib/changelog/notifier/adapters/slack.rb, line 12
def configured?
  @webhook_url.to_s.empty? == false
end
publish!(release_note_hash, version) click to toggle source
# File lib/changelog/notifier/adapters/slack.rb, line 16
def publish!(release_note_hash, version)
  formatted_release_note = format_release_note_hash(release_note_hash)

  notifier = instantiate_slack_notifier

  @capistrano.info "Posting #{version}'s release note in the " \
                   "Slack #{channel} channel using the #{icon_emoji} " \
                   'emoji icon ...'

  notifier.post formatted_release_note
end

Private Instance Methods

channel() click to toggle source
# File lib/changelog/notifier/adapters/slack.rb, line 30
def channel
  @channel || '#general'
end
fetches_adapter_configuration() click to toggle source

Fetches all the configuration variables from Capistrano.

# File lib/changelog/notifier/adapters/slack.rb, line 37
def fetches_adapter_configuration
  @webhook_url = @capistrano.fetch(
    :changelog_notifier_slack_webhook_url
  )
  @channel = @capistrano.fetch(:changelog_notifier_slack_channel)
  @icon_emoji = @capistrano.fetch(:changelog_notifier_slack_icon_emoji)
end
format_release_note_hash(release_note_hash) click to toggle source
# File lib/changelog/notifier/adapters/slack.rb, line 45
def format_release_note_hash(release_note_hash)
  Changelog::Notifier::Formatters::Slack.new(release_note_hash).format
end
icon_emoji() click to toggle source
# File lib/changelog/notifier/adapters/slack.rb, line 49
def icon_emoji
  @icon_emoji || ':package:'
end
instantiate_slack_notifier() click to toggle source
# File lib/changelog/notifier/adapters/slack.rb, line 53
def instantiate_slack_notifier
  ::Slack::Notifier.new(
    @webhook_url,
    channel: channel,
    icon_emoji: icon_emoji,
    username: 'ChangeLog Notifier'
  )
end