Class: Groundskeeper::Slack
- Inherits:
-
Object
- Object
- Groundskeeper::Slack
- Defined in:
- lib/groundskeeper/slack.rb
Overview
Posts to the RADD #general channel.
Constant Summary collapse
- COMMAND =
"curl"
- SLACK_WORKSPACE_KEY =
"SLACK_WORKSPACE"
- SLACK_CHANNEL_KEY =
"SLACK_CHANNEL"
- SLACK_TOKEN_KEY =
"SLACK_TOKEN"
- URL =
"https://hooks.slack.com/services/" \ "%<workspace>s/%<channel>s/%<token>s"
- SEND_MESSAGE =
"-X POST -H 'Content-type: application/json' " \ "--data '{\"text\":\"%<message>s\"}' #{URL}".freeze
Instance Attribute Summary collapse
-
#slack ⇒ Object
readonly
Returns the value of attribute slack.
Class Method Summary collapse
Instance Method Summary collapse
- #credentials? ⇒ Boolean
-
#initialize(slack) ⇒ Slack
constructor
A new instance of Slack.
- #send_message(message) ⇒ Object
Constructor Details
#initialize(slack) ⇒ Slack
Returns a new instance of Slack.
21 22 23 |
# File 'lib/groundskeeper/slack.rb', line 21 def initialize(slack) @slack = slack end |
Instance Attribute Details
#slack ⇒ Object (readonly)
Returns the value of attribute slack.
15 16 17 |
# File 'lib/groundskeeper/slack.rb', line 15 def slack @slack end |
Class Method Details
.build ⇒ Object
17 18 19 |
# File 'lib/groundskeeper/slack.rb', line 17 def self.build new Executable.new(COMMAND) end |
Instance Method Details
#credentials? ⇒ Boolean
33 34 35 36 37 |
# File 'lib/groundskeeper/slack.rb', line 33 def credentials? !ENV.fetch(SLACK_WORKSPACE_KEY, "").empty? && !ENV.fetch(SLACK_CHANNEL_KEY, "").empty? && !ENV.fetch(SLACK_TOKEN_KEY, "").empty? end |
#send_message(message) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/groundskeeper/slack.rb', line 25 def () slack.execute(format(SEND_MESSAGE, message: , workspace: ENV.fetch(SLACK_WORKSPACE_KEY, nil), channel: ENV.fetch(SLACK_CHANNEL_KEY, nil), token: ENV.fetch(SLACK_TOKEN_KEY, nil))) end |