blather 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +36 -33
- data/README.rdoc +11 -17
- data/Rakefile +4 -3
- data/blather.gemspec +9 -9
- data/examples/drb_client.rb +7 -0
- data/examples/echo.rb +9 -18
- data/lib/blather.rb +140 -31
- data/lib/blather/{core/errors.rb → errors.rb} +0 -0
- data/lib/blather/{core/jid.rb → jid.rb} +0 -0
- data/lib/blather/{core/roster.rb → roster.rb} +0 -0
- data/lib/blather/{core/roster_item.rb → roster_item.rb} +0 -0
- data/lib/blather/{core/stanza.rb → stanza.rb} +6 -14
- data/lib/blather/stanza/error.rb +31 -0
- data/lib/blather/{core/stanza → stanza}/iq.rb +2 -2
- data/lib/blather/stanza/iq/query.rb +50 -0
- data/lib/blather/{core/stanza → stanza}/iq/roster.rb +3 -3
- data/lib/blather/{core/stanza → stanza}/message.rb +6 -2
- data/lib/blather/{core/stanza → stanza}/presence.rb +10 -0
- data/lib/blather/{core/stanza → stanza}/presence/status.rb +8 -6
- data/lib/blather/{core/stanza → stanza}/presence/subscription.rb +1 -1
- data/lib/blather/{core/stream.rb → stream.rb} +1 -1
- data/lib/blather/{core/stream → stream}/parser.rb +0 -5
- data/lib/blather/{core/stream → stream}/resource.rb +0 -0
- data/lib/blather/{core/stream → stream}/sasl.rb +16 -5
- data/lib/blather/{core/stream → stream}/session.rb +0 -0
- data/lib/blather/{core/stream → stream}/tls.rb +0 -0
- data/lib/blather/{core/sugar.rb → sugar.rb} +4 -0
- data/lib/blather/{core/xmpp_node.rb → xmpp_node.rb} +1 -3
- data/spec/blather/{core/jid_spec.rb → jid_spec.rb} +16 -1
- data/spec/blather/{core/roster_item_spec.rb → roster_item_spec.rb} +1 -1
- data/spec/blather/{core/roster_spec.rb → roster_spec.rb} +11 -1
- data/spec/blather/stanza/iq/query_spec.rb +34 -0
- data/spec/blather/stanza/iq/roster_spec.rb +7 -0
- data/spec/blather/stanza/iq_spec.rb +11 -0
- data/spec/blather/stanza/message_spec.rb +52 -0
- data/spec/blather/stanza/presence/status_spec.rb +102 -0
- data/spec/blather/stanza/presence/subscription_spec.rb +74 -0
- data/spec/blather/stanza/presence_spec.rb +24 -0
- data/spec/blather/{core/stanza_spec.rb → stanza_spec.rb} +1 -1
- data/spec/blather/{core/stream_spec.rb → stream_spec.rb} +208 -9
- data/spec/blather/{core/xmpp_node_spec.rb → xmpp_node_spec.rb} +1 -1
- metadata +75 -69
- data/examples/shell_client.rb +0 -28
- data/lib/blather/callback.rb +0 -24
- data/lib/blather/client.rb +0 -81
- data/lib/blather/core/stanza/iq/query.rb +0 -42
- data/lib/blather/extensions.rb +0 -4
- data/lib/blather/extensions/last_activity.rb +0 -55
- data/lib/blather/extensions/version.rb +0 -85
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
@@ -1,43 +1,46 @@
|
|
1
1
|
CHANGELOG
|
2
|
+
examples/drb_client.rb
|
2
3
|
examples/echo.rb
|
3
|
-
examples/shell_client.rb
|
4
4
|
lib/autotest/discover.rb
|
5
5
|
lib/autotest/spec.rb
|
6
|
-
lib/blather/
|
7
|
-
lib/blather/
|
8
|
-
lib/blather/
|
9
|
-
lib/blather/
|
10
|
-
lib/blather/
|
11
|
-
lib/blather/
|
12
|
-
lib/blather/
|
13
|
-
lib/blather/
|
14
|
-
lib/blather/
|
15
|
-
lib/blather/
|
16
|
-
lib/blather/
|
17
|
-
lib/blather/
|
18
|
-
lib/blather/
|
19
|
-
lib/blather/
|
20
|
-
lib/blather/
|
21
|
-
lib/blather/
|
22
|
-
lib/blather/
|
23
|
-
lib/blather/
|
24
|
-
lib/blather/
|
25
|
-
lib/blather/
|
26
|
-
lib/blather/
|
27
|
-
lib/blather/core/xmpp_node.rb
|
28
|
-
lib/blather/extensions/last_activity.rb
|
29
|
-
lib/blather/extensions/version.rb
|
30
|
-
lib/blather/extensions.rb
|
6
|
+
lib/blather/errors.rb
|
7
|
+
lib/blather/jid.rb
|
8
|
+
lib/blather/roster.rb
|
9
|
+
lib/blather/roster_item.rb
|
10
|
+
lib/blather/stanza/error.rb
|
11
|
+
lib/blather/stanza/iq/query.rb
|
12
|
+
lib/blather/stanza/iq/roster.rb
|
13
|
+
lib/blather/stanza/iq.rb
|
14
|
+
lib/blather/stanza/message.rb
|
15
|
+
lib/blather/stanza/presence/status.rb
|
16
|
+
lib/blather/stanza/presence/subscription.rb
|
17
|
+
lib/blather/stanza/presence.rb
|
18
|
+
lib/blather/stanza.rb
|
19
|
+
lib/blather/stream/parser.rb
|
20
|
+
lib/blather/stream/resource.rb
|
21
|
+
lib/blather/stream/sasl.rb
|
22
|
+
lib/blather/stream/session.rb
|
23
|
+
lib/blather/stream/tls.rb
|
24
|
+
lib/blather/stream.rb
|
25
|
+
lib/blather/sugar.rb
|
26
|
+
lib/blather/xmpp_node.rb
|
31
27
|
lib/blather.rb
|
32
28
|
LICENSE
|
29
|
+
Manifest
|
33
30
|
Rakefile
|
34
31
|
README.rdoc
|
35
|
-
spec/blather/
|
36
|
-
spec/blather/
|
37
|
-
spec/blather/
|
38
|
-
spec/blather/
|
39
|
-
spec/blather/
|
40
|
-
spec/blather/
|
32
|
+
spec/blather/jid_spec.rb
|
33
|
+
spec/blather/roster_item_spec.rb
|
34
|
+
spec/blather/roster_spec.rb
|
35
|
+
spec/blather/stanza/iq/query_spec.rb
|
36
|
+
spec/blather/stanza/iq/roster_spec.rb
|
37
|
+
spec/blather/stanza/iq_spec.rb
|
38
|
+
spec/blather/stanza/message_spec.rb
|
39
|
+
spec/blather/stanza/presence/status_spec.rb
|
40
|
+
spec/blather/stanza/presence/subscription_spec.rb
|
41
|
+
spec/blather/stanza/presence_spec.rb
|
42
|
+
spec/blather/stanza_spec.rb
|
43
|
+
spec/blather/stream_spec.rb
|
44
|
+
spec/blather/xmpp_node_spec.rb
|
41
45
|
spec/build_safe.rb
|
42
46
|
spec/spec_helper.rb
|
43
|
-
Manifest
|
data/README.rdoc
CHANGED
@@ -30,28 +30,22 @@ Jeff Smick <sprsquish@gmail.com>
|
|
30
30
|
|
31
31
|
See the /examples directory for more advanced examples.
|
32
32
|
|
33
|
-
This will auto-accept any subscription requests and echo back any messages
|
33
|
+
This will auto-accept any subscription requests and echo back any chat messages.
|
34
34
|
|
35
|
-
require
|
35
|
+
%w[rubygems blather].each { |r| require r }
|
36
36
|
|
37
|
-
|
38
|
-
# Auto-approve subscription requests
|
39
|
-
def receive_subscription(s)
|
40
|
-
send_data(s.approve!) and true if s.request?
|
41
|
-
end
|
37
|
+
setup 'echo@jabber.local', 'echo'
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
# Echo message
|
49
|
-
def receive_message(message)
|
50
|
-
send_data(message.reply) if message.type == :chat
|
51
|
-
end
|
39
|
+
# Auto approve subscription requests
|
40
|
+
handle :subscription do |s|
|
41
|
+
write(s.approve!) if s.request?
|
52
42
|
end
|
53
43
|
|
54
|
-
|
44
|
+
# Echo back what was said
|
45
|
+
handle :message do |m|
|
46
|
+
write(m.reply) if m.chat? && m.body
|
47
|
+
end
|
48
|
+
|
55
49
|
|
56
50
|
|
57
51
|
= License
|
data/Rakefile
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require 'echoe'
|
2
|
-
require 'lib/blather'
|
3
2
|
require 'hanna/rdoctask'
|
4
3
|
|
5
4
|
Echoe.new('blather') do |p|
|
6
5
|
p.author = 'Jeff Smick'
|
7
6
|
p.email = 'sprsquish@gmail.com'
|
7
|
+
p.url = 'http://github.com/sprsquish/blather/tree/master'
|
8
8
|
|
9
9
|
p.project = 'squishtech'
|
10
|
-
p.version = Blather::VERSION
|
11
10
|
p.summary = 'An evented XMPP library written on EventMachine and libxml-ruby'
|
12
11
|
|
13
|
-
p.runtime_dependencies = ['eventmachine', 'libxml >=
|
12
|
+
p.runtime_dependencies = ['eventmachine', 'libxml-ruby >=0.9.2']
|
14
13
|
p.rdoc_options += %w[-S -T hanna --main README.rdoc --exclude autotest]
|
14
|
+
|
15
15
|
p.test_pattern = 'spec/**/*_spec.rb'
|
16
|
+
p.rcov_options = ['--exclude \/Library\/Ruby\/Gems,spec\/', '--xrefs']
|
16
17
|
end
|
data/blather.gemspec
CHANGED
@@ -2,23 +2,23 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{blather}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jeff Smick"]
|
9
|
-
s.date = %q{2008-
|
9
|
+
s.date = %q{2008-12-19}
|
10
10
|
s.description = %q{An evented XMPP library written on EventMachine and libxml-ruby}
|
11
11
|
s.email = %q{sprsquish@gmail.com}
|
12
|
-
s.extra_rdoc_files = ["CHANGELOG", "lib/autotest/discover.rb", "lib/autotest/spec.rb", "lib/blather/
|
13
|
-
s.files = ["CHANGELOG", "examples/
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "lib/autotest/discover.rb", "lib/autotest/spec.rb", "lib/blather/errors.rb", "lib/blather/jid.rb", "lib/blather/roster.rb", "lib/blather/roster_item.rb", "lib/blather/stanza/error.rb", "lib/blather/stanza/iq/query.rb", "lib/blather/stanza/iq/roster.rb", "lib/blather/stanza/iq.rb", "lib/blather/stanza/message.rb", "lib/blather/stanza/presence/status.rb", "lib/blather/stanza/presence/subscription.rb", "lib/blather/stanza/presence.rb", "lib/blather/stanza.rb", "lib/blather/stream/parser.rb", "lib/blather/stream/resource.rb", "lib/blather/stream/sasl.rb", "lib/blather/stream/session.rb", "lib/blather/stream/tls.rb", "lib/blather/stream.rb", "lib/blather/sugar.rb", "lib/blather/xmpp_node.rb", "lib/blather.rb", "LICENSE", "README.rdoc"]
|
13
|
+
s.files = ["CHANGELOG", "examples/drb_client.rb", "examples/echo.rb", "lib/autotest/discover.rb", "lib/autotest/spec.rb", "lib/blather/errors.rb", "lib/blather/jid.rb", "lib/blather/roster.rb", "lib/blather/roster_item.rb", "lib/blather/stanza/error.rb", "lib/blather/stanza/iq/query.rb", "lib/blather/stanza/iq/roster.rb", "lib/blather/stanza/iq.rb", "lib/blather/stanza/message.rb", "lib/blather/stanza/presence/status.rb", "lib/blather/stanza/presence/subscription.rb", "lib/blather/stanza/presence.rb", "lib/blather/stanza.rb", "lib/blather/stream/parser.rb", "lib/blather/stream/resource.rb", "lib/blather/stream/sasl.rb", "lib/blather/stream/session.rb", "lib/blather/stream/tls.rb", "lib/blather/stream.rb", "lib/blather/sugar.rb", "lib/blather/xmpp_node.rb", "lib/blather.rb", "LICENSE", "Manifest", "Rakefile", "README.rdoc", "spec/blather/jid_spec.rb", "spec/blather/roster_item_spec.rb", "spec/blather/roster_spec.rb", "spec/blather/stanza/iq/query_spec.rb", "spec/blather/stanza/iq/roster_spec.rb", "spec/blather/stanza/iq_spec.rb", "spec/blather/stanza/message_spec.rb", "spec/blather/stanza/presence/status_spec.rb", "spec/blather/stanza/presence/subscription_spec.rb", "spec/blather/stanza/presence_spec.rb", "spec/blather/stanza_spec.rb", "spec/blather/stream_spec.rb", "spec/blather/xmpp_node_spec.rb", "spec/build_safe.rb", "spec/spec_helper.rb", "blather.gemspec"]
|
14
14
|
s.has_rdoc = true
|
15
|
-
s.homepage = %q{}
|
15
|
+
s.homepage = %q{http://github.com/sprsquish/blather/tree/master}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Blather", "--main", "README.rdoc", "-S", "-T", "hanna", "--main", "README.rdoc", "--exclude", "autotest"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubyforge_project = %q{squishtech}
|
19
19
|
s.rubygems_version = %q{1.3.1}
|
20
20
|
s.summary = %q{An evented XMPP library written on EventMachine and libxml-ruby}
|
21
|
-
s.test_files = ["spec/blather/
|
21
|
+
s.test_files = ["spec/blather/jid_spec.rb", "spec/blather/roster_item_spec.rb", "spec/blather/roster_spec.rb", "spec/blather/stanza/iq/query_spec.rb", "spec/blather/stanza/iq/roster_spec.rb", "spec/blather/stanza/iq_spec.rb", "spec/blather/stanza/message_spec.rb", "spec/blather/stanza/presence/status_spec.rb", "spec/blather/stanza/presence/subscription_spec.rb", "spec/blather/stanza/presence_spec.rb", "spec/blather/stanza_spec.rb", "spec/blather/stream_spec.rb", "spec/blather/xmpp_node_spec.rb"]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -26,16 +26,16 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
|
29
|
-
s.add_runtime_dependency(%q<libxml>, [">=
|
29
|
+
s.add_runtime_dependency(%q<libxml-ruby>, [">= 0.9.2"])
|
30
30
|
s.add_development_dependency(%q<echoe>, [">= 0"])
|
31
31
|
else
|
32
32
|
s.add_dependency(%q<eventmachine>, [">= 0"])
|
33
|
-
s.add_dependency(%q<libxml>, [">=
|
33
|
+
s.add_dependency(%q<libxml-ruby>, [">= 0.9.2"])
|
34
34
|
s.add_dependency(%q<echoe>, [">= 0"])
|
35
35
|
end
|
36
36
|
else
|
37
37
|
s.add_dependency(%q<eventmachine>, [">= 0"])
|
38
|
-
s.add_dependency(%q<libxml>, [">=
|
38
|
+
s.add_dependency(%q<libxml-ruby>, [">= 0.9.2"])
|
39
39
|
s.add_dependency(%q<echoe>, [">= 0"])
|
40
40
|
end
|
41
41
|
end
|
data/examples/echo.rb
CHANGED
@@ -1,22 +1,13 @@
|
|
1
|
-
|
2
|
-
include Blather
|
1
|
+
%w[rubygems lib/blather].each { |r| require r }
|
3
2
|
|
4
|
-
|
5
|
-
# Auto-approve subscription requests
|
6
|
-
def receive_subscription(s)
|
7
|
-
send_data(s.approve!) and true if s.request?
|
8
|
-
end
|
3
|
+
setup 'echo@jabber.local', 'echo'
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
# Echo message
|
16
|
-
def receive_message(message)
|
17
|
-
send_data(message.reply) if message.type == :chat
|
18
|
-
end
|
5
|
+
# Auto approve subscription requests
|
6
|
+
handle :subscription do |s|
|
7
|
+
write(s.approve!) if s.request?
|
19
8
|
end
|
20
9
|
|
21
|
-
#
|
22
|
-
|
10
|
+
# Echo back what was said
|
11
|
+
handle :message do |m|
|
12
|
+
write(m.reply) if m.chat? && m.body
|
13
|
+
end
|
data/lib/blather.rb
CHANGED
@@ -7,40 +7,149 @@ $:.unshift File.dirname(__FILE__)
|
|
7
7
|
digest/md5
|
8
8
|
logger
|
9
9
|
|
10
|
-
blather/
|
11
|
-
|
12
|
-
blather/
|
13
|
-
blather/
|
14
|
-
blather/
|
15
|
-
blather/
|
16
|
-
|
17
|
-
blather/
|
18
|
-
|
19
|
-
blather/
|
20
|
-
blather/
|
21
|
-
blather/
|
22
|
-
blather/
|
23
|
-
blather/
|
24
|
-
blather/
|
25
|
-
blather/
|
26
|
-
|
27
|
-
|
28
|
-
blather/
|
29
|
-
blather/
|
30
|
-
blather/
|
31
|
-
blather/
|
32
|
-
blather/
|
33
|
-
blather/core/stream/tls
|
10
|
+
blather/errors
|
11
|
+
blather/jid
|
12
|
+
blather/roster
|
13
|
+
blather/roster_item
|
14
|
+
blather/sugar
|
15
|
+
blather/xmpp_node
|
16
|
+
|
17
|
+
blather/stanza
|
18
|
+
blather/stanza/error
|
19
|
+
blather/stanza/iq
|
20
|
+
blather/stanza/iq/query
|
21
|
+
blather/stanza/iq/roster
|
22
|
+
blather/stanza/message
|
23
|
+
blather/stanza/presence
|
24
|
+
blather/stanza/presence/status
|
25
|
+
blather/stanza/presence/subscription
|
26
|
+
|
27
|
+
blather/stream
|
28
|
+
blather/stream/parser
|
29
|
+
blather/stream/resource
|
30
|
+
blather/stream/sasl
|
31
|
+
blather/stream/session
|
32
|
+
blather/stream/tls
|
34
33
|
].each { |r| require r }
|
35
34
|
|
36
|
-
XML
|
35
|
+
XML.indent_tree_output = false
|
37
36
|
|
38
37
|
module Blather
|
39
|
-
|
40
|
-
|
38
|
+
LOG = Logger.new(STDOUT)
|
39
|
+
|
40
|
+
class Client
|
41
|
+
attr_accessor :jid,
|
42
|
+
:roster
|
43
|
+
|
44
|
+
def initialize
|
45
|
+
@state = :initializing
|
46
|
+
|
47
|
+
@status = Stanza::Presence::Status.new
|
48
|
+
@handlers = Hash.new { |h,k| h[k] = [] }
|
49
|
+
@roster = Roster.new self
|
50
|
+
|
51
|
+
setup_initial_handlers
|
52
|
+
end
|
53
|
+
|
54
|
+
def register_handler(type, &handler)
|
55
|
+
@handlers[type] << handler
|
56
|
+
end
|
57
|
+
|
58
|
+
def status
|
59
|
+
@status.state
|
60
|
+
end
|
61
|
+
|
62
|
+
def status=(state)
|
63
|
+
state, msg, to = state
|
64
|
+
|
65
|
+
status = Stanza::Presence::Status.new state, msg
|
66
|
+
status.to = to
|
67
|
+
@status = status unless to
|
68
|
+
|
69
|
+
write status
|
70
|
+
end
|
71
|
+
|
72
|
+
def write(data)
|
73
|
+
@stream.send(data) if @stream
|
74
|
+
end
|
75
|
+
|
76
|
+
def stream_started(stream)
|
77
|
+
@stream = stream
|
78
|
+
|
79
|
+
#retreive roster
|
80
|
+
write Stanza::Iq::Roster.new
|
81
|
+
end
|
82
|
+
|
83
|
+
def call(stanza)
|
84
|
+
stanza.handler_heirarchy.each do |type|
|
85
|
+
break if call_handler_for(type, stanza) && stanza.type == :iq
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def call_handler_for(type, stanza)
|
90
|
+
if @handlers[type]
|
91
|
+
@handlers[type].each { |handler| handler.call(stanza) }
|
92
|
+
true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
protected
|
97
|
+
def setup_initial_handlers
|
98
|
+
register_handler :iq do |iq|
|
99
|
+
write(Stanza::Error.new_from(iq, 'service-unavailable', 'cancel').reply!) if [:set, :get].include?(iq.type)
|
100
|
+
end
|
101
|
+
|
102
|
+
register_handler :status do |status|
|
103
|
+
roster[status.from].status = status if roster[status.from]
|
104
|
+
end
|
105
|
+
|
106
|
+
register_handler :roster do |node|
|
107
|
+
roster.process node
|
108
|
+
if @state == :initializing
|
109
|
+
@state = :ready
|
110
|
+
write @status
|
111
|
+
call_handler_for :ready, nil
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end #Client
|
117
|
+
|
118
|
+
module Application
|
119
|
+
@@client = Blather::Client.new
|
120
|
+
|
121
|
+
def setup(jid, password, host = nil, port = 5222)
|
122
|
+
at_exit do
|
123
|
+
trap(:INT) { EM.stop }
|
124
|
+
EM.run { Blather::Stream.start @@client, Blather::JID.new(jid), password, host, port }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def daemonize
|
129
|
+
@daemonize = true
|
130
|
+
end
|
131
|
+
|
132
|
+
def handle(stanza_type, &block)
|
133
|
+
@@client.register_handler stanza_type, &block
|
134
|
+
end
|
135
|
+
|
136
|
+
def status(state = nil, msg = nil)
|
137
|
+
@@client.status = state, msg
|
138
|
+
end
|
139
|
+
|
140
|
+
def roster
|
141
|
+
@@client.roster
|
142
|
+
end
|
143
|
+
|
144
|
+
def write(stanza)
|
145
|
+
@@client.write(stanza)
|
146
|
+
end
|
147
|
+
|
148
|
+
def say(to, msg)
|
149
|
+
@@client.write Blather::Stanza::Message.new(to, msg)
|
150
|
+
end
|
151
|
+
end #Application
|
41
152
|
|
42
|
-
def run(jid, password, client, host = nil, port = 5222)
|
43
|
-
EM.run { Stream.start client, JID.new(jid), password, host, port }
|
44
|
-
end
|
45
|
-
module_function :run
|
46
153
|
end
|
154
|
+
|
155
|
+
include Blather::Application
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,13 +2,7 @@ module Blather
|
|
2
2
|
##
|
3
3
|
# Base XMPP Stanza
|
4
4
|
class Stanza < XMPPNode
|
5
|
-
|
6
|
-
|
7
|
-
def self.registered_callbacks
|
8
|
-
@@registered_callbacks
|
9
|
-
end
|
10
|
-
|
11
|
-
class_inheritable_array :callback_heirarchy
|
5
|
+
class_inheritable_array :handler_heirarchy
|
12
6
|
|
13
7
|
##
|
14
8
|
# Registers a callback onto the callback heirarchy stack
|
@@ -17,13 +11,11 @@ module Blather
|
|
17
11
|
# that inherits Stanza can register a callback for itself
|
18
12
|
# which is added to a list and iterated over when looking for
|
19
13
|
# a callback to use
|
20
|
-
def self.register(
|
21
|
-
|
22
|
-
|
23
|
-
self.callback_heirarchy ||= []
|
24
|
-
self.callback_heirarchy.unshift callback_type
|
14
|
+
def self.register(type, name = nil, xmlns = nil)
|
15
|
+
self.handler_heirarchy ||= []
|
16
|
+
self.handler_heirarchy.unshift type
|
25
17
|
|
26
|
-
name = name || self.name ||
|
18
|
+
name = name || self.name || type
|
27
19
|
super name, xmlns
|
28
20
|
end
|
29
21
|
|
@@ -109,7 +101,7 @@ module Blather
|
|
109
101
|
##
|
110
102
|
# returns:: a symbol of the type
|
111
103
|
def type
|
112
|
-
self['type'].to_sym
|
104
|
+
self['type'].to_sym unless self['type'].nil? || self['type'].empty?
|
113
105
|
end
|
114
106
|
|
115
107
|
end
|