Class: Capistrano::Wearerequired::SlackistranoExpandedGitMessaging
- Inherits:
-
SlackistranoMessagingColors
- Object
- Slackistrano::Messaging::Base
- SlackistranoMessagingElements
- SlackistranoMessagingColors
- Capistrano::Wearerequired::SlackistranoExpandedGitMessaging
- Defined in:
- lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb
Instance Method Summary collapse
- #author_icon ⇒ Object
- #author_link ⇒ Object
-
#current_revision ⇒ Object
Get current revision.
-
#current_revision_url ⇒ Object
Get current revision URL.
- #footer ⇒ Object
- #footer_icon ⇒ Object
-
#payload_for_reverting ⇒ Object
Suppress reverting message.
-
#payload_for_updated ⇒ Object
More detailed updated message.
-
#payload_for_updating ⇒ Object
Suppress updating message.
-
#previous_revision ⇒ Object
Get previous revision.
-
#repo ⇒ Object
Get individual parts of the repo_url.
-
#revision ⇒ Object
Get information about the revision being deployed.
-
#revision_compare_url ⇒ Object
Get revision comparison.
Methods inherited from SlackistranoMessagingColors
#payload_for_failed, #payload_for_reverted
Methods inherited from SlackistranoMessagingElements
Constructor Details
This class inherits a constructor from Capistrano::Wearerequired::SlackistranoMessagingElements
Instance Method Details
#author_icon ⇒ Object
65 66 67 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 65 def "https://required.com/content/themes/required-valencia/assets/img/character-%{name}-300x300.png" % { name: deployer.downcase } end |
#author_link ⇒ Object
69 70 71 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 69 def "https://required.com/team/%{name}/" % { name: deployer.downcase } end |
#current_revision ⇒ Object
Get current revision
16 17 18 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 16 def current_revision fetch(:current_revision) end |
#current_revision_url ⇒ Object
Get current revision URL
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 40 def current_revision_url "<https://%{host}/%{owner}/%{repo}/%{commit}/%{revision}|%{revision_short}@%{branch}>" % { :host => repo[:host], :owner => repo[:owner], :repo => repo[:repo], :commit => 'bitbucket.org' == repo[:host] ? 'commits' : 'commit', :revision => current_revision, :revision_short => current_revision[0..10], :branch => branch } end |
#footer ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 85 def if repo.nil? || current_revision.nil? || previous_revision.nil? '' else 'Diff: ' + revision_compare_url end end |
#footer_icon ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 73 def if repo.nil? '' elsif 'bitbucket.org' == repo[:host] 'https://bitbucket.org/site/master/avatar/64/' elsif 'gitlab.com' == repo[:host] 'https://gitlab.com/uploads/system/project/avatar/13083/logo-extra-whitespace.png' elsif 'github.com' == repo[:host] 'https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png' end end |
#payload_for_reverting ⇒ Object
Suppress reverting message.
11 12 13 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 11 def payload_for_reverting nil end |
#payload_for_updated ⇒ Object
More detailed updated message.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 94 def payload_for_updated { attachments: [{ color: 'good', pretext: application + ' was successfully deployed :white_check_mark:', author_name: deployer.capitalize, author_icon: , author_link: , footer: , footer_icon: , fields: [{ title: 'Environment', value: stage.capitalize, short: true }, { title: 'Revision', value: revision, short: true }], fallback: application + ' was successfully deployed.' }] } end |
#payload_for_updating ⇒ Object
Suppress updating message.
6 7 8 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 6 def payload_for_updating nil end |
#previous_revision ⇒ Object
Get previous revision
21 22 23 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 21 def previous_revision fetch(:previous_revision) end |
#repo ⇒ Object
Get individual parts of the repo_url
26 27 28 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 26 def repo repo_url.match(/(git@|https:\/\/)(?<host>([\w\.@]+))(\/|:)(?<owner>[\w,\-,\_]+)\/(?<repo>[\w,\-,\_]+)(.git){0,1}((\/){0,1})/) end |
#revision ⇒ Object
Get information about the revision being deployed
31 32 33 34 35 36 37 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 31 def revision if repo.nil? || current_revision.nil? 'Unknown' else current_revision_url end end |
#revision_compare_url ⇒ Object
Get revision comparison
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/capistrano/wearerequired/slackistrano_extended_git_messaging.rb', line 53 def revision_compare_url "<https://%{host}/%{owner}/%{repo}/%{compare}/%{previous_revision}...%{current_revision}|%{revision_short}>" % { :host => repo[:host], :owner => repo[:owner], :repo => repo[:repo], :compare => 'bitbucket.org' == repo[:host] ? 'branches/compare' : 'compare', :current_revision => current_revision, :previous_revision => previous_revision, :revision_short => previous_revision[0..7] + '...' + current_revision[0..7] } end |