capistrano-notifications 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/capistrano-notifications.gemspec +3 -2
- data/lib/capistrano/notifications/adapter/base.rb +2 -2
- data/lib/capistrano/notifications/adapter/slack.rb +2 -8
- data/lib/capistrano/notifications/version.rb +1 -1
- data/lib/capistrano/notifications.rb +2 -0
- data/lib/capistrano/tasks/notifications.rake +24 -42
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b06e7740bac372fe30fde45fe126e4ce7844b4
|
4
|
+
data.tar.gz: bf6f315f2601a0fbdf945e9a68d9a27e6fb370c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a76d78038ec573da4305e823351453928a5ae36cba1228a8d603d4d88437e631eaf858aa1767ca1c96e5b48741189f52f51afa464acb89286c0f967ad6a382ca
|
7
|
+
data.tar.gz: 327c0cf4b8dd9d3015f21b4dc2a53c58e0d4f743b4ccdf097ce0dd30882e2d9faa6348a4654881d15eb64e9ebfeb7ceb372237d0ae5baf5b50e451c5f4ad546c
|
data/.gitignore
CHANGED
@@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
-
spec.add_development_dependency 'capistrano', '~> 3.3
|
23
|
+
spec.add_development_dependency 'capistrano', '~> 3.3'
|
24
24
|
|
25
|
-
spec.add_dependency 'faraday'
|
25
|
+
spec.add_dependency 'faraday', '~> 0.9'
|
26
|
+
spec.add_dependency 'activesupport', '~> 4.1'
|
26
27
|
end
|
@@ -12,13 +12,13 @@ module Capistrano
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def notify(members = [], message = '')
|
15
|
-
members.each { |member| send_notification(member, message) }
|
15
|
+
Array.wrap(members).each { |member| send_notification(member, message) }
|
16
16
|
end
|
17
17
|
|
18
18
|
protected
|
19
19
|
|
20
20
|
def send_notification(_member, _message)
|
21
|
-
raise NoMethodError, 'send_notification is not
|
21
|
+
raise NoMethodError, 'send_notification is not implemented.'
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -6,7 +6,7 @@ module Capistrano
|
|
6
6
|
attr_reader :team, :token
|
7
7
|
|
8
8
|
protected
|
9
|
-
def send_notification(
|
9
|
+
def send_notification(member, message, username = 'Capistrano Notification')
|
10
10
|
connection = Faraday.new(url: "https://#{team}.slack.com") do |faraday|
|
11
11
|
faraday.request :url_encoded
|
12
12
|
faraday.adapter Faraday.default_adapter
|
@@ -16,13 +16,7 @@ module Capistrano
|
|
16
16
|
req.headers['User-Agent'] = "Capistrano Notification #{Capistrano::Notifications::VERSION}"
|
17
17
|
req.body = {
|
18
18
|
token: token,
|
19
|
-
payload: {
|
20
|
-
channel: "#{_member}",
|
21
|
-
username: "#{fetch(:application)} #{fetch(:env)}",
|
22
|
-
text: _message,
|
23
|
-
icon_emoji: ':grin:',
|
24
|
-
mrkdwn: true
|
25
|
-
}.to_json
|
19
|
+
payload: {channel: member, username: username, text: message, icon_emoji: ':grin:', mrkdwn: true}.to_json
|
26
20
|
}
|
27
21
|
end
|
28
22
|
end
|
@@ -1,49 +1,29 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# examples:
|
3
3
|
#
|
4
|
-
#
|
4
|
+
# * Slack
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# set :notify, -> {
|
7
|
+
# {
|
8
|
+
# to: %w(@scorix #deploy),
|
9
|
+
# via: :slack,
|
10
|
+
# options: {team: 'my-team', token: 'token'}
|
11
|
+
# }
|
12
|
+
# }
|
7
13
|
#
|
8
|
-
|
9
|
-
#
|
10
|
-
set :notify_adapter, -> { nil }
|
11
|
-
|
12
|
-
#
|
13
|
-
# default options:
|
14
|
-
#
|
15
|
-
# * Slack:
|
16
|
-
#
|
17
|
-
# team **required**
|
18
|
-
#
|
19
|
-
# token **required**
|
20
|
-
#
|
21
|
-
# example:
|
22
|
-
#
|
23
|
-
# set :notify_default_options, team: 'my-team', token: 'token'
|
24
|
-
#
|
25
|
-
set :notify_default_options, -> { {} }
|
26
|
-
|
27
|
-
#
|
28
|
-
# subscribers
|
29
|
-
#
|
30
|
-
# * Slack:
|
31
|
-
#
|
32
|
-
# subscribers could be a user, or a channel
|
33
|
-
#
|
34
|
-
# example:
|
35
|
-
#
|
36
|
-
# set :subscribers, -> { ['@scorix', '#deploy'] }
|
37
|
-
#
|
38
|
-
set :subscribers, -> { [] }
|
14
|
+
set :notify, -> { {} }
|
39
15
|
|
40
16
|
namespace :notify do
|
41
17
|
|
18
|
+
def notify
|
19
|
+
fetch(:notify) { {} }
|
20
|
+
end
|
21
|
+
|
42
22
|
def find_adapter
|
43
|
-
adapter =
|
23
|
+
adapter = notify[:via]
|
44
24
|
|
45
25
|
if adapter
|
46
|
-
adapter = Capistrano::Notifications::Adapter.const_get(adapter.to_sym).setup(
|
26
|
+
adapter = Capistrano::Notifications::Adapter.const_get(adapter.to_s.classify.to_sym).setup(notify[:options])
|
47
27
|
|
48
28
|
begin
|
49
29
|
yield adapter
|
@@ -55,17 +35,19 @@ namespace :notify do
|
|
55
35
|
|
56
36
|
task :starting do
|
57
37
|
find_adapter do |adapter|
|
58
|
-
adapter.notify(
|
38
|
+
adapter.notify(notify[:to], "#{local_user} is deploying the `#{fetch(:branch)}` branch...")
|
59
39
|
end
|
60
40
|
end
|
61
41
|
|
62
42
|
task :finishing do
|
63
43
|
find_adapter do |adapter|
|
64
|
-
adapter.notify(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
44
|
+
adapter.notify(notify[:to],
|
45
|
+
t(:revision_log_message,
|
46
|
+
branch: fetch(:branch),
|
47
|
+
user: local_user,
|
48
|
+
sha: fetch(:current_revision),
|
49
|
+
release: fetch(:release_timestamp)),
|
50
|
+
"#{fetch(:application)} #{fetch(:env)}".titleize)
|
69
51
|
end
|
70
52
|
end
|
71
53
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-notifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- scorix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,28 +44,42 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.3
|
47
|
+
version: '3.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.3
|
54
|
+
version: '3.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: faraday
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.9'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.1'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '4.1'
|
69
83
|
description: Send deploy notifications to subscribers.
|
70
84
|
email:
|
71
85
|
- scorix@gmail.com
|