capistrano3-notification 0.0.2 → 0.0.3

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: 02ca023f98b66f7e8a2bbc10a3c48395750b8bc6
4
- data.tar.gz: 842aabdc6ddc273173119522c54bbd4a54722137
3
+ metadata.gz: cfc1a1b79468f75feab46ebf083d00d8411075b8
4
+ data.tar.gz: 74986a47b8b44aece6bcf10ae7d6170b2081f7a4
5
5
  SHA512:
6
- metadata.gz: c2225172dda50a9acf4129f68017003e0ee2b87255585d7470fc0db661251fcc4999923b6e8711621f6dfd5414ef55a5173cc91314d09f07ef7c04382a57226d
7
- data.tar.gz: e7c4b1b636a4711c944a34efff4aa5981b3ad2316d1081ccf8d687d8f31c88ebfe33c0c859c8989c4bcf3c6ebb21c7e2a1d989c76e67b15fb32322b26aed8987
6
+ metadata.gz: df0313a786ae120a27705d7822c95a1955deb9165370c0cbe8e455075b954dc1ce9eb41929ee06f8591cae1e8b447a0830637a5888be50917761a1ee66a01a63
7
+ data.tar.gz: dc32646913a04454039840f4e2e26edc9716c10891650874e7c06170e03ceacf0db8538ddfc7eae94621a14259d4a6c8c7bb11126dbf56b60109ca345f7a0e50
data/README.md CHANGED
@@ -30,6 +30,17 @@ set :irc_user, 'myproject' # default: 'capistrano'
30
30
  set :notification, -> { "#{fetch(:application)} was deployed to #{fetch(:stage)}" } # this message is default
31
31
  ```
32
32
 
33
+ ### Slack notification
34
+
35
+ ```ruby
36
+ set :slack_webhook_url, 'https://hooks.slack.com/services/EX/AM/PLE'
37
+ set :slack_user, 'myproject' # default: 'capistrano'
38
+ set :slack_channel, '#notice'
39
+ set :slack_icon, ':ghost:' # use emoji
40
+ set :slack_icon, 'http://example.com/icon.png' # use image
41
+ set :notification, -> { "#{fetch(:application)} was deployed to #{fetch(:stage)}" } # this message is default
42
+ ```
43
+
33
44
  ### Other notification
34
45
 
35
46
  **contribute me!**
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'capistrano'
22
22
  spec.add_dependency 'shout-bot'
23
+ spec.add_dependency 'slack-notifier'
23
24
 
24
25
  spec.add_development_dependency 'bundler', '~> 1.6'
25
26
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -2,28 +2,53 @@ namespace :load do
2
2
  task :defaults do
3
3
  set :irc_port, 6667
4
4
  set :irc_user, 'capistrano'
5
+ set :slack_user, 'capistrano'
5
6
  set :notification, -> { "#{fetch(:application)} was deployed to #{fetch(:stage)}" }
6
7
  end
7
8
  end
8
9
 
9
10
  namespace :notification do
10
11
  task :notify do
11
- %w(irc).each do |adapter|
12
+ %w(irc slack).each do |adapter|
12
13
  invoke "notification:#{adapter}"
13
14
  end
14
15
  end
15
16
 
16
17
  task :irc do
17
- require 'shout-bot'
18
18
  user = fetch(:irc_user)
19
19
  host = fetch(:irc_host)
20
20
  port = fetch(:irc_port)
21
21
  channel = fetch(:irc_channel)
22
22
  message = fetch(:notification)
23
23
  return unless user && host && port && channel && message
24
+ require 'shout-bot'
24
25
  url = "irc://#{user}@#{host}:#{port}/#{channel}"
25
26
  ShoutBot.shout(url) { |irc| irc.say message }
26
27
  end
27
28
 
29
+ task :slack do
30
+ webhook_url = fetch(:slack_webhook_url)
31
+ name = fetch(:slack_user) || nil
32
+ channel = fetch(:slack_channel) || nil
33
+ icon = fetch(:slack_icon) || nil
34
+ message = fetch(:notification)
35
+ return unless webhook_url && message
36
+ require 'slack-notifier'
37
+ notifier_options = { username: name, channel: channel }.reject { |_x, y| y.nil? }
38
+ icon_type = case icon
39
+ when /^:.+:/
40
+ :icon_emoji
41
+ when /^http/
42
+ :icon_url
43
+ else
44
+ nil
45
+ end
46
+ ping_options = {}.tap do |h|
47
+ h[icon_type] = icon if icon_type
48
+ end
49
+ notifier = Slack::Notifier.new webhook_url, notifier_options
50
+ notifier.ping message, ping_options
51
+ end
52
+
28
53
  after 'deploy:finished', 'notification:notify'
29
54
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano3
2
2
  module Notification
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano3-notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - masarakki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-29 00:00:00.000000000 Z
11
+ date: 2014-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: slack-notifier
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement