blather 1.1.4 → 1.2.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +6 -0
- data/blather.gemspec +1 -2
- data/lib/blather/roster.rb +6 -3
- data/lib/blather/stanza/disco/disco_info.rb +4 -0
- data/lib/blather/stanza/disco/disco_items.rb +2 -0
- data/lib/blather/stanza/iq/roster.rb +7 -0
- data/lib/blather/stanza/presence/status.rb +9 -1
- data/lib/blather/stanza/pubsub.rb +2 -0
- data/lib/blather/version.rb +1 -1
- data/spec/blather/roster_spec.rb +7 -2
- data/spec/blather/stanza/iq/roster_spec.rb +7 -1
- data/spec/blather/stanza/presence/status_spec.rb +14 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26cf5c0a6d1dba72a71b5c0b48696354f78c421b
|
4
|
+
data.tar.gz: f1bd35632f6b5b809dcf6fa062da13f750eae39b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92884baac11b0f449f6b87b2a52f55534bca13f1638783c5c4c2f50c160af35b30712d47a89395455aeb6fbe6585c87ee0b0ad5b81b84782415605f28c80662d
|
7
|
+
data.tar.gz: eeb47327e6496182a286311a0873c1347679fa09f1ed827c5e71b35843aa6c117a299dc64e93fc1bb340b14c3100f64ad3e9a2c871b03752fb7c66c414371ae4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# [develop](https://github.com/adhearsion/blather/compare/master...develop)
|
2
2
|
|
3
|
+
# [v1.2.0](https://github.com/adhearsion/blather/compare/v1.1.4...v1.2.0) - [2016-01-07](https://rubygems.org/gems/blather/versions/1.2.0)
|
4
|
+
* Bugfix: Properly sort resources with the same priority but different status
|
5
|
+
* Bugfix: Lock to Nokogiri <= 1.6.1 because new versions are more broken than old ones
|
6
|
+
* Bugfix: Avoid repeatedly parsing nodes which are already parsed
|
7
|
+
* Feature: Implement Blather::Roster#version, which returns version of last processed roster stanza
|
8
|
+
|
3
9
|
# [v1.1.4](https://github.com/adhearsion/blather/compare/v1.1.4...v1.1.4) - [2015-06-12](https://rubygems.org/gems/blather/versions/1.1.4)
|
4
10
|
* Bugfix: Typo in passing through connection options
|
5
11
|
* Today was a very dark day. I am ashamed of myself.
|
data/blather.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.extra_rdoc_files = %w{LICENSE README.md}
|
36
36
|
|
37
37
|
s.add_dependency "eventmachine", [">= 1.0.0"]
|
38
|
-
s.add_dependency "nokogiri", ["~> 1.5", ">= 1.5.6"]
|
38
|
+
s.add_dependency "nokogiri", ["~> 1.5", ">= 1.5.6", "<= 1.6.1"]
|
39
39
|
s.add_dependency "niceogiri", ["~> 1.0"]
|
40
40
|
s.add_dependency "activesupport", [">= 2.3.11"]
|
41
41
|
s.add_dependency "girl_friday"
|
@@ -46,7 +46,6 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.add_development_dependency "mocha", ["~> 0.9"]
|
47
47
|
s.add_development_dependency "guard-rspec"
|
48
48
|
s.add_development_dependency "yard", ["~> 0.6"]
|
49
|
-
s.add_development_dependency "jruby-openssl", ["~> 0.7"] if jruby?
|
50
49
|
s.add_development_dependency "bluecloth" unless jruby? || rbx?
|
51
50
|
s.add_development_dependency "countdownlatch"
|
52
51
|
s.add_development_dependency 'rb-fsevent', ['~> 0.9']
|
data/lib/blather/roster.rb
CHANGED
@@ -5,24 +5,27 @@ module Blather
|
|
5
5
|
class Roster
|
6
6
|
include Enumerable
|
7
7
|
|
8
|
+
attr_reader :version
|
9
|
+
|
8
10
|
# Create a new roster
|
9
11
|
#
|
10
12
|
# @param [Blather::Stream] stream the stream the roster should use to
|
11
13
|
# update roster entries
|
12
|
-
# @param [Blather::Stanza::Roster] stanza a roster stanza used to preload
|
14
|
+
# @param [Blather::Stanza::Iq::Roster] stanza a roster stanza used to preload
|
13
15
|
# the roster
|
14
16
|
# @return [Blather::Roster]
|
15
17
|
def initialize(stream, stanza = nil)
|
16
18
|
@stream = stream
|
17
19
|
@items = {}
|
18
|
-
stanza
|
20
|
+
process(stanza) if stanza
|
19
21
|
end
|
20
22
|
|
21
23
|
# Process any incoming stanzas and either adds or removes the
|
22
24
|
# corresponding RosterItem
|
23
25
|
#
|
24
|
-
# @param [Blather::Stanza::Roster] stanza a roster stanza
|
26
|
+
# @param [Blather::Stanza::Iq::Roster] stanza a roster stanza
|
25
27
|
def process(stanza)
|
28
|
+
@version = stanza.version
|
26
29
|
stanza.items.each do |i|
|
27
30
|
case i.subscription
|
28
31
|
when :remove then @items.delete(key(i.jid))
|
@@ -84,6 +84,8 @@ class Stanza
|
|
84
84
|
# @param [String, nil] type the type of the Identity
|
85
85
|
# @param [String, nil] category the category of the Identity
|
86
86
|
def self.new(name, type = nil, category = nil, xml_lang = nil)
|
87
|
+
return name if name.class == self
|
88
|
+
|
87
89
|
new_node = super :identity
|
88
90
|
|
89
91
|
case name
|
@@ -170,6 +172,8 @@ class Stanza
|
|
170
172
|
# @param [String] var a the Feautre's var
|
171
173
|
# @return [DiscoInfo::Feature]
|
172
174
|
def self.new(var)
|
175
|
+
return var if var.class == self
|
176
|
+
|
173
177
|
new_node = super :feature
|
174
178
|
case var
|
175
179
|
when Nokogiri::XML::Node
|
@@ -76,9 +76,13 @@ class Presence
|
|
76
76
|
# @handler :status
|
77
77
|
class Status < Presence
|
78
78
|
# @private
|
79
|
+
# The spec requires only the following 4 states
|
79
80
|
VALID_STATES = [:away, :chat, :dnd, :xa].freeze
|
80
81
|
VALID_TYPES = [:unavailable].freeze
|
81
82
|
|
83
|
+
# ...but this is the sorted list of possible states
|
84
|
+
POSSIBLE_STATES = [:unavailable, :dnd, :xa, :away, :available, :chat].freeze
|
85
|
+
|
82
86
|
include Comparable
|
83
87
|
|
84
88
|
register :status, :status
|
@@ -200,7 +204,11 @@ class Presence
|
|
200
204
|
end
|
201
205
|
|
202
206
|
if (self.type.nil? && o.type.nil?) || (!self.type.nil? && !o.type.nil?)
|
203
|
-
self.priority
|
207
|
+
if self.priority == o.priority
|
208
|
+
POSSIBLE_STATES.index(self.state) <=> POSSIBLE_STATES.index(o.state)
|
209
|
+
else
|
210
|
+
self.priority <=> o.priority
|
211
|
+
end
|
204
212
|
elsif self.type.nil? && !o.type.nil?
|
205
213
|
1
|
206
214
|
elsif !self.type.nil? && o.type.nil?
|
@@ -72,6 +72,8 @@ class Stanza
|
|
72
72
|
# @param [XML::Document, nil] document the document the node should be
|
73
73
|
# attached to. This should be the document of the parent PubSub node.
|
74
74
|
def self.new(id = nil, payload = nil, document = nil)
|
75
|
+
return id if id.class == self
|
76
|
+
|
75
77
|
new_node = super 'item', document
|
76
78
|
new_node.id = id
|
77
79
|
new_node.payload = payload if payload
|
data/lib/blather/version.rb
CHANGED
data/spec/blather/roster_spec.rb
CHANGED
@@ -6,14 +6,15 @@ describe Blather::Roster do
|
|
6
6
|
@stream.stubs(:write)
|
7
7
|
|
8
8
|
@stanza = mock()
|
9
|
-
items =
|
9
|
+
items = 4.times.map { |n| Blather::Stanza::Iq::Roster::RosterItem.new(jid: "n@d/#{n}r") }
|
10
10
|
@stanza.stubs(:items).returns(items)
|
11
|
+
@stanza.stubs(:version).returns('24d091d0dcfab1b3')
|
11
12
|
|
12
13
|
@roster = Blather::Roster.new(@stream, @stanza)
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'initializes with items' do
|
16
|
-
@roster.items.map { |_,i| i.jid.to_s }.should == (@stanza.items.map { |i| i.stripped.to_s }.uniq)
|
17
|
+
@roster.items.map { |_,i| i.jid.to_s }.should == (@stanza.items.map { |i| i.jid.stripped.to_s }.uniq)
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'processes @stanzas with remove requests' do
|
@@ -104,4 +105,8 @@ describe Blather::Roster do
|
|
104
105
|
'group3' => [item2]
|
105
106
|
})
|
106
107
|
end
|
108
|
+
|
109
|
+
it 'has a version' do
|
110
|
+
expect(@roster.version).to eq @stanza.version
|
111
|
+
end
|
107
112
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
def roster_xml
|
4
4
|
<<-XML
|
5
5
|
<iq to='juliet@example.com/balcony' type='result' id='roster_1'>
|
6
|
-
<query xmlns='jabber:iq:roster'>
|
6
|
+
<query xmlns='jabber:iq:roster' ver='3bb607aa4fa0bc9e'>
|
7
7
|
<item jid='romeo@example.net'
|
8
8
|
name='Romeo'
|
9
9
|
subscription='both'>
|
@@ -38,6 +38,12 @@ describe Blather::Stanza::Iq::Roster do
|
|
38
38
|
it 'can be created with #import' do
|
39
39
|
Blather::XMPPNode.parse(roster_xml).should be_instance_of Blather::Stanza::Iq::Roster
|
40
40
|
end
|
41
|
+
|
42
|
+
it 'retrieves version' do
|
43
|
+
n = parse_stanza roster_xml
|
44
|
+
r = Blather::Stanza::Iq::Roster.new.inherit n.root
|
45
|
+
expect(r.version).to eq '3bb607aa4fa0bc9e'
|
46
|
+
end
|
41
47
|
end
|
42
48
|
|
43
49
|
describe Blather::Stanza::Iq::Roster::RosterItem do
|
@@ -118,6 +118,20 @@ describe Blather::Stanza::Presence::Status do
|
|
118
118
|
(status1 <=> status2).should == 0
|
119
119
|
end
|
120
120
|
|
121
|
+
it 'must should sort by status if priorities are equal' do
|
122
|
+
jid = Blather::JID.new 'a@b/c'
|
123
|
+
|
124
|
+
status1 = Blather::Stanza::Presence::Status.new :away
|
125
|
+
status1.from = jid
|
126
|
+
|
127
|
+
status2 = Blather::Stanza::Presence::Status.new :available
|
128
|
+
status2.from = jid
|
129
|
+
|
130
|
+
status1.priority = status2.priority = 1
|
131
|
+
(status1 <=> status2).should == -1
|
132
|
+
(status2 <=> status1).should == 1
|
133
|
+
end
|
134
|
+
|
121
135
|
it 'raises an argument error if compared to a status with a different Blather::JID' do
|
122
136
|
status1 = Blather::Stanza::Presence::Status.new
|
123
137
|
status1.from = 'a@b/c'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Smick
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -35,6 +35,9 @@ dependencies:
|
|
35
35
|
- - ">="
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: 1.5.6
|
38
|
+
- - "<="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.6.1
|
38
41
|
type: :runtime
|
39
42
|
prerelease: false
|
40
43
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -45,6 +48,9 @@ dependencies:
|
|
45
48
|
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
50
|
version: 1.5.6
|
51
|
+
- - "<="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.6.1
|
48
54
|
- !ruby/object:Gem::Dependency
|
49
55
|
name: niceogiri
|
50
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -392,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
392
398
|
version: '0'
|
393
399
|
requirements: []
|
394
400
|
rubyforge_project:
|
395
|
-
rubygems_version: 2.
|
401
|
+
rubygems_version: 2.5.1
|
396
402
|
signing_key:
|
397
403
|
specification_version: 4
|
398
404
|
summary: Simpler XMPP built for speed
|