Module: SlackNotifierWrapper
- Defined in:
- lib/slack_notifier_wrapper.rb,
lib/slack_notifier_wrapper/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
- .config(&block) ⇒ Object
- .default_channel(channel) ⇒ Object
- .icon_emoji(emoji) ⇒ Object
- .notifier ⇒ Object
- .slack_webhook_url(url) ⇒ Object
- .speak(message) ⇒ Object
- .speak_attachments(message, attachment_message, color) ⇒ Object
- .username(username) ⇒ Object
Class Method Details
.config(&block) ⇒ Object
24 25 26 |
# File 'lib/slack_notifier_wrapper.rb', line 24 def config(&block) instance_eval(&block) end |
.default_channel(channel) ⇒ Object
32 33 34 |
# File 'lib/slack_notifier_wrapper.rb', line 32 def default_channel(channel) @default_channel = channel end |
.icon_emoji(emoji) ⇒ Object
40 41 42 |
# File 'lib/slack_notifier_wrapper.rb', line 40 def icon_emoji(emoji) @icon_emoji = emoji end |
.notifier ⇒ Object
20 21 22 |
# File 'lib/slack_notifier_wrapper.rb', line 20 def notifier @notifier ||= Slack::Notifier.new(@slack_webhook_url, channel: @default_channel, username: @username) end |
.slack_webhook_url(url) ⇒ Object
28 29 30 |
# File 'lib/slack_notifier_wrapper.rb', line 28 def slack_webhook_url(url) @slack_webhook_url = url end |
.speak(message) ⇒ Object
7 8 9 |
# File 'lib/slack_notifier_wrapper.rb', line 7 def speak() notifier.ping , icon_emoji: @icon_emoji end |
.speak_attachments(message, attachment_message, color) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/slack_notifier_wrapper.rb', line 11 def (, , color) { text: args.fetch(:attachment_message, ""), color: color, mrkdwn_in: ["text"] } notifier.ping , icon_emoji: @icon_emoji, attachments: [] end |
.username(username) ⇒ Object
36 37 38 |
# File 'lib/slack_notifier_wrapper.rb', line 36 def username(username) @username = username end |