Class: Octobot::SlackAgent::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/octobot/slack_agent/notifier.rb

Direct Known Subclasses

DeployNotifier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(webhook_url, username = 'octobot', icon_emoji = nil) ⇒ Notifier

Returns a new instance of Notifier.



14
15
16
17
18
# File 'lib/octobot/slack_agent/notifier.rb', line 14

def initialize(webhook_url, username='octobot', icon_emoji=nil)
  @webhook_url = webhook_url
  @username = username
  @icon_emoji = icon_emoji
end

Instance Attribute Details

#icon_emojiObject

Returns the value of attribute icon_emoji.



12
13
14
# File 'lib/octobot/slack_agent/notifier.rb', line 12

def icon_emoji
  @icon_emoji
end

#usernameObject

Returns the value of attribute username.



12
13
14
# File 'lib/octobot/slack_agent/notifier.rb', line 12

def username
  @username
end

#webhook_urlObject

Returns the value of attribute webhook_url.



12
13
14
# File 'lib/octobot/slack_agent/notifier.rb', line 12

def webhook_url
  @webhook_url
end

Instance Method Details

#error(params) ⇒ Object



28
29
30
# File 'lib/octobot/slack_agent/notifier.rb', line 28

def error(params)
  send_attachments [ attachment(params, DANGER) ]
end

#send(params) ⇒ Object



36
37
38
# File 'lib/octobot/slack_agent/notifier.rb', line 36

def send(params)
  send_request(base_params.merge(params))
end

#send_attachments(attachments) ⇒ Object



32
33
34
# File 'lib/octobot/slack_agent/notifier.rb', line 32

def send_attachments(attachments)
  send attachments: attachments
end

#success(params) ⇒ Object



20
21
22
# File 'lib/octobot/slack_agent/notifier.rb', line 20

def success(params)
  send_attachments [ attachment(params, GOOD) ]
end

#warn(params) ⇒ Object



24
25
26
# File 'lib/octobot/slack_agent/notifier.rb', line 24

def warn(params)
  send_attachments [ attachment(params, WARNING) ]
end