blather 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
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
- write s.approve!
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
- write m.reply
49
+ write_to_stream m.reply
50
50
  end
51
51
 
52
52
  == Handlers
data/examples/echo.rb CHANGED
@@ -5,7 +5,7 @@ require 'blather/client'
5
5
  when_ready { puts "Connected ! send messages to #{jid.stripped}." }
6
6
 
7
7
  subscription :request? do |s|
8
- write s.approve!
8
+ write_to_stream s.approve!
9
9
  end
10
10
 
11
11
  message :chat?, :body => 'exit' do |m|
@@ -167,8 +167,7 @@ module Blather #:nodoc:
167
167
 
168
168
  protected
169
169
  def stream
170
- raise 'Stream not ready!' unless @stream
171
- @stream
170
+ @stream || raise('Stream not ready!')
172
171
  end
173
172
 
174
173
  def check_handler(type, guards)
@@ -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 write(stanza)
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
 
@@ -89,7 +89,7 @@ describe Blather::DSL do
89
89
  it 'provides a writer' do
90
90
  stanza = Blather::Stanza::Iq.new
91
91
  @client.expects(:write).with stanza
92
- @dsl.write stanza
92
+ @dsl.write_to_stream stanza
93
93
  end
94
94
 
95
95
  it 'provides a "say" helper' do
@@ -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
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-08-12 00:00:00 -07:00
12
+ date: 2009-10-28 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency