class Mina::Slack::Promulgator::Helper
Public Class Methods
default_github_url()
click to toggle source
# File lib/mina/slack/promulgator/helper.rb, line 15 def self.default_github_url remote_origin_url = `git config --get remote.origin.url` path = remote_origin_url.gsub("git@", "").gsub(".git", "").gsub("github.com:", "github.com/") "https://#{path}".strip end
failure_message(emoji, repository, github_url)
click to toggle source
# File lib/mina/slack/promulgator/helper.rb, line 25 def self.failure_message(emoji, repository, github_url) "#{emoji} [#{project_name(repository)}] deploy failed: #{github_url}/commit/'\"$GIT_HASH\"'" end
failure_payload(text, channel, name, application_emoji)
click to toggle source
# File lib/mina/slack/promulgator/helper.rb, line 33 def self.failure_payload(text, channel, name, application_emoji) %{{"attachments": [ { "fallback": "#{text}", "color": "danger", "text": "#{text}" } ], "channel": "#{channel}", "username": "#{name}", "icon_emoji": "#{application_emoji}"}} end
project_name(repository)
click to toggle source
# File lib/mina/slack/promulgator/helper.rb, line 10 def self.project_name(repository) regex = /:(\w+)\/((\w|-)+)/ repository.match(regex)[2] end
requirements_check(slack_promulgator_webhook_url)
click to toggle source
# File lib/mina/slack/promulgator/helper.rb, line 6 def self.requirements_check(slack_promulgator_webhook_url) raise "Must set 'slack_promulgator_webhook_url' in your deploy file for promulgator to work" unless slack_promulgator_webhook_url end
success_message(emoji, repository, github_url)
click to toggle source
# File lib/mina/slack/promulgator/helper.rb, line 21 def self.success_message(emoji, repository, github_url) "#{emoji} [#{project_name(repository)}] deployed: #{github_url}/commit/'\"$GIT_HASH\"'" end
success_payload(text, channel, name, application_emoji)
click to toggle source
# File lib/mina/slack/promulgator/helper.rb, line 29 def self.success_payload(text, channel, name, application_emoji) %{{"text": "#{text}", "channel": "#{channel}", "username": "#{name}", "icon_emoji": "#{application_emoji}"}} end