blather 0.2.2 → 0.2.3

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.
Files changed (46) hide show
  1. data/README.rdoc +2 -2
  2. data/Rakefile +30 -18
  3. data/ext/Makefile +149 -0
  4. data/ext/mkmf.log +30 -0
  5. data/ext/push_parser.bundle +0 -0
  6. data/ext/push_parser.c +231 -0
  7. data/ext/push_parser.o +0 -0
  8. data/lib/blather.rb +3 -7
  9. data/lib/blather/client.rb +247 -4
  10. data/lib/blather/roster.rb +0 -9
  11. data/lib/blather/stanza/{disco.rb → iq/disco.rb} +3 -1
  12. data/lib/blather/stanza/{disco → iq/discos}/disco_info.rb +5 -3
  13. data/lib/blather/stanza/{disco → iq/discos}/disco_items.rb +2 -0
  14. data/lib/blather/stanza/iq/query.rb +1 -1
  15. data/lib/blather/stanza/iq/roster.rb +2 -2
  16. data/lib/blather/xmpp_node.rb +1 -1
  17. data/spec/blather/stanza/{discos → iq/discos}/disco_info_spec.rb +12 -12
  18. data/spec/blather/stanza/{discos → iq/discos}/disco_items_spec.rb +1 -1
  19. data/spec/blather/stanza/iq/query_spec.rb +0 -7
  20. data/spec/blather/stanza/iq/roster_spec.rb +21 -21
  21. data/spec/blather/stanza/pubsub/event_spec.rb +13 -0
  22. data/spec/build_safe.rb +20 -0
  23. metadata +19 -68
  24. data/VERSION.yml +0 -4
  25. data/examples/pubsub/cli.rb +0 -64
  26. data/examples/pubsub/ping_pong.rb +0 -18
  27. data/examples/pubsub/pubsub_dsl.rb +0 -52
  28. data/examples/pubsub_client.rb +0 -39
  29. data/examples/rosterprint.rb +0 -14
  30. data/examples/xmpp4r/echo.rb +0 -35
  31. data/lib/blather/client/client.rb +0 -165
  32. data/lib/blather/client/dsl.rb +0 -99
  33. data/lib/blather/client/pubsub.rb +0 -53
  34. data/lib/blather/client/pubsub/node.rb +0 -27
  35. data/lib/blather/stanza/pubsub.rb +0 -33
  36. data/lib/blather/stanza/pubsub/affiliations.rb +0 -52
  37. data/lib/blather/stanza/pubsub/errors.rb +0 -9
  38. data/lib/blather/stanza/pubsub/event.rb +0 -21
  39. data/lib/blather/stanza/pubsub/items.rb +0 -59
  40. data/lib/blather/stanza/pubsub/owner.rb +0 -9
  41. data/lib/blather/stanza/pubsub/subscriptions.rb +0 -57
  42. data/spec/blather/stanza/pubsub/affiliations_spec.rb +0 -46
  43. data/spec/blather/stanza/pubsub/items_spec.rb +0 -59
  44. data/spec/blather/stanza/pubsub/subscriptions_spec.rb +0 -63
  45. data/spec/blather/stanza/pubsub_spec.rb +0 -26
  46. data/spec/fixtures/pubsub.rb +0 -157
