blather 0.4.4 → 0.4.5
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/README.rdoc +2 -2
- data/examples/echo.rb +1 -1
- data/lib/blather/client/client.rb +1 -2
- data/lib/blather/client/dsl.rb +3 -3
- data/lib/blather/stanza/pubsub.rb +13 -2
- data/spec/blather/client/dsl_spec.rb +1 -1
- data/spec/blather/stanza/pubsub_spec.rb +5 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -41,12 +41,12 @@ This will auto-accept any subscription requests and echo back any chat messages.
|
|
41
41
|
|
42
42
|
# Auto approve subscription requests
|
43
43
|
subscription :request? do |s|
|
44
|
-
|
44
|
+
write_to_stream s.approve!
|
45
45
|
end
|
46
46
|
|
47
47
|
# Echo back what was said
|
48
48
|
message :chat?, :body do |m|
|
49
|
-
|
49
|
+
write_to_stream m.reply
|
50
50
|
end
|
51
51
|
|
52
52
|
== Handlers
|
data/examples/echo.rb
CHANGED
data/lib/blather/client/dsl.rb
CHANGED
@@ -19,7 +19,7 @@ module Blather
|
|
19
19
|
# This works such that it can be chained:
|
20
20
|
# self << stanza1 << stanza2 << "raw data"
|
21
21
|
def <<(stanza)
|
22
|
-
write stanza
|
22
|
+
client.write stanza
|
23
23
|
self
|
24
24
|
end
|
25
25
|
|
@@ -83,7 +83,7 @@ module Blather
|
|
83
83
|
##
|
84
84
|
# Write data to the stream
|
85
85
|
# Anything that resonds to #to_s can be paseed to the stream
|
86
|
-
def
|
86
|
+
def write_to_stream(stanza)
|
87
87
|
client.write stanza
|
88
88
|
end
|
89
89
|
|
@@ -122,7 +122,7 @@ module Blather
|
|
122
122
|
stanza.node = where
|
123
123
|
|
124
124
|
client.register_tmp_handler stanza.id, &callback
|
125
|
-
write stanza
|
125
|
+
client.write stanza
|
126
126
|
end
|
127
127
|
|
128
128
|
##
|
@@ -51,11 +51,22 @@ class Stanza
|
|
51
51
|
attribute_accessor :id
|
52
52
|
|
53
53
|
def payload=(payload = nil)
|
54
|
-
self.content = payload
|
54
|
+
self.entry.content = payload
|
55
55
|
end
|
56
56
|
|
57
57
|
def payload
|
58
|
-
content.empty? ? nil : content
|
58
|
+
self.entry.content.empty? ? nil : content
|
59
|
+
end
|
60
|
+
|
61
|
+
def entry
|
62
|
+
e = find_first('ns:entry', :ns => 'http://www.w3.org/2005/Atom') ||
|
63
|
+
find_first('entry', :ns => 'http://www.w3.org/2005/Atom')
|
64
|
+
|
65
|
+
unless e
|
66
|
+
self << (e = XMPPNode.new('entry', self.document))
|
67
|
+
e.namespace = 'http://www.w3.org/2005/Atom'
|
68
|
+
end
|
69
|
+
e
|
59
70
|
end
|
60
71
|
end
|
61
72
|
|
@@ -59,4 +59,9 @@ describe Blather::Stanza::PubSub::PubSubItem do
|
|
59
59
|
item.payload = nil
|
60
60
|
item.payload.must_be_nil
|
61
61
|
end
|
62
|
+
|
63
|
+
it 'must have an entry child to item' do
|
64
|
+
item = Blather::Stanza::PubSub::Items::PubSubItem.new 'foo', 'payload'
|
65
|
+
item.find_first('ns:entry', :ns => 'http://www.w3.org/2005/Atom').wont_be_nil
|
66
|
+
end
|
62
67
|
end
|
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: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Smick
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|