mina_slack_promulgator 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4194861d3772ccc75df47a4ef9187f4f12bbad9
4
- data.tar.gz: 386cacff0ad97f94af85a1fa9355a8d4e852d311
3
+ metadata.gz: 1256eb86cc82262d382bb8b81a82f85ccc98a9b7
4
+ data.tar.gz: c7e452770caedb2fa14c1d185f4770599800f02d
5
5
  SHA512:
6
- metadata.gz: 2296325c5b6cde5327908181817f267c9af942e926d8eff4580cb0579ea0e20e7faacf4a79b484dd29cda15c6a99326700182e2f10fcb36c135e1ef454ec6387
7
- data.tar.gz: 5fc08f501526234ee4632b4bfcab25bd5875ae9d6b0d33a7e2b9c0998d9dc47bff251f6da7cf453ee8897a358a7d0b41c667d5504c3ac6638dd10bc805d40602
6
+ metadata.gz: 0e9782453540900cbc2b87e1207d8e413856cd04652b9bcffdd4a5a4da9047cd70add9db65a98f0f5605960b783dd6077c16759b15cfb5c576df170c4afdc308
7
+ data.tar.gz: 215398cf4206617db990049354c5b1d83bc190af3ca624f00a376ab0f977091bcc7ae9e34e9c080070c1ecec622f42d999260287eb6b0494527dd0890dcd479c
data/README.md CHANGED
@@ -6,7 +6,9 @@ Simple mina deploy success/failure notifications to slack channels.
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'mina_slack_promulgator'
9
+ ```ruby
10
+ gem 'mina_slack_promulgator'
11
+ ```
10
12
 
11
13
  And then execute:
12
14
 
@@ -20,21 +22,35 @@ Or install it yourself as:
20
22
 
21
23
  Require within your mina deploy.rb:
22
24
 
23
- require 'mina/slack/promulgator'
24
-
25
+ ```ruby
26
+ require 'mina/slack/promulgator'
27
+ ```
28
+
29
+ Set the required mina variables:
30
+
31
+ ```ruby
32
+ set :slack_promulgator_webhook_url, "your slack webhook url"
33
+ set :slack_promulgator_channel, "slack channel, e.g. #general"
34
+ set :slack_promulgator_application_emoji, "emoji, e.g. :smile:"
35
+ ```
36
+
25
37
  Call success on launch in deploy.rb:
26
38
 
27
- to :launch do
28
- { ... other launch tasks ... }
29
- invoke :'slack:promulgator:success'
30
- end
31
-
39
+ ```ruby
40
+ to :launch do
41
+ { ... other launch tasks ... }
42
+ invoke :'slack:promulgator:success'
43
+ end
44
+ ```
45
+
32
46
  Call failure on clean in deploy.rb:
33
47
 
34
- to :clean do
35
- { ... other cleanup tasks ... }
36
- invoke :'slack:promulgator:failure'
37
- end
48
+ ```ruby
49
+ to :clean do
50
+ { ... other cleanup tasks ... }
51
+ invoke :'slack:promulgator:failure'
52
+ end
53
+ ```
38
54
 
39
55
  ## Contributing
40
56
 
@@ -10,35 +10,35 @@ set_default :slack_promulgator_failure_message_emoji, ':boom:'
10
10
  set_default :slack_promulgator_github_url, Mina::Slack::Promulgator::Helper.default_github_url
11
11
 
12
12
  namespace :slack do
13
-
13
+
14
14
  namespace :promulgator do
15
-
15
+
16
16
  task :success do
17
17
  Mina::Slack::Promulgator::Helper.requirements_check(slack_promulgator_webhook_url)
18
-
19
- message = Mina::Slack::Promulgator::Helper.success_message(slack_promulgator_success_message_emoji, project_name, slack_promulgator_github_url)
18
+
19
+ message = Mina::Slack::Promulgator::Helper.success_message(slack_promulgator_success_message_emoji, repository, slack_promulgator_github_url)
20
20
  payload = Mina::Slack::Promulgator::Helper.success_payload(message, slack_promulgator_channel, slack_promulgator_name, slack_promulgator_application_emoji)
21
-
21
+
22
22
  queue %{
23
23
  export GIT_HASH=$(cd #{deploy_to}/scm && git rev-parse #{commit || branch})
24
24
  echo "-----> Posting Deploy Success to Slack #{slack_promulgator_channel}"
25
25
  curl -X POST --data-urlencode 'payload=#{payload}' #{slack_promulgator_webhook_url}
26
26
  }
27
27
  end
28
-
28
+
29
29
  task :failure do
30
30
  Mina::Slack::Promulgator::Helper.requirements_check(slack_promulgator_webhook_url)
31
-
32
- message = Mina::Slack::Promulgator::Helper.failure_message(slack_promulgator_failure_message_emoji, project_name, slack_promulgator_github_url)
31
+
32
+ message = Mina::Slack::Promulgator::Helper.failure_message(slack_promulgator_failure_message_emoji, repository, slack_promulgator_github_url)
33
33
  payload = Mina::Slack::Promulgator::Helper.failure_payload(message, slack_promulgator_channel, slack_promulgator_name, slack_promulgator_application_emoji)
34
-
34
+
35
35
  queue %{
36
36
  export GIT_HASH=$(cd #{deploy_to}/scm && git rev-parse #{commit || branch})
37
37
  echo "-----> Posting Deploy Failure to Slack #{slack_promulgator_channel}"
38
38
  curl -X POST --data-urlencode 'payload=#{payload}' #{slack_promulgator_webhook_url}
39
39
  }
40
40
  end
41
-
41
+
42
42
  end
43
-
44
- end
43
+
44
+ end
@@ -2,33 +2,38 @@ module Mina
2
2
  module Slack
3
3
  module Promulgator
4
4
  class Helper
5
-
5
+
6
6
  def self.requirements_check(slack_promulgator_webhook_url)
7
7
  raise "Must set 'slack_promulgator_webhook_url' in your deploy file for promulgator to work" unless slack_promulgator_webhook_url
8
8
  end
9
-
9
+
10
+ def self.project_name(repository)
11
+ regex = /:(\w+)\/((\w|-)+)/
12
+ repository.match(regex)[2]
13
+ end
14
+
10
15
  def self.default_github_url
11
16
  remote_origin_url = `git config --get remote.origin.url`
12
17
  path = remote_origin_url.gsub("git@", "").gsub(".git", "").gsub("github.com:", "github.com/")
13
18
  "https://#{path}".strip
14
19
  end
15
-
16
- def self.success_message(emoji, project_name, github_url)
17
- "#{emoji} [#{project_name}] deployed: #{github_url}/commit/'\"$GIT_HASH\"'"
20
+
21
+ def self.success_message(emoji, repository, github_url)
22
+ "#{emoji} [#{project_name(repository)}] deployed: #{github_url}/commit/'\"$GIT_HASH\"'"
18
23
  end
19
-
20
- def self.failure_message(emoji, project_name, github_url)
21
- "#{emoji} [#{project_name}] deploy failed: #{github_url}/commit/'\"$GIT_HASH\"'"
24
+
25
+ def self.failure_message(emoji, repository, github_url)
26
+ "#{emoji} [#{project_name(repository)}] deploy failed: #{github_url}/commit/'\"$GIT_HASH\"'"
22
27
  end
23
28
 
24
29
  def self.success_payload(text, channel, name, application_emoji)
25
30
  %{{"text": "#{text}", "channel": "#{channel}", "username": "#{name}", "icon_emoji": "#{application_emoji}"}}
26
31
  end
27
-
32
+
28
33
  def self.failure_payload(text, channel, name, application_emoji)
29
34
  %{{"attachments": [ { "fallback": "#{text}", "color": "danger", "text": "#{text}" } ], "channel": "#{channel}", "username": "#{name}", "icon_emoji": "#{application_emoji}"}}
30
35
  end
31
-
36
+
32
37
  end
33
38
  end
34
39
  end
@@ -1,7 +1,7 @@
1
1
  module Mina
2
2
  module Slack
3
3
  module Promulgator
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina_slack_promulgator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Closson
@@ -9,34 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-01 00:00:00.000000000 Z
12
+ date: 2015-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.5'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.5'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  description: Mina Deploy Notifications in Slack.
@@ -47,7 +47,7 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
- - .gitignore
50
+ - ".gitignore"
51
51
  - Gemfile
52
52
  - LICENSE.txt
53
53
  - README.md
@@ -66,17 +66,17 @@ require_paths:
66
66
  - lib
67
67
  required_ruby_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.1.5
79
+ rubygems_version: 2.4.5
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Mina Deploy Notifications in Slack