Sha256: 48e3aa805ad2ff12b675bf6ca12c52d0be6dfc61047c0e06b76feb3db0453630
Contents?: true
Size: 1.13 KB
Versions: 7
Compression:
Stored size: 1.13 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.fetch(SLACK_WORKSPACE_KEY, nil), channel: ENV.fetch(SLACK_CHANNEL_KEY, nil), token: ENV.fetch(SLACK_TOKEN_KEY, nil))) end def credentials? !ENV.fetch(SLACK_WORKSPACE_KEY, "").empty? && !ENV.fetch(SLACK_CHANNEL_KEY, "").empty? && !ENV.fetch(SLACK_TOKEN_KEY, "").empty? end end end
Version data entries
7 entries across 7 versions & 1 rubygems