Class: PuppetWebhook::Chatops::Slack
- Inherits:
-
Object
- Object
- PuppetWebhook::Chatops::Slack
- Defined in:
- lib/plugins/chatops/slack.rb
Overview
Sets up Slack object that will send notifications to Slack via a webhook.
Instance Method Summary collapse
-
#initialize(channel, url, user, message, options = {}) ⇒ Slack
constructor
A new instance of Slack.
- #notify ⇒ Object
Constructor Details
#initialize(channel, url, user, message, options = {}) ⇒ Slack
Returns a new instance of Slack.
7 8 9 10 11 12 13 |
# File 'lib/plugins/chatops/slack.rb', line 7 def initialize(channel, url, user, , = {}) @channel = channel @url = url @user = user @message = @options = end |
Instance Method Details
#notify ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/plugins/chatops/slack.rb', line 15 def notify notifier = ::Slack::Notifier.new @url, http_options: @options[:http_options] target = if @message[:branch] @message[:branch] elsif @message[:module] @message[:module] end msg = (target) notifier.post text: msg[:fallback], channel: @channel, username: @user, icon_emoji: @options[:icon_emoji], attachments: [msg] end |