Class: RakeNotifier::Slack
Defined Under Namespace
Classes: Client
Constant Summary collapse
- START_LABEL =
":construction: *[START]*"- SUCCESS_LABEL =
":congratulations: *[SUCCESS]*"- FAILED_LABEL =
":x: *[FAILED]*"
Instance Method Summary collapse
- #completed_task(task, system_exit) ⇒ Object
-
#initialize(token, channel, icon: nil, username: nil, notice_when_fail: false) ⇒ Slack
constructor
A new instance of Slack.
- #started_task(task) ⇒ Object
Constructor Details
#initialize(token, channel, icon: nil, username: nil, notice_when_fail: false) ⇒ Slack
Returns a new instance of Slack.
11 12 13 14 15 16 17 |
# 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 |
Instance Method Details
#completed_task(task, system_exit) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# 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 " \#{label} `$ \#{task.reconstructed_command_line}`\#{at_channel}\n >>> exit \#{system_exit.status} from \#{hostname} at \#{Time.now} RAILS_ENV=\#{rails_env}\n EOS\nend\n".strip_heredoc |
#started_task(task) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rake_notifier/slack.rb', line 19 def started_task(task) notice " \#{START_LABEL} `$ \#{task.reconstructed_command_line}`\n >>> from \#{hostname} at \#{Time.now} RAILS_ENV=\#{rails_env}\n EOS\nend\n".strip_heredoc |