capistrano-jabber-notifications 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile
CHANGED
@@ -18,6 +18,5 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.
|
22
|
-
spec.add_development_dependency "rake"
|
21
|
+
spec.add_dependency 'xmpp4r', '=0.5'
|
23
22
|
end
|
@@ -1,9 +1,88 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require 'xmpp4r'
|
4
|
+
require 'xmpp4r/roster/helper/roster'
|
1
5
|
require "capistrano/jabber/notifications/version"
|
2
6
|
|
3
7
|
module Capistrano
|
4
8
|
module Jabber
|
5
9
|
module Notifications
|
6
|
-
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
attr_accessor :options
|
14
|
+
|
15
|
+
def deploy_started(stage)
|
16
|
+
send_jabber_message("cap deploy #{stage} by :username started at #{Time.now}")
|
17
|
+
end
|
18
|
+
|
19
|
+
def deploy_completed(stage)
|
20
|
+
send_jabber_message("cap deploy #{stage} by :username completed at #{Time.now}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def rollback_started(stage)
|
24
|
+
send_jabber_message("cap deploy:rollback #{stage} by :username started at #{Time.now}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def rollback_completed(stage)
|
28
|
+
send_jabber_message("cap deploy:rollback #{stage} by :username completed at #{Time.now}")
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def send_jabber_message(msg)
|
34
|
+
msg.gsub!(':username', username) if msg[':username']
|
35
|
+
|
36
|
+
client = ::Jabber::Client.new(options[:uid])
|
37
|
+
client.connect(options[:server])
|
38
|
+
client.auth(options[:password])
|
39
|
+
notification_group = options[:group]
|
40
|
+
|
41
|
+
roster = ::Jabber::Roster::Helper.new(client)
|
42
|
+
|
43
|
+
mainthread = Thread.current
|
44
|
+
roster.add_query_callback { |iq| mainthread.wakeup }
|
45
|
+
Thread.stop
|
46
|
+
|
47
|
+
roster.find_by_group(notification_group).each {|item|
|
48
|
+
client.send(item.jid)
|
49
|
+
m = ::Jabber::Message.new(item.jid, msg).set_type(:normal).set_id('1').set_subject('hi')
|
50
|
+
client.send(m)
|
51
|
+
}
|
52
|
+
|
53
|
+
client.close
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
def username
|
58
|
+
@username ||= [`whoami`, `hostname`].map(&:strip).join('@')
|
59
|
+
end
|
60
|
+
end
|
7
61
|
end
|
8
62
|
end
|
9
63
|
end
|
64
|
+
|
65
|
+
|
66
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
67
|
+
|
68
|
+
namespace :deploy do
|
69
|
+
namespace :jabber do
|
70
|
+
%w(deploy_started deploy_completed rollback_started rollback_completed).each do |m|
|
71
|
+
task m.to_sym do
|
72
|
+
Capistrano::Jabber::Notifications.options = {
|
73
|
+
uid: fetch(:jabber_uid),
|
74
|
+
server: fetch(:jabber_server),
|
75
|
+
password: fetch(:jabber_password),
|
76
|
+
group: fetch(:jabber_group)
|
77
|
+
}
|
78
|
+
Capistrano::Jabber::Notifications.send(m, fetch(:stage))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
before 'deploy', 'deploy:jabber:deploy_started'
|
85
|
+
after 'deploy', 'deploy:jabber:deploy_completed'
|
86
|
+
before 'deploy:rollback', 'deploy:jabber:rollback_started'
|
87
|
+
after 'deploy:rollback', 'deploy:jabber:rollback_completed'
|
88
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-jabber-notifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,37 +12,16 @@ cert_chain: []
|
|
12
12
|
date: 2013-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
15
|
+
name: xmpp4r
|
16
|
+
requirement: &8732140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
22
|
-
type: :
|
21
|
+
version: '0.5'
|
22
|
+
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.3'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rake
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
24
|
+
version_requirements: *8732140
|
46
25
|
description: Sending notifications about deploy to jabber
|
47
26
|
email:
|
48
27
|
- lazureykis@gmail.com
|
@@ -73,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
52
|
version: '0'
|
74
53
|
segments:
|
75
54
|
- 0
|
76
|
-
hash:
|
55
|
+
hash: 2971062857575580786
|
77
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
57
|
none: false
|
79
58
|
requirements:
|
@@ -82,10 +61,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
61
|
version: '0'
|
83
62
|
segments:
|
84
63
|
- 0
|
85
|
-
hash:
|
64
|
+
hash: 2971062857575580786
|
86
65
|
requirements: []
|
87
66
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.11
|
89
68
|
signing_key:
|
90
69
|
specification_version: 3
|
91
70
|
summary: Sending notifications about deploy to jabber
|