Module: SlackNotifierWrapper
- Defined in:
- lib/slack_notifier_wrapper.rb,
lib/slack_notifier_wrapper/helpers.rb,
lib/slack_notifier_wrapper/version.rb
Defined Under Namespace
Modules: Helpers
Constant Summary collapse
- VERSION =
"0.1.2"
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(args) ⇒ Object
- .username(username) ⇒ Object
Class Method Details
.config(&block) ⇒ Object
25 26 27 |
# File 'lib/slack_notifier_wrapper.rb', line 25 def config(&block) instance_eval(&block) end |
.default_channel(channel) ⇒ Object
33 34 35 |
# File 'lib/slack_notifier_wrapper.rb', line 33 def default_channel(channel) @default_channel = channel end |
.icon_emoji(emoji) ⇒ Object
41 42 43 |
# File 'lib/slack_notifier_wrapper.rb', line 41 def icon_emoji(emoji) @icon_emoji = emoji end |
.notifier ⇒ Object
21 22 23 |
# File 'lib/slack_notifier_wrapper.rb', line 21 def notifier @notifier ||= Slack::Notifier.new(@slack_webhook_url, channel: @default_channel, username: @username) end |
.slack_webhook_url(url) ⇒ Object
29 30 31 |
# File 'lib/slack_notifier_wrapper.rb', line 29 def slack_webhook_url(url) @slack_webhook_url = url end |
.speak(message) ⇒ Object
8 9 10 |
# File 'lib/slack_notifier_wrapper.rb', line 8 def speak() notifier.ping , icon_emoji: @icon_emoji end |
.speak_attachments(args) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/slack_notifier_wrapper.rb', line 12 def (args) = { text: args.fetch(:attachment_message, ""), color: args.fetch(:color, "good"), mrkdwn_in: ["text"] } notifier.ping(args.fetch(:message, ""), icon_emoji: @icon_emoji, attachments: []) end |
.username(username) ⇒ Object
37 38 39 |
# File 'lib/slack_notifier_wrapper.rb', line 37 def username(username) @username = username end |