badcarl-integrity-jabber 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/integrity-jabber.gemspec +1 -1
- data/lib/integrity/notifier/config.haml +4 -0
- data/lib/integrity/notifier/jabber.rb +12 -10
- data/test/unit/integrity_jabber_test.rb +8 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/integrity-jabber.gemspec
CHANGED
@@ -19,3 +19,7 @@
|
|
19
19
|
%p.normal
|
20
20
|
%label{ :for => "jabber_notifier_port" } Port
|
21
21
|
%input.text#jabber_notifier_port{ :name => "notifiers[Jabber][port]", :value => config["port"], :type => "text" }
|
22
|
+
|
23
|
+
%p.normal
|
24
|
+
%label{ :for => "jabber_notifier_stanza_limit" } Stanza Limit
|
25
|
+
%input.text#jabber_notifier_stanza_limit{ :name => "notifiers[Jabber][stanza_limit]", :value => config["stanza_limit"], :type => "text" }
|
@@ -9,25 +9,27 @@ module Integrity
|
|
9
9
|
File.read(File.dirname(__FILE__) + "/config.haml")
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(commit, config
|
13
|
-
|
12
|
+
def initialize(commit, config)
|
13
|
+
config.delete_if { |k,v| v.blank? }
|
14
14
|
|
15
|
-
@client
|
16
|
-
@password
|
17
|
-
@
|
18
|
-
@server
|
19
|
-
@
|
15
|
+
@client = ::Jabber::Client.new(config.delete('jid'))
|
16
|
+
@password = config.delete('password')
|
17
|
+
@to = config.delete('to').split(/\s+/)
|
18
|
+
@server = config.delete('server')
|
19
|
+
@port = config.delete('port') || '5222'
|
20
|
+
@stanza_limit = config.delete('stanza_limit') || '65536'
|
20
21
|
|
21
|
-
|
22
|
-
@port = 5222 if @port.blank?
|
22
|
+
super(commit, config)
|
23
23
|
end
|
24
24
|
|
25
25
|
def deliver!
|
26
26
|
@client.connect(@server, @port.to_i)
|
27
27
|
@client.auth(@password)
|
28
28
|
|
29
|
+
body = full_message[0...@stanza_limit.to_i]
|
30
|
+
|
29
31
|
@to.each do |to|
|
30
|
-
message = ::Jabber::Message.new(to,
|
32
|
+
message = ::Jabber::Message.new(to, body)
|
31
33
|
message.type = :chat
|
32
34
|
@client.send(message)
|
33
35
|
end
|
@@ -30,6 +30,7 @@ class IntegrityJabberTest < Test::Unit::TestCase
|
|
30
30
|
assert provides_option?("server", "example.org")
|
31
31
|
assert provides_option?("port", "5222")
|
32
32
|
assert provides_option?("to", "bar@example.org")
|
33
|
+
assert provides_option?("stanza_limit", "65536")
|
33
34
|
end
|
34
35
|
|
35
36
|
def test_configuration_with_server
|
@@ -76,4 +77,11 @@ class IntegrityJabberTest < Test::Unit::TestCase
|
|
76
77
|
Integrity::Notifier::Jabber.new(@commit, @config).deliver!
|
77
78
|
end
|
78
79
|
|
80
|
+
def test_truncates_long_build
|
81
|
+
@commit.build.output = 'x' * 65537
|
82
|
+
@client.expects(:send).with { |message| message.body.length == 65536 }
|
83
|
+
|
84
|
+
Integrity::Notifier::Jabber.new(@commit, @config.merge('stanza_limit' => '65536')).deliver!
|
85
|
+
end
|
86
|
+
|
79
87
|
end
|