wcc-xmpp-notificator 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +24 -0
- data/assets/template.d/xmpp-body.plain.erb +1 -4
- data/lib/wcc-xmpp-notificator.rb +12 -32
- metadata +9 -8
- data/assets/template.d/xmpp-subject.plain.erb +0 -1
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
wcc-xmpp-notificator
|
2
|
+
====================
|
3
|
+
|
4
|
+
This adds XMPP/Jabber support to [wcc](https://github.com/cmur2/wcc) encapsuled
|
5
|
+
in a separate gem.
|
6
|
+
|
7
|
+
Note: This notificator does not need to have an (and even not supports establishing some)
|
8
|
+
authorization/subscription to talk to the recipients jabber accounts.
|
9
|
+
|
10
|
+
What you need to add to your conf.yml:
|
11
|
+
|
12
|
+
conf:
|
13
|
+
[...]
|
14
|
+
# jid is the address wcc will talk from
|
15
|
+
xmpp:
|
16
|
+
jid: wcc@example.com/wcc
|
17
|
+
password: s3cr3t
|
18
|
+
|
19
|
+
recipients:
|
20
|
+
[...]
|
21
|
+
- me:
|
22
|
+
[...]
|
23
|
+
# address to be notified via Jabber
|
24
|
+
- xmpp: me@mydomain.com
|
@@ -1,9 +1,6 @@
|
|
1
1
|
<% if data.diff.nil? %>
|
2
2
|
Checked <%= data.site.uri.to_s %> the first time so no diff was possible.
|
3
3
|
<% else %>
|
4
|
-
|
5
|
-
|
4
|
+
<%= data.site.uri.to_s %> changed:
|
6
5
|
<%= data.diff.to_s %>
|
7
|
-
|
8
|
-
nHunks: <%= data.diff.nhunks %>, nIns: <%= data.diff.ninsertions %>, nDel: <%= data.diff.ndeletions %>, nLinesC: <%= data.diff.nlinesc %>, nCharsC: <%= data.diff.ncharsc %>
|
9
6
|
<% end %>
|
data/lib/wcc-xmpp-notificator.rb
CHANGED
@@ -3,8 +3,7 @@ require 'xmpp4r/client'
|
|
3
3
|
|
4
4
|
class XMPPNotificator
|
5
5
|
@@client = nil
|
6
|
-
@@
|
7
|
-
@@body_tpl = nil
|
6
|
+
@@tpl = {}
|
8
7
|
|
9
8
|
def initialize(opts)
|
10
9
|
@jid = Jabber::JID.new(opts)
|
@@ -12,11 +11,9 @@ class XMPPNotificator
|
|
12
11
|
|
13
12
|
def notify!(data)
|
14
13
|
# prepare message
|
15
|
-
|
16
|
-
body = self.class.get_body_tpl.result(binding)
|
14
|
+
body = self.class.get_tpl(:body, 'xmpp-body.plain.erb').result(binding)
|
17
15
|
m = Jabber::Message.new(@jid, body)
|
18
16
|
m.type = :normal
|
19
|
-
m.subject = subject
|
20
17
|
# send it
|
21
18
|
c = self.class.get_client
|
22
19
|
c.send(m) unless c.nil?
|
@@ -63,38 +60,21 @@ class XMPPNotificator
|
|
63
60
|
@@client
|
64
61
|
end
|
65
62
|
|
66
|
-
def self.
|
67
|
-
if @@
|
68
|
-
@@
|
69
|
-
if @@
|
70
|
-
src_path = Pathname.new(__FILE__) + "../../assets/template.d
|
63
|
+
def self.get_tpl(id, name)
|
64
|
+
if @@tpl[id].nil?
|
65
|
+
@@tpl[id] = WCC::Prog.load_template(name)
|
66
|
+
if @@tpl[id].nil?
|
67
|
+
src_path = Pathname.new(__FILE__) + "../../assets/template.d/#{name}"
|
71
68
|
t = File.open(src_path, 'r') { |f| f.read }
|
72
|
-
WCC::Prog.save_template(
|
69
|
+
WCC::Prog.save_template(name, t)
|
73
70
|
# retry load
|
74
|
-
@@
|
71
|
+
@@tpl[id] = WCC::Prog.load_template(name)
|
75
72
|
end
|
76
|
-
if @@
|
77
|
-
@@
|
73
|
+
if @@tpl[id].nil?
|
74
|
+
@@tpl[id] = ERB.new("ERROR LOADING TEMPLATE '#{name}'!", 0, "<>")
|
78
75
|
end
|
79
76
|
end
|
80
|
-
@@
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.get_body_tpl
|
84
|
-
if @@body_tpl.nil?
|
85
|
-
@@body_tpl = WCC::Prog.load_template('xmpp-body.plain.erb')
|
86
|
-
if @@body_tpl.nil?
|
87
|
-
src_path = Pathname.new(__FILE__) + "../../assets/template.d/xmpp-body.plain.erb"
|
88
|
-
t = File.open(src_path, 'r') { |f| f.read }
|
89
|
-
WCC::Prog.save_template('xmpp-body.plain.erb', t)
|
90
|
-
# retry load
|
91
|
-
@@body_tpl = WCC::Prog.load_template('xmpp-body.plain.erb')
|
92
|
-
end
|
93
|
-
if @@body_tpl.nil?
|
94
|
-
@@body_tpl = ERB.new("ERROR LOADING TEMPLATE 'xmpp-body.plain.erb'!", 0, "<>")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
@@body_tpl
|
77
|
+
@@tpl[id]
|
98
78
|
end
|
99
79
|
end
|
100
80
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wcc-xmpp-notificator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christian Nicolai
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: xmpp4r
|
@@ -23,12 +23,13 @@ dependencies:
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 1
|
29
29
|
segments:
|
30
30
|
- 0
|
31
|
-
|
31
|
+
- 5
|
32
|
+
version: "0.5"
|
32
33
|
type: :runtime
|
33
34
|
version_requirements: *id001
|
34
35
|
description:
|
@@ -40,9 +41,9 @@ extensions: []
|
|
40
41
|
extra_rdoc_files: []
|
41
42
|
|
42
43
|
files:
|
43
|
-
- assets/template.d/xmpp-subject.plain.erb
|
44
44
|
- assets/template.d/xmpp-body.plain.erb
|
45
45
|
- lib/wcc-xmpp-notificator.rb
|
46
|
+
- README.md
|
46
47
|
homepage: https://github.com/cmur2/wcc-xmpp-notificator
|
47
48
|
licenses: []
|
48
49
|
|
@@ -1 +0,0 @@
|
|
1
|
-
BLAH [<%= data.tag %>] <%= data.site.uri.host %> changed
|