@@ -1,9 +0,0 @@
1
- module Blather
2
- class Stanza
3
-
4
- class PubSubErrors < PubSub
5
- attribute_accessor :node, :to_sym => false
6
- end
7
-
8
- end #Stanza
9
- end #Blather
@@ -1,21 +0,0 @@
1
- module Blather
2
- class Stanza
3
- class PubSub
4
-
5
- class Event < Message
6
- register :pubsub_event, nil, 'http://jabber.org/protocol/pubsub#event'
7
-
8
- def items
9
- end
10
-
11
- class Item
12
- attribute_accessor :id, :node, :to_sym => false
13
-
14
- alias_method :payload, :content
15
- alias_method :payload=, :content=
16
- end
17
- end
18
-
19
- end #PubSub
20
- end #Stanza
21
- end #Blather
@@ -1,59 +0,0 @@
1
- module Blather
2
- class Stanza
3
- class PubSub
4
-
5
- class Items < PubSub
6
- register :pubsub_items, :pubsub_items, self.ns
7
-
8
- include Enumerable
9
-
10
- def self.request(host, path, list = [], max = nil)
11
- node = self.new :get, host
12
-
13
- node.items.attributes[:node] = path
14
- node.items.attributes[:max_items] = max
15
-
16
- (list || []).each do |id|
17
- item = XMPPNode.new 'item'
18
- item.attributes[:id] = id
19
- node.items << item
20
- end
21
-
22
- node
23
- end
24
-
25
- def initialize(type = nil, host = nil)
26
- super
27
- items
28
- end
29
-
30
- ##
31
- # Kill the items node before running inherit
32
- def inherit(node)
33
- items.remove!
34
- super
35
- end
36
-
37
- def [](id)
38
- items[id]
39
- end
40
-
41
- def each(&block)
42
- items.each &block
43
- end
44
-
45
- def size
46
- items.size
47
- end
48
-
49
- def items
50
- items = pubsub.find_first('//items', self.class.ns)
51
- items = pubsub.find_first('//pubsub_ns:items', :pubsub_ns => self.class.ns) unless items
52
- (self.pubsub << (items = XMPPNode.new('items'))) unless items
53
- items
54
- end
55
- end
56
-
57
- end #PubSub
58
- end #Stanza
59
- end #Blather
@@ -1,9 +0,0 @@
1
- module Blather
2
- class Stanza
3
-
4
- class PubSubOwner < PubSub
5
- attribute_accessor :node, :to_sym => false
6
- end
7
-
8
- end #Stanza
9
- end #Blather
@@ -1,57 +0,0 @@
1
- module Blather
2
- class Stanza
3
- class PubSub
4
-
5
- class Subscriptions < PubSub
6
- register :pubsub_subscriptions, :pubsub_subscriptions, self.ns
7
-
8
- include Enumerable
9
-
10
- ##
11
- # Ensure the namespace is set to the query node
12
- def initialize(type = nil, host = nil)
13
- super type
14
- self.to = host
15
- subscriptions
16
- end
17
-
18
- ##
19
- # Kill the pubsub node before running inherit
20
- def inherit(node)
21
- subscriptions.remove!
22
- super
23
- end
24
-
25
- def subscriptions
26
- aff = pubsub.find_first('//pubsub_ns:subscriptions', :pubsub_ns => self.class.ns)
27
- (self.pubsub << (aff = XMPPNode.new('subscriptions'))) unless aff
28
- aff
29
- end
30
-
31
- def [](subscription)
32
- list[subscription]
33
- end
34
-
35
- def each(&block)
36
- list.each &block
37
- end
38
-
39
- def size
40
- list.size
41
- end
42
-
43
- def list
44
- @subscription_list ||= begin
45
- items = subscriptions.find('//pubsub_ns:subscription', :pubsub_ns => self.class.ns)
46
- items.inject({}) do |hash, item|
47
- hash[item.attributes[:subscription].to_sym] ||= []
48
- hash[item.attributes[:subscription].to_sym] << item.attributes[:node]
49
- hash
50
- end
51
- end
52
- end
53
- end #Subscriptions
54
-
55
- end #PubSub
56
- end #Stanza
57
- end #Blather
@@ -1,46 +0,0 @@
1
- require File.join(File.dirname(__FILE__), *%w[.. .. .. spec_helper])
2
- require File.join(File.dirname(__FILE__), *%w[.. .. .. fixtures pubsub])
3
-
4
- describe 'Blather::Stanza::PubSub::Affiliations' do
5
- it 'registers itself' do
6
- XMPPNode.class_from_registration(:pubsub_affiliations, 'http://jabber.org/protocol/pubsub').must_equal Stanza::PubSub::Affiliations
7
- end
8
-
9
- it 'ensures an affiliations node is present on create' do
10
- affiliations = Stanza::PubSub::Affiliations.new
11
- affiliations.pubsub.children.detect { |n| n.element_name == 'affiliations' }.wont_be_nil
12
- end
13
-
14
- it 'ensures an affiliations node exists when calling #affiliations' do
15
- affiliations = Stanza::PubSub::Affiliations.new
16
- affiliations.pubsub.remove_child :affiliations
17
- affiliations.pubsub.children.detect { |n| n.element_name == 'affiliations' }.must_be_nil
18
-
19
- affiliations.affiliations.wont_be_nil
20
- affiliations.pubsub.children.detect { |n| n.element_name == 'affiliations' }.wont_be_nil
21
- end
22
-
23
- it 'defaults to a get node' do
24
- aff = Stanza::PubSub::Affiliations.new
25
- aff.type.must_equal :get
26
- end
27
-
28
- it 'sets the host if requested' do
29
- aff = Stanza::PubSub::Affiliations.new :get, 'pubsub.jabber.local'
30
- aff.to.must_equal JID.new('pubsub.jabber.local')
31
- end
32
-
33
- it 'can import an affiliates result node' do
34
- node = XML::Document.string(affiliations_xml).root
35
-
36
- affiliations = Stanza::PubSub::Affiliations.new.inherit node
37
- affiliations.size.must_equal 5
38
- affiliations.list.must_equal({
39
- :owner => ['node1', 'node2'],
40
- :publisher => ['node3'],
41
- :outcast => ['node4'],
42
- :member => ['node5'],
43
- :none => ['node6']
44
- })
45
- end
46
- end
@@ -1,59 +0,0 @@
1
- require File.join(File.dirname(__FILE__), *%w[.. .. .. spec_helper])
2
- require File.join(File.dirname(__FILE__), *%w[.. .. .. fixtures pubsub])
3
-
4
- describe 'Blather::Stanza::PubSub::Items' do
5
- it 'registers itself' do
6
- XMPPNode.class_from_registration(:pubsub_items, 'http://jabber.org/protocol/pubsub').must_equal Stanza::PubSub::Items
7
- end
8
-
9
- it 'ensures an items node is present on create' do
10
- items = Stanza::PubSub::Items.new
11
- items.pubsub.children.detect { |n| n.element_name == 'items' }.wont_be_nil
12
- end
13
-
14
- it 'ensures an items node exists when calling #items' do
15
- items = Stanza::PubSub::Items.new
16
- items.pubsub.remove_child :items
17
- items.pubsub.children.detect { |n| n.element_name == 'items' }.must_be_nil
18
-
19
- items.items.wont_be_nil
20
- items.pubsub.children.detect { |n| n.element_name == 'items' }.wont_be_nil
21
- end
22
-
23
- it 'defaults to a get node' do
24
- aff = Stanza::PubSub::Items.new
25
- aff.type.must_equal :get
26
- end
27
-
28
- it 'can create an items request node to request all items' do
29
- host = 'pubsub.jabber.local'
30
- node = 'princely_musings'
31
-
32
- items = Stanza::PubSub::Items.request host, node
33
- items.find("//pubsub/items[@node=\"#{node}\"]").size.must_equal 1
34
- items.to.must_equal JID.new(host)
35
- end
36
-
37
- it 'can create an items request node to request some items' do
38
- host = 'pubsub.jabber.local'
39
- node = 'princely_musings'
40
- items = %w[item1 item2]
41
-
42
- items_xpath = items.map { |i| "@id=\"#{i}\"" } * ' or '
43
-
44
- items = Stanza::PubSub::Items.request host, node, items
45
- items.find("//pubsub/items[@node=\"#{node}\"]/item[#{items_xpath}]").size.must_equal 2
46
- items.to.must_equal JID.new(host)
47
- end
48
-
49
- it 'can create an items request node to request "max_number" of items' do
50
- host = 'pubsub.jabber.local'
51
- node = 'princely_musings'
52
- max = 3
53
-
54
- items = Stanza::PubSub::Items.request host, node, nil, max
55
- items.find("//pubsub/items[@node=\"#{node}\" and @max_items=\"#{max}\"]").size.must_equal 1
56
- items.to.must_equal JID.new(host)
57
- end
58
-
59
- end
@@ -1,63 +0,0 @@
1
- require File.join(File.dirname(__FILE__), *%w[.. .. .. spec_helper])
2
-
3
- def subscriptions_xml
4
- <<-NODE
5
- <iq type='result'
6
- from='pubsub.shakespeare.lit'
7
- to='francisco@denmark.lit'
8
- id='affil1'>
9
- <pubsub xmlns='http://jabber.org/protocol/pubsub'>
10
- <subscriptions>
11
- <subscription node='node1' subscription='subscribed'/>
12
- <subscription node='node2' subscription='subscribed'/>
13
- <subscription node='node3' subscription='unconfigured'/>
14
- <subscription node='node4' subscription='pending'/>
15
- <subscription node='node5' subscription='none'/>
16
- </subscriptions>
17
- </pubsub>
18
- </iq>
19
- NODE
20
- end
21
-
22
- describe 'Blather::Stanza::PubSub::Subscriptions' do
23
- it 'registers itself' do
24
- XMPPNode.class_from_registration(:pubsub_subscriptions, 'http://jabber.org/protocol/pubsub').must_equal Stanza::PubSub::Subscriptions
25
- end
26
-
27
- it 'ensures an subscriptions node is present on create' do
28
- subscriptions = Stanza::PubSub::Subscriptions.new
29
- subscriptions.pubsub.children.detect { |n| n.element_name == 'subscriptions' }.wont_be_nil
30
- end
31
-
32
- it 'ensures an subscriptions node exists when calling #subscriptions' do
33
- subscriptions = Stanza::PubSub::Subscriptions.new
34
- subscriptions.pubsub.remove_child :subscriptions
35
- subscriptions.pubsub.children.detect { |n| n.element_name == 'subscriptions' }.must_be_nil
36
-
37
- subscriptions.list.wont_be_nil
38
- subscriptions.pubsub.children.detect { |n| n.element_name == 'subscriptions' }.wont_be_nil
39
- end
40
-
41
- it 'defaults to a get node' do
42
- aff = Stanza::PubSub::Subscriptions.new
43
- aff.type.must_equal :get
44
- end
45
-
46
- it 'sets the host if requested' do
47
- aff = Stanza::PubSub::Subscriptions.new :get, 'pubsub.jabber.local'
48
- aff.to.must_equal JID.new('pubsub.jabber.local')
49
- end
50
-
51
- it 'can import a subscriptions result node' do
52
- node = XML::Document.string(subscriptions_xml).root
53
-
54
- subscriptions = Stanza::PubSub::Subscriptions.new.inherit node
55
- subscriptions.size.must_equal 4
56
- subscriptions.list.must_equal({
57
- :subscribed => ['node1', 'node2'],
58
- :unconfigured => ['node3'],
59
- :pending => ['node4'],
60
- :none => ['node5']
61
- })
62
- end
63
- end
@@ -1,26 +0,0 @@
1
- require File.join(File.dirname(__FILE__), *%w[.. .. spec_helper])
2
-
3
- describe 'Blather::Stanza::PubSub' do
4
- it 'registers itself' do
5
- XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub').must_equal Stanza::PubSub
6
- end
7
-
8
- it 'ensures a pubusb node is present on create' do
9
- pubsub = Stanza::PubSub.new
10
- pubsub.children.detect { |n| n.element_name == 'pubsub' }.wont_be_nil
11
- end
12
-
13
- it 'ensures a pubsub node exists when calling #pubsub' do
14
- pubsub = Stanza::PubSub.new
15
- pubsub.remove_child :pubsub
16
- pubsub.children.detect { |n| n.element_name == 'pubsub' }.must_be_nil
17
-
18
- pubsub.pubsub.wont_be_nil
19
- pubsub.children.detect { |n| n.element_name == 'pubsub' }.wont_be_nil
20
- end
21
-
22
- it 'sets the host if requested' do
23
- aff = Stanza::PubSub.new :get, 'pubsub.jabber.local'
24
- aff.to.must_equal JID.new('pubsub.jabber.local')
25
- end
26
- end
@@ -1,157 +0,0 @@
1
- def items_all_nodes_xml
2
- <<-ITEMS
3
- <iq type='result'
4
- from='pubsub.shakespeare.lit'
5
- to='francisco@denmark.lit/barracks'
6
- id='items1'>
7
- <pubsub xmlns='http://jabber.org/protocol/pubsub'>
8
- <items node='princely_musings'>
9
- <item id='368866411b877c30064a5f62b917cffe'>
10
- <entry xmlns='http://www.w3.org/2005/Atom'>
11
- <title>The Uses of This World</title>
12
- <summary>
13
- O, that this too too solid flesh would melt
14
- Thaw and resolve itself into a dew!
15
- </summary>
16
- <link rel='alternate' type='text/html'
17
- href='http://denmark.lit/2003/12/13/atom03'/>
18
- <id>tag:denmark.lit,2003:entry-32396</id>
19
- <published>2003-12-12T17:47:23Z</published>
20
- <updated>2003-12-12T17:47:23Z</updated>
21
- </entry>
22
- </item>
23
- <item id='3300659945416e274474e469a1f0154c'>
24
- <entry xmlns='http://www.w3.org/2005/Atom'>
25
- <title>Ghostly Encounters</title>
26
- <summary>
27
- O all you host of heaven! O earth! what else?
28
- And shall I couple hell? O, fie! Hold, hold, my heart;
29
- And you, my sinews, grow not instant old,
30
- But bear me stiffly up. Remember thee!
31
- </summary>
32
- <link rel='alternate' type='text/html'
33
- href='http://denmark.lit/2003/12/13/atom03'/>
34
- <id>tag:denmark.lit,2003:entry-32396</id>
35
- <published>2003-12-12T23:21:34Z</published>
36
- <updated>2003-12-12T23:21:34Z</updated>
37
- </entry>
38
- </item>
39
- <item id='4e30f35051b7b8b42abe083742187228'>
40
- <entry xmlns='http://www.w3.org/2005/Atom'>
41
- <title>Alone</title>
42
- <summary>
43
- Now I am alone.
44
- O, what a rogue and peasant slave am I!
45
- </summary>
46
- <link rel='alternate' type='text/html'
47
- href='http://denmark.lit/2003/12/13/atom03'/>
48
- <id>tag:denmark.lit,2003:entry-32396</id>
49
- <published>2003-12-13T11:09:53Z</published>
50
- <updated>2003-12-13T11:09:53Z</updated>
51
- </entry>
52
- </item>
53
- <item id='ae890ac52d0df67ed7cfdf51b644e901'>
54
- <entry xmlns='http://www.w3.org/2005/Atom'>
55
- <title>Soliloquy</title>
56
- <summary>
57
- To be, or not to be: that is the question:
58
- Whether 'tis nobler in the mind to suffer
59
- The slings and arrows of outrageous fortune,
60
- Or to take arms against a sea of troubles,
61
- And by opposing end them?
62
- </summary>
63
- <link rel='alternate' type='text/html'
64
- href='http://denmark.lit/2003/12/13/atom03'/>
65
- <id>tag:denmark.lit,2003:entry-32397</id>
66
- <published>2003-12-13T18:30:02Z</published>
67
- <updated>2003-12-13T18:30:02Z</updated>
68
- </entry>
69
- </item>
70
- </items>
71
- </pubsub>
72
- </iq>
73
- ITEMS
74
- end
75
-
76
- def pubsub_items_some_xml
77
- <<-ITEMS
78
- <iq type='result'
79
- from='pubsub.shakespeare.lit'
80
- to='francisco@denmark.lit/barracks'
81
- id='items1'>
82
- <pubsub xmlns='http://jabber.org/protocol/pubsub'>
83
- <items node='princely_musings'>
84
- <item id='368866411b877c30064a5f62b917cffe'>
85
- <entry xmlns='http://www.w3.org/2005/Atom'>
86
- <title>The Uses of This World</title>
87
- <summary>
88
- O, that this too too solid flesh would melt
89
- Thaw and resolve itself into a dew!
90
- </summary>
91
- <link rel='alternate' type='text/html'
92
- href='http://denmark.lit/2003/12/13/atom03'/>
93
- <id>tag:denmark.lit,2003:entry-32396</id>
94
- <published>2003-12-12T17:47:23Z</published>
95
- <updated>2003-12-12T17:47:23Z</updated>
96
- </entry>
97
- </item>
98
- <item id='3300659945416e274474e469a1f0154c'>
99
- <entry xmlns='http://www.w3.org/2005/Atom'>
100
- <title>Ghostly Encounters</title>
101
- <summary>
102
- O all you host of heaven! O earth! what else?
103
- And shall I couple hell? O, fie! Hold, hold, my heart;
104
- And you, my sinews, grow not instant old,
105
- But bear me stiffly up. Remember thee!
106
- </summary>
107
- <link rel='alternate' type='text/html'
108
- href='http://denmark.lit/2003/12/13/atom03'/>
109
- <id>tag:denmark.lit,2003:entry-32396</id>
110
- <published>2003-12-12T23:21:34Z</published>
111
- <updated>2003-12-12T23:21:34Z</updated>
112
- </entry>
113
- </item>
114
- <item id='4e30f35051b7b8b42abe083742187228'>
115
- <entry xmlns='http://www.w3.org/2005/Atom'>
116
- <title>Alone</title>
117
- <summary>
118
- Now I am alone.
119
- O, what a rogue and peasant slave am I!
120
- </summary>
121
- <link rel='alternate' type='text/html'
122
- href='http://denmark.lit/2003/12/13/atom03'/>
123
- <id>tag:denmark.lit,2003:entry-32396</id>
124
- <published>2003-12-13T11:09:53Z</published>
125
- <updated>2003-12-13T11:09:53Z</updated>
126
- </entry>
127
- </item>
128
- </items>
129
- <set xmlns='http://jabber.org/protocol/rsm'>
130
- <first index='0'>368866411b877c30064a5f62b917cffe</first>
131
- <last>4e30f35051b7b8b42abe083742187228</last>
132
- <count>19</count>
133
- </set>
134
- </pubsub>
135
- </iq>
136
- ITEMS
137
- end
138
-
139
- def affiliations_xml
140
- <<-NODE
141
- <iq type='result'
142
- from='pubsub.shakespeare.lit'
143
- to='francisco@denmark.lit'
144
- id='affil1'>
145
- <pubsub xmlns='http://jabber.org/protocol/pubsub'>
146
- <affiliations>
147
- <affiliation node='node1' affiliation='owner'/>
148
- <affiliation node='node2' affiliation='owner'/>
149
- <affiliation node='node3' affiliation='publisher'/>
150
- <affiliation node='node4' affiliation='outcast'/>
151
- <affiliation node='node5' affiliation='member'/>
152
- <affiliation node='node6' affiliation='none'/>
153
- </affiliations>
154
- </pubsub>
155
- </iq>
156
- NODE
157
- end