Class: Mina::Slack::Promulgator::Helper
- Inherits:
-
Object
- Object
- Mina::Slack::Promulgator::Helper
- Defined in:
- lib/mina/slack/promulgator/helper.rb
Class Method Summary collapse
- .default_github_url ⇒ Object
- .failure_message(emoji, repository, github_url) ⇒ Object
- .failure_payload(text, channel, name, application_emoji) ⇒ Object
- .project_name(repository) ⇒ Object
- .requirements_check(slack_promulgator_webhook_url) ⇒ Object
- .success_message(emoji, repository, github_url) ⇒ Object
- .success_payload(text, channel, name, application_emoji) ⇒ Object
Class Method Details
.default_github_url ⇒ Object
15 16 17 18 19 |
# 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) ⇒ Object
25 26 27 |
# File 'lib/mina/slack/promulgator/helper.rb', line 25 def self.(emoji, repository, github_url) "#{emoji} [#{project_name(repository)}] deploy failed: #{github_url}/commit/'\"$GIT_HASH\"'" end |
.failure_payload(text, channel, name, application_emoji) ⇒ Object
33 34 35 |
# 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) ⇒ Object
10 11 12 13 |
# 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) ⇒ Object
6 7 8 |
# 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) ⇒ Object
21 22 23 |
# File 'lib/mina/slack/promulgator/helper.rb', line 21 def self.(emoji, repository, github_url) "#{emoji} [#{project_name(repository)}] deployed: #{github_url}/commit/'\"$GIT_HASH\"'" end |
.success_payload(text, channel, name, application_emoji) ⇒ Object
29 30 31 |
# 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 |