blather 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/README.md +162 -0
  2. data/examples/{print_heirarchy.rb → print_hierarchy.rb} +5 -5
  3. data/examples/stream_only.rb +27 -0
  4. data/lib/blather.rb +4 -0
  5. data/lib/blather/client/client.rb +91 -73
  6. data/lib/blather/client/dsl.rb +156 -32
  7. data/lib/blather/client/dsl/pubsub.rb +86 -54
  8. data/lib/blather/core_ext/active_support.rb +9 -9
  9. data/lib/blather/core_ext/active_support/inheritable_attributes.rb +2 -2
  10. data/lib/blather/core_ext/nokogiri.rb +12 -7
  11. data/lib/blather/errors.rb +25 -14
  12. data/lib/blather/errors/sasl_error.rb +21 -3
  13. data/lib/blather/errors/stanza_error.rb +37 -21
  14. data/lib/blather/errors/stream_error.rb +27 -17
  15. data/lib/blather/jid.rb +79 -24
  16. data/lib/blather/roster.rb +39 -21
  17. data/lib/blather/roster_item.rb +43 -21
  18. data/lib/blather/stanza.rb +88 -40
  19. data/lib/blather/stanza/disco.rb +12 -2
  20. data/lib/blather/stanza/disco/disco_info.rb +112 -20
  21. data/lib/blather/stanza/disco/disco_items.rb +81 -12
  22. data/lib/blather/stanza/iq.rb +94 -38
  23. data/lib/blather/stanza/iq/query.rb +16 -22
  24. data/lib/blather/stanza/iq/roster.rb +98 -20
  25. data/lib/blather/stanza/message.rb +266 -111
  26. data/lib/blather/stanza/presence.rb +118 -42
  27. data/lib/blather/stanza/presence/status.rb +140 -60
  28. data/lib/blather/stanza/presence/subscription.rb +44 -10
  29. data/lib/blather/stanza/pubsub.rb +70 -15
  30. data/lib/blather/stanza/pubsub/affiliations.rb +36 -7
  31. data/lib/blather/stanza/pubsub/create.rb +26 -4
  32. data/lib/blather/stanza/pubsub/errors.rb +13 -4
  33. data/lib/blather/stanza/pubsub/event.rb +56 -10
  34. data/lib/blather/stanza/pubsub/items.rb +46 -6
  35. data/lib/blather/stanza/pubsub/publish.rb +52 -7
  36. data/lib/blather/stanza/pubsub/retract.rb +45 -6
  37. data/lib/blather/stanza/pubsub/subscribe.rb +30 -4
  38. data/lib/blather/stanza/pubsub/subscription.rb +74 -6
  39. data/lib/blather/stanza/pubsub/subscriptions.rb +35 -9
  40. data/lib/blather/stanza/pubsub/unsubscribe.rb +30 -4
  41. data/lib/blather/stanza/pubsub_owner.rb +17 -7
  42. data/lib/blather/stanza/pubsub_owner/delete.rb +23 -5
  43. data/lib/blather/stanza/pubsub_owner/purge.rb +23 -5
  44. data/lib/blather/stream.rb +96 -29
  45. data/lib/blather/stream/parser.rb +6 -9
  46. data/lib/blather/xmpp_node.rb +101 -153
  47. data/spec/blather/client/client_spec.rb +1 -1
  48. data/spec/blather/errors_spec.rb +5 -5
  49. data/spec/blather/stanza/message_spec.rb +56 -0
  50. data/spec/blather/stanza/presence/status_spec.rb +1 -1
  51. data/spec/blather/stanza_spec.rb +3 -3
  52. data/spec/blather/xmpp_node_spec.rb +19 -74
  53. metadata +6 -10
  54. data/README.rdoc +0 -185
  55. data/examples/drb_client.rb +0 -5
  56. data/examples/ping.rb +0 -11
  57. data/examples/pong.rb +0 -6
  58. data/examples/pubsub/cli.rb +0 -64
  59. data/examples/pubsub/ping_pong.rb +0 -18
