class RakeNotifier::Slack
Constants
- FAILED_LABEL
- START_LABEL
- SUCCESS_LABEL
Public Class Methods
new(token, channel, icon: nil, username: nil, notice_when_fail: false)
click to toggle source
# File lib/rake_notifier/slack.rb, line 11 def initialize(token, channel, icon: nil, username: nil, notice_when_fail: false) @client = Client.new(token, channel: channel, icon: icon, username: username) @notice_when_fail = notice_when_fail if @notice_when_fail and !@notice_when_fail.is_a?(String) @notice_when_fail = "@channel" end end
Public Instance Methods
completed_task(task, system_exit)
click to toggle source
# File lib/rake_notifier/slack.rb, line 26 def completed_task(task, system_exit) success = system_exit.success? label = success ? SUCCESS_LABEL : FAILED_LABEL at_channel = (success or !@notice_when_fail) ? "" : " #{@notice_when_fail}" notice <<-EOS.strip_heredoc #{label} `$ #{task.reconstructed_command_line}`#{at_channel} >>> exit #{system_exit.status} from #{hostname} at #{Time.now} RAILS_ENV=#{rails_env} EOS end
started_task(task)
click to toggle source
# File lib/rake_notifier/slack.rb, line 19 def started_task(task) notice <<-EOS.strip_heredoc #{START_LABEL} `$ #{task.reconstructed_command_line}` >>> from #{hostname} at #{Time.now} RAILS_ENV=#{rails_env} EOS end
Private Instance Methods
notice(msg)
click to toggle source
# File lib/rake_notifier/slack.rb, line 37 def notice(msg) @client.ping(msg) end