class Capistrano::Fireworks::SlackPost
Public Class Methods
new(hook_url: , attributes: )
click to toggle source
# File lib/capistrano/fireworks/slack.rb, line 4 def initialize(hook_url: , attributes: ) @uri, @attributes = URI(hook_url), attributes end
Public Instance Methods
call()
click to toggle source
# File lib/capistrano/fireworks/slack.rb, line 8 def call message = compose_message post(message) end
Private Instance Methods
compose_message()
click to toggle source
# File lib/capistrano/fireworks/slack.rb, line 15 def compose_message "<#{@attributes[:commit_url]}|#{@attributes[:branch]}(#{@attributes[:commit]} - #{@attributes[:subject]})> deployed to `#{@attributes[:name]}` by #{@attributes[:username]}!" end
post(text)
click to toggle source
# File lib/capistrano/fireworks/slack.rb, line 19 def post(text) req = Net::HTTP::Post.new(@uri) req.content_type = 'application/json' req.body = JSON.dump(text: text) http = Net::HTTP.new(@uri.hostname, @uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE res = http.request(req) puts res.body end