class Object
Public Instance Methods
announced_application_name()
click to toggle source
# File lib/mina/slack/tasks.rb, line 47 def announced_application_name (+'').tap do |output| output << fetch(:slack_application) output << " #{fetch(:branch)}" if fetch(:branch) output << " (#{fetch(:deployed_revision)})" if fetch(:deployed_revision) end end
post_slack_message(message)
click to toggle source
# File lib/mina/slack/tasks.rb, line 55 def post_slack_message(message) return if fetch(:simulate) # Parse the URI and handle the https connection uri = URI.parse("https://#{fetch(:slack_subdomain)}.slack.com/services/hooks/incoming-webhook?token=#{fetch(:slack_token)}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE payload = { 'parse' => 'full', 'channel' => fetch(:slack_room), 'username' => fetch(:slack_username), 'text' => message, 'icon_emoji' => fetch(:slack_emoji) } # Create the post request and setup the form data request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(payload: payload.to_json) # Make the actual request to the API http.request(request) end