data/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # Blather
2
+
3
+ XMPP DSL (and more) for Ruby written on EventMachine and Nokogiri.
4
+
5
+ ## Features
6
+
7
+ * evented architecture
8
+ * uses Nokogiri
9
+ * simplified starting point
10
+
11
+ ## Project Pages
12
+
13
+ * [Docs](http://blather.squishtech.com)
14
+ * [GitHub](https://github.com/sprsquish/blather)
15
+ * [Gemcutter](http://gemcutter.org/gems/blather)
16
+ * [Google Group](http://groups.google.com/group/xmpp-blather)
17
+
18
+ # Usage
19
+
20
+ ## Installation
21
+
22
+ sudo gem install blather
23
+
24
+ ## Example
25
+
26
+ See the examples directory for more advanced examples.
27
+
28
+ This will auto-accept any subscription requests and echo back any chat messages.
29
+
30
+ require 'rubygems'
31
+ require 'blather/client'
32
+
33
+ setup 'echo@jabber.local', 'echo'
34
+
35
+ # Auto approve subscription requests
36
+ subscription :request? do |s|
37
+ write_to_stream s.approve!
38
+ end
39
+
40
+ # Echo back what was said
41
+ message :chat?, :body do |m|
42
+ write_to_stream m.reply
43
+ end
44
+
45
+ ## Handlers
46
+
47
+ Setup handlers by calling their names as methods.
48
+
49
+ # Will only be called for messages where #chat? responds positively
50
+ # and #body == 'exit'
51
+ message :chat?, :body => 'exit'
52
+
53
+ ### Non-Stanza Handlers
54
+
55
+ So far there are two non-stanza related handlers.
56
+
57
+ # Called after the connection has been connected. It's good for initializing
58
+ # your system.
59
+ # DSL:
60
+ when_ready {}
61
+ # Client:
62
+ client.register_handler(:ready) {}
63
+
64
+ # Called after the connection has been terminated. Good for teardown or
65
+ # automatic reconnection.
66
+ # DSL:
67
+ disconnected {}
68
+ # Client
69
+ client.register_handler(:disconnected) {}
70
+ # The following will reconnect every time the connection is lost:
71
+ disconnected { client.connect }
72
+
73
+ ### Handler Guards
74
+
75
+ Guards act like AND statements. Each condition must be met if the handler is to
76
+ be used.
77
+
78
+ # Equivalent to saying (stanza.chat? && stanza.body)
79
+ message :chat?, :body
80
+
81
+ The different types of guards are:
82
+
83
+ # Symbol
84
+ # Checks for a non-false reply to calling the symbol on the stanza
85
+ # Equivalent to stanza.chat?
86
+ message :chat?
87
+
88
+ # Hash with any value (:body => 'exit')
89
+ # Calls the key on the stanza and checks for equality
90
+ # Equivalent to stanza.body == 'exit'
91
+ message :body => 'exit'
92
+
93
+ # Hash with regular expression (:body => /exit/)
94
+ # Calls the key on the stanza and checks for a match
95
+ # Equivalent to stanza.body.match /exit/
96
+ message :body => /exit/
97
+
98
+ # Hash with array (:name => [:gone, :forbidden])
99
+ # Calls the key on the stanza and check for inclusion in the array
100
+ # Equivalent to [:gone, :forbidden].include?(stanza.name)
101
+ stanza_error :name => [:gone, :fobidden]
102
+
103
+ # Proc
104
+ # Calls the proc passing in the stanza
105
+ # Checks that the ID is modulo 3
106
+ message proc { |m| m.id % 3 == 0 }
107
+
108
+ # Array
109
+ # Use arrays with the previous types effectively turns the guard into
110
+ # an OR statement.
111
+ # Equivalent to stanza.body == 'foo' || stanza.body == 'baz'
112
+ message [{:body => 'foo'}, {:body => 'baz'}]
113
+
114
+ # XPath
115
+ # Runs the xpath query on the stanza and checks for results
116
+ # This guard type cannot be combined with other guards
117
+ # Equivalent to !stanza.find('/iq/ns:pubsub', :ns => 'pubsub:namespace').empty?
118
+ iq '/iq/ns:pubsub', :ns => 'pubsub:namespace'
119
+
120
+ ### Filters
121
+
122
+ Blather provides before and after filters that work much the way regular
123
+ handlers work. Filters come in a before and after flavor. They're called in
124
+ order of definition and can be guarded like handlers.
125
+
126
+ before { |s| "I'm run before any handler" }
127
+ before { |s| "I'm run next" }
128
+
129
+ before(:message) { |s| "I'm only run in front of message stanzas" }
130
+ before(nil, :id => 1) { |s| "I'll only be run when the stanza's ID == 1" }
131
+
132
+ # ... handlers
133
+
134
+ after { |s| "I'm run after everything" }
135
+
136
+ ## On the Command Line:
137
+
138
+ Default usage is:
139
+
140
+ [blather_script] [options] node@domain.com/resource password [host] [port]
141
+
142
+ Command line options:
143
+
144
+ -D, --debug Run in debug mode (you will see all XMPP communication)
145
+ -d, --daemonize Daemonize the process
146
+ --pid=[PID] Write the PID to this file
147
+ --log=[LOG] Write to the [LOG] file instead of stdout/stderr
148
+ -h, --help Show this message
149
+ -v, --version Show version
150
+
151
+
152
+ # Author
153
+
154
+ [Jeff Smick](http://github.com/sprsquish)
155
+
156
+ ### Contributors
157
+
158
+ [Nolan Darilek](http://github.com/thewordnerd)
159
+
160
+ # Copyright
161
+
162
+ Copyright (c) 2009 Jeff Smick. See LICENSE for details.
@@ -8,7 +8,7 @@ class Object
8
8
  # We check defined? in case we find a removed class that has yet to be
9
9
  # garbage collected. This also fails for anonymous classes -- please
10
10
  # submit a patch if you have a workaround.
11
- def subclasses_of(*superclasses) #:nodoc:
11
+ def subclasses_of(*superclasses)
12
12
  subclasses = []
13
13
 
14
14
  superclasses.each do |sup|
@@ -24,7 +24,7 @@ class Object
24
24
  rescue RuntimeError
25
25
  # JRuby and any implementations which cannot handle the objectspace traversal
26
26
  # above fall back to this implementation
27
- def subclasses_of(*superclasses) #:nodoc:
27
+ def subclasses_of(*superclasses)
28
28
  subclasses = []
29
29
 
30
30
  superclasses.each do |sup|
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  handlers = {}
54
54
  (Object.subclasses_of(Blather::Stanza) + Object.subclasses_of(Blather::BlatherError)).each do |klass|
55
- handlers = handlers.deep_merge klass.handler_heirarchy.inject('klass' => klass.to_s.gsub('Blather::', '')) { |h,k| {k.to_s => h} }
55
+ handlers = handlers.deep_merge klass.handler_hierarchy.inject('klass' => klass.to_s.gsub('Blather::', '')) { |h,k| {k.to_s => h} }
56
56
  end
57
57
 
58
58
  level = 0
@@ -61,8 +61,8 @@ runner = proc do |k,v|
61
61
 
62
62
  str = ''
63
63
  if level > 0
64
- (level - 1).times { str << '| ' }
65
- str << '|-- '
64
+ (level - 1).times { str << '| ' }
65
+ str << '|- '
66
66
  end
67
67
 
68
68
  puts str+k
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'blather'
4
+
5
+ trap(:INT) { EM.stop }
6
+ trap(:TERM) { EM.stop }
7
+ EM.run do
8
+ Blather::Stream::Client.start(Class.new {
9
+ attr_accessor :jid
10
+
11
+ def post_init(stream, jid = nil)
12
+ @stream = stream
13
+ self.jid = jid
14
+
15
+ @stream.send_data Blather::Stanza::Presence::Status.new
16
+ puts "Stream started!"
17
+ end
18
+
19
+ def receive_data(stanza)
20
+ @stream.send_data stanza.reply!
21
+ end
22
+
23
+ def unbind
24
+ puts "Stream ended!"
25
+ end
26
+ }.new, 'echo@jabber.local', 'echo')
27
+ end
data/lib/blather.rb CHANGED
@@ -58,7 +58,10 @@
58
58
  ].each { |r| require r }
59
59
 
60
60
  module Blather
61
+ # @private
61
62
  @@logger = nil
63
+
64
+ # Get or create an instance of Logger
62
65
  def self.logger
63
66
  unless @@logger
64
67
  self.logger = Logger.new($stdout)
@@ -67,6 +70,7 @@ module Blather
67
70
  @@logger
68
71
  end
69
72
 
73
+ # Set the Logger
70
74
  def self.logger=(logger)
71
75
  @@logger = logger
72
76
  end
@@ -1,48 +1,54 @@
1
1
  require File.join(File.dirname(__FILE__), *%w[.. .. blather])
2
2
 
3
- module Blather #:nodoc:
4
-
5
- # = Blather Client
3
+ module Blather
4
+ # # Blather Client
6
5
  #
7
- # Blather's Client class provides a set of helpers for working with common XMPP tasks such as setting up and starting
8
- # the connection, settings status, registering and dispatching filters and handlers and roster management.
6
+ # Blather's Client class provides a set of helpers for working with common
7
+ # XMPP tasks such as setting up and starting the connection, settings
8
+ # status, registering and dispatching filters and handlers and roster
9
+ # management.
9
10
  #
10
- # Client can be used separately from the DSL if you'd like to implement your own DSL
11
- # Here's the echo example using the client without the DSL:
11
+ # Client can be used separately from the DSL if you'd like to implement your
12
+ # own DSL Here's the echo example using the client without the DSL:
12
13
  #
13
- # require 'blather/client/client'
14
- # client = Client.setup 'echo@jabber.local', 'echo'
14
+ # require 'blather/client/client'
15
+ # client = Client.setup 'echo@jabber.local', 'echo'
15
16
  #
16
- # client.register_handler(:ready) { puts "Connected ! send messages to #{client.jid.stripped}." }
17
+ # client.register_handler(:ready) do
18
+ # puts "Connected ! send messages to #{client.jid.stripped}."
19
+ # end
17
20
  #
18
- # client.register_handler :subscription, :request? do |s|
19
- # client.write s.approve!
20
- # end
21
+ # client.register_handler :subscription, :request? do |s|
22
+ # client.write s.approve!
23
+ # end
21
24
  #
22
- # client.register_handler :message, :chat?, :body => 'exit' do |m|
23
- # client.write Blather::Stanza::Message.new(m.from, 'Exiting...')
24
- # client.close
25
- # end
25
+ # client.register_handler :message, :chat?, :body => 'exit' do |m|
26
+ # client.write Blather::Stanza::Message.new(m.from, 'Exiting...')
27
+ # client.close
28
+ # end
26
29
  #
27
- # client.register_handler :message, :chat?, :body do |m|
28
- # client.write Blather::Stanza::Message.new(m.from, "You sent: #{m.body}")
29
- # end
30
+ # client.register_handler :message, :chat?, :body do |m|
31
+ # client.write Blather::Stanza::Message.new(m.from, "You sent: #{m.body}")
32
+ # end
30
33
  #
31
34
  class Client
32
35
  attr_reader :jid,
33
36
  :roster
34
37
 
35
- ##
36
- # Initialize and setup the client
37
- # * +jid+ - the JID to login with
38
- # * +password+ - password associated with the JID
39
- # * +host+ - hostname or IP to connect to. If nil the stream will look one up based on the domain in the JID
40
- # * +port+ - port to connect to
38
+ # Create a new client and set it up
39
+ #
40
+ # @param [Blather::JID, #to_s] jid the JID to authorize with
41
+ # @param [String] password the password to authorize with
42
+ # @param [String] host if this isn't set it'll be resolved off the JID's
43
+ # domain
44
+ # @param [Fixnum, String] port the port to connect to.
45
+ #
46
+ # @return [Blather::Client]
41
47
  def self.setup(jid, password, host = nil, port = nil)
42
48
  self.new.setup(jid, password, host, port)
43
49
  end
44
50
 
45
- def initialize # :nodoc:
51
+ def initialize # @private
46
52
  @state = :initializing
47
53
 
48
54
  @status = Stanza::Presence::Status.new
@@ -54,14 +60,14 @@ module Blather #:nodoc:
54
60
  setup_initial_handlers
55
61
  end
56
62
 
57
- ##
58
- # Get the current status. Taken from the +state+ attribute of Status
63
+ # Get the current status. Taken from the `state` attribute of Status
59
64
  def status
60
65
  @status.state
61
66
  end
62
67
 
63
- ##
64
- # Set the status. Status can be set with either a single value or an array containing
68
+ # Set the status. Status can be set with either a single value or an array
69
+ # containing
70
+ #
65
71
  # [state, message, to].
66
72
  def status=(state)
67
73
  state, msg, to = state
@@ -73,8 +79,10 @@ module Blather #:nodoc:
73
79
  write status
74
80
  end
75
81
 
76
- ##
77
82
  # Start the connection.
83
+ #
84
+ # The stream type used is based on the JID. If a node exists it uses
85
+ # Blather::Stream::Client otherwise Blather::Stream::Component
78
86
  def run
79
87
  raise 'not setup!' unless setup?
80
88
  klass = @setup[0].node ? Blather::Stream::Client : Blather::Stream::Component
@@ -82,70 +90,79 @@ module Blather #:nodoc:
82
90
  end
83
91
  alias_method :connect, :run
84
92
 
85
- ##
86
93
  # Register a filter to be run before or after the handler chain is run.
87
- # * +type+ - the type of filter. Must be +:before+ or +:after+
88
- # * +guards+ - guards that should be checked before the filter is called
94
+ #
95
+ # @param [<:before, :after>] type the filter type
96
+ # @param [Symbol, nil] handler set the filter on a specific handler
97
+ # @param [guards] guards take a look at the guards documentation
98
+ # @yield [Blather::Stanza] stanza the incomming stanza
89
99
  def register_filter(type, handler = nil, *guards, &filter)
90
- raise "Invalid filter: #{type}. Must be :before or :after" unless [:before, :after].include?(type)
100
+ unless [:before, :after].include?(type)
101
+ raise "Invalid filter: #{type}. Must be :before or :after"
102
+ end
91
103
  @filters[type] << [guards, handler, filter]
92
104
  end
93
105
 
94
- ##
95
- # Register a temporary handler. Temporary handlers are based on the ID of the JID and live
96
- # only until a stanza with said ID is received.
97
- # * +id+ - the ID of the stanza that should be handled
106
+ # Register a temporary handler. Temporary handlers are based on the ID of
107
+ # the JID and live only until a stanza with said ID is received.
108
+ #
109
+ # @param [#to_s] id the ID of the stanza that should be handled
110
+ # @yield [Blather::Stanza] stanza the incomming stanza
98
111
  def register_tmp_handler(id, &handler)
99
- @tmp_handlers[id] = handler
112
+ @tmp_handlers[id.to_s] = handler
100
113
  end
101
114
 
102
- ##
103
115
  # Register a handler
104
- # * +type+ - the handler type. Should be registered in Stanza.handler_list. Blather will log a warning if it's not.
105
- # * +guards+ - the list of guards that must be verified before the handler will be called
116
+ #
117
+ # @param [Symbol, nil] handler set the filter on a specific handler
118
+ # @param [guards] guards take a look at the guards documentation
119
+ # @yield [Blather::Stanza] stanza the incomming stanza
106
120
  def register_handler(type, *guards, &handler)
107
121
  check_handler type, guards
108
122
  @handlers[type] ||= []
109
123
  @handlers[type] << [guards, handler]
110
124
  end
111
125
 
112
- ##
113
126
  # Write data to the stream
127
+ #
128
+ # @param [#to_xml, #to_s] stanza the content to send down the wire
114
129
  def write(stanza)
115
130
  self.stream.send(stanza)
116
131
  end
117
132
 
118
- ##
119
- # Helper that will create a temporary handler for the stanza being sent before writing it to the stream.
133
+ # Helper that will create a temporary handler for the stanza being sent
134
+ # before writing it to the stream.
120
135
  #
121
- # client.write_with_handler(stanza) { |s| "handle stanza here" }
136
+ # client.write_with_handler(stanza) { |s| "handle stanza here" }
122
137
  #
123
138
  # is equivalent to:
124
139
  #
125
- # client.register_tmp_handler(stanza.id) { |s| "handle stanza here" }
126
- # client.write stanza
140
+ # client.register_tmp_handler(stanza.id) { |s| "handle stanza here" }
141
+ # client.write stanza
142
+ #
143
+ # @param [Blather::Stanza] stanza the stanza to send down the wire
144
+ # @yield [Blather::Stanza] stanza the reply stanza
127
145
  def write_with_handler(stanza, &handler)
128
146
  register_tmp_handler stanza.id, &handler
129
147
  write stanza
130
148
  end
131
149
 
132
- ##
133
150
  # Close the connection
134
151
  def close
135
152
  self.stream.close_connection_after_writing
136
153
  end
137
154
 
138
- def post_init(stream, jid = nil) # :nodoc:
155
+ def post_init(stream, jid = nil) # @private
139
156
  @stream = stream
140
157
  @jid = JID.new(jid) if jid
141
158
  self.jid.node ? client_post_init : ready!
142
159
  end
143
160
 
144
- def unbind # :nodoc:
161
+ def unbind # @private
145
162
  call_handler_for(:disconnected, nil) || (EM.reactor_running? && EM.stop)
146
163
  end
147
164
 
148
- def receive_data(stanza) # :nodoc:
165
+ def receive_data(stanza) # @private
149
166
  catch(:halt) do
150
167
  run_filters :before, stanza
151
168
  handle_stanza stanza
@@ -153,11 +170,11 @@ module Blather #:nodoc:
153
170
  end
154
171
  end
155
172
 
156
- def setup? # :nodoc:
173
+ def setup? # @private
157
174
  @setup.is_a? Array
158
175
  end
159
176
 
160
- def setup(jid, password, host = nil, port = nil) # :nodoc:
177
+ def setup(jid, password, host = nil, port = nil) # @private
161
178
  @jid = JID.new(jid)
162
179
  @setup = [@jid, password]
163
180
  @setup << host if host
@@ -166,20 +183,20 @@ module Blather #:nodoc:
166
183
  end
167
184
 
168
185
  protected
169
- def stream
186
+ def stream # @private
170
187
  @stream || raise('Stream not ready!')
171
188
  end
172
189
 
173
- def check_handler(type, guards)
190
+ def check_handler(type, guards) # @private
174
191
  Blather.logger.warn "Handler for type \"#{type}\" will never be called as it's not a registered type" unless current_handlers.include?(type)
175
192
  check_guards guards
176
193
  end
177
194
 
178
- def current_handlers
195
+ def current_handlers # @private
179
196
  [:ready, :disconnected] + Stanza.handler_list + BlatherError.handler_list
180
197
  end
181
198
 
182
- def setup_initial_handlers # :nodoc:
199
+ def setup_initial_handlers # @private
183
200
  register_handler :error do |err|
184
201
  raise err
185
202
  end
@@ -198,12 +215,12 @@ module Blather #:nodoc:
198
215
  end
199
216
  end
200
217
 
201
- def ready! # :nodoc:
218
+ def ready! # @private
202
219
  @state = :ready
203
220
  call_handler_for :ready, nil
204
221
  end
205
222
 
206
- def client_post_init # :nodoc:
223
+ def client_post_init # @private
207
224
  write_with_handler Stanza::Iq::Roster.new do |node|
208
225
  roster.process node
209
226
  write @status
@@ -211,31 +228,31 @@ module Blather #:nodoc:
211
228
  end
212
229
  end
213
230
 
214
- def run_filters(type, stanza) # :nodoc:
231
+ def run_filters(type, stanza) # @private
215
232
  @filters[type].each do |guards, handler, filter|
216
- next if handler && !stanza.handler_heirarchy.include?(handler)
233
+ next if handler && !stanza.handler_hierarchy.include?(handler)
217
234
  catch(:pass) { call_handler filter, guards, stanza }
218
235
  end
219
236
  end
220
237
 
221
- def handle_stanza(stanza) # :nodoc:
238
+ def handle_stanza(stanza) # @private
222
239
  if handler = @tmp_handlers.delete(stanza.id)
223
240
  handler.call stanza
224
241
  else
225
- stanza.handler_heirarchy.each do |type|
242
+ stanza.handler_hierarchy.each do |type|
226
243
  break if call_handler_for(type, stanza)
227
244
  end
228
245
  end
229
246
  end
230
247
 
231
- def call_handler_for(type, stanza) # :nodoc:
248
+ def call_handler_for(type, stanza) # @private
232
249
  return unless handler = @handlers[type]
233
250
  handler.find do |guards, handler|
234
251
  catch(:pass) { call_handler handler, guards, stanza }
235
252
  end
236
253
  end
237
254
 
238
- def call_handler(handler, guards, stanza) # :nodoc:
255
+ def call_handler(handler, guards, stanza) # @private
239
256
  if guards.first.respond_to?(:to_str)
240
257
  result = stanza.find(*guards)
241
258
  handler.call(stanza, result) unless result.empty?
@@ -244,11 +261,12 @@ module Blather #:nodoc:
244
261
  end
245
262
  end
246
263
 
247
- ##
248
264
  # If any of the guards returns FALSE this returns true
249
265
  # the logic is reversed to allow short circuiting
250
266
  # (why would anyone want to loop over more values than necessary?)
251
- def guarded?(guards, stanza) # :nodoc:
267
+ #
268
+ # @private
269
+ def guarded?(guards, stanza)
252
270
  guards.find do |guard|
253
271
  case guard
254
272
  when Symbol
@@ -275,7 +293,7 @@ module Blather #:nodoc:
275
293
  end
276
294
  end
277
295
 
278
- def check_guards(guards) # :nodoc:
296
+ def check_guards(guards) # @private
279
297
  guards.each do |guard|
280
298
  case guard
281
299
  when Array
@@ -287,6 +305,6 @@ module Blather #:nodoc:
287
305
  end
288
306
  end
289
307
  end
308
+ end # Client
290
309
 
291
- end #Client
292
- end #Blather
310
+ end # Blather