Class: Slack::Cap::SlackNotifierWrapper
- Inherits:
-
Object
- Object
- Slack::Cap::SlackNotifierWrapper
- Defined in:
- lib/slack-cap/slack_notifier_wrapper.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#team ⇒ Object
Returns the value of attribute team.
-
#token ⇒ Object
Returns the value of attribute token.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #deployer ⇒ Object
-
#initialize(opts) ⇒ SlackNotifierWrapper
constructor
A new instance of SlackNotifierWrapper.
- #notifier ⇒ Object
- #notify(msg, icon_emoji: ':rocket:') ⇒ Object
- #reason ⇒ Object
Constructor Details
#initialize(opts) ⇒ SlackNotifierWrapper
Returns a new instance of SlackNotifierWrapper.
6 7 8 9 10 11 12 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 6 def initialize(opts) @app = opts.fetch(:app) @team = opts.fetch(:team) @token = opts.fetch(:token) @channel = opts.fetch(:channel) @username = opts[:username] ||'capistrano' end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
4 5 6 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 4 def app @app end |
#channel ⇒ Object
Returns the value of attribute channel.
4 5 6 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 4 def channel @channel end |
#team ⇒ Object
Returns the value of attribute team.
4 5 6 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 4 def team @team end |
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 4 def token @token end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 4 def username @username end |
Instance Method Details
#deployer ⇒ Object
14 15 16 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 14 def deployer ENV['GIT_AUTHOR_NAME'] || `git config user.name`.chomp end |
#notifier ⇒ Object
31 32 33 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 31 def notifier @notifier ||= ::Slack::Notifier.new(team, token, channel: channel, username: username) end |
#notify(msg, icon_emoji: ':rocket:') ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 23 def notify(msg, icon_emoji: ':rocket:') begin notifier.ping(msg, icon_emoji: icon_emoji) rescue Net::OpenTimeout, Net::ReadTimeout puts Colorize.red("SLACK TIMEOUT") end end |
#reason ⇒ Object
18 19 20 21 |
# File 'lib/slack-cap/slack_notifier_wrapper.rb', line 18 def reason raise "provice a reason with MSG=... !" unless ENV['MSG'] ENV['MSG'] end |