Sha256: bbbe0815bea2e226bda6065b2837becbfe3c32a77c1ee30af788d1fa0bd9027d
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Groundskeeper # Posts to the RADD #general channel. class Slack 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 attr_reader :slack def self.build new Executable.new(COMMAND) end def initialize(slack) @slack = slack end def send_message(message) slack.execute(format(SEND_MESSAGE, message: message, workspace: ENV[SLACK_WORKSPACE_KEY], channel: ENV[SLACK_CHANNEL_KEY], token: ENV[SLACK_TOKEN_KEY])) end def credentials? ENV[SLACK_WORKSPACE_KEY].present? && ENV[SLACK_CHANNEL_KEY].present? && ENV[SLACK_TOKEN_KEY].present? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
groundskeeper-bitcore-0.24.0 | lib/groundskeeper/slack.rb |
groundskeeper-bitcore-0.23.0 | lib/groundskeeper/slack.rb |