capistrano-jabber-notifications 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,32 +11,40 @@ module Capistrano
11
11
  class << self
12
12
 
13
13
  attr_accessor :options
14
+ attr_accessor :variables
14
15
 
15
- def deploy_started(stage)
16
- send_jabber_message("cap deploy #{stage} by :username started at #{Time.now}")
16
+ def deploy_started
17
+ send_jabber_message "deploy"
17
18
  end
18
19
 
19
- def deploy_completed(stage)
20
- send_jabber_message("cap deploy #{stage} by :username completed at #{Time.now}")
20
+ def deploy_completed
21
+ send_jabber_message "deploy", true
21
22
  end
22
23
 
23
- def rollback_started(stage)
24
- send_jabber_message("cap deploy:rollback #{stage} by :username started at #{Time.now}")
24
+ def rollback_started
25
+ send_jabber_message "deploy:rollback"
25
26
  end
26
27
 
27
- def rollback_completed(stage)
28
- send_jabber_message("cap deploy:rollback #{stage} by :username completed at #{Time.now}")
28
+ def rollback_completed
29
+ send_jabber_message "deploy:rollback", true
29
30
  end
30
31
 
31
32
  private
32
33
 
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]
34
+ def send_jabber_message(action, completed = false)
35
+ msg = []
36
+ msg << "#{completed ? 'Completed' : 'Started'} #{action} on #{variables[:stage]} by #{username}"
37
+ msg << "Time #{Time.now.strftime('%Y%jT%H%MZ')}"
38
+ msg << "Application #{variables[:application]}"
39
+ msg << "Branch #{variables[:branch]}"
40
+ msg << "Revision #{options[:real_revision]}"
41
+ msg << "Release name #{options[:release_name]}"
42
+ msg = msg.join("\r\n")
43
+
44
+ client = ::Jabber::Client.new(options[:uid].to_s)
45
+ client.connect(options[:server].to_s)
46
+ client.auth(options[:password].to_s)
47
+ notification_group = options[:group].to_s
40
48
 
41
49
  roster = ::Jabber::Roster::Helper.new(client)
42
50
 
@@ -46,7 +54,7 @@ module Capistrano
46
54
 
47
55
  roster.find_by_group(notification_group).each {|item|
48
56
  client.send(item.jid)
49
- m = ::Jabber::Message.new(item.jid, msg).set_type(:normal).set_id('1').set_subject('hi')
57
+ m = ::Jabber::Message.new(item.jid, msg).set_type(:normal).set_id('1').set_subject('deploy')
50
58
  client.send(m)
51
59
  }
52
60
 
@@ -73,9 +81,13 @@ Capistrano::Configuration.instance(:must_exist).load do
73
81
  uid: fetch(:jabber_uid),
74
82
  server: fetch(:jabber_server),
75
83
  password: fetch(:jabber_password),
76
- group: fetch(:jabber_group)
84
+ group: fetch(:jabber_group),
85
+ real_revision: fetch(:real_revision),
86
+ release_name: fetch(:release_name),
87
+ action: m.to_sym
77
88
  }
78
- Capistrano::Jabber::Notifications.send(m, fetch(:stage))
89
+ Capistrano::Jabber::Notifications.variables = variables
90
+ Capistrano::Jabber::Notifications.send m
79
91
  end
80
92
  end
81
93
  end
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  module Jabber
3
3
  module Notifications
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  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.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xmpp4r
16
- requirement: &8732140 !ruby/object:Gem::Requirement
16
+ requirement: &9495840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *8732140
24
+ version_requirements: *9495840
25
25
  description: Sending notifications about deploy to jabber
26
26
  email:
27
27
  - lazureykis@gmail.com
@@ -52,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  segments:
54
54
  - 0
55
- hash: 2971062857575580786
55
+ hash: 1282198561129148951
56
56
  required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  segments:
63
63
  - 0
64
- hash: 2971062857575580786
64
+ hash: 1282198561129148951
65
65
  requirements: []
66
66
  rubyforge_project:
67
67
  rubygems_version: 1.8.11