Sha256: e7428417cec4a35f65ff6af255054d12eb7a9ea7317415561bbc777281f74f9a

Contents?: true

Size: 764 Bytes

Versions: 2

Compression:

Stored size: 764 Bytes

Contents

require 'papa/command/base'
require 'papa/helper/config'
require 'json'

module Papa
  module Command
    module Slack
      class SendMessage < Command::Base
        def initialize(build_type, hostname, action)
          @build_type = build_type
          @hostname = hostname
          @action = action

          command = "curl -X POST --data-urlencode 'payload=#{payload.to_json}' #{webhook_url}"
          super(command)
        end

        private

        def payload
          url = "https://#{@hostname}.indinerocorp.com"
          {
            'text' => "<!channel> Deployment to <#{url}|#{@hostname}> #{@action}."
          }
        end

        def webhook_url
          Helper::Config.read["slack_webhook"]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
papa-0.7.2 lib/papa/command/slack/send_message.rb
papa-0.7.1 lib/papa/command/slack/send_message.rb