badcarl-integrity-jabber 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.1.0
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{integrity-jabber}
5
- s.version = "0.0.3"
5
+ s.version = "0.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Carl Porth"]
@@ -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
- super(commit, config)
12
+ def initialize(commit, config)
13
+ config.delete_if { |k,v| v.blank? }
14
14
 
15
- @client = ::Jabber::Client.new(config.delete('jid'))
16
- @password = config.delete('password')
17
- @port = config.delete('port')
18
- @server = config.delete('server')
19
- @to = config.delete('to').split(/\s+/)
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
- @server = nil if @server.blank?
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, full_message)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badcarl-integrity-jabber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Porth