blather 0.4.16 → 0.5.0
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/.gemtest +0 -0
- data/CHANGELOG +12 -5
- data/README.md +1 -1
- data/Rakefile +1 -3
- data/blather.gemspec +11 -24
- data/examples/echo.rb +1 -0
- data/examples/execute.rb +1 -0
- data/examples/ping_pong.rb +1 -0
- data/examples/print_hierarchy.rb +1 -0
- data/examples/rosterprint.rb +1 -0
- data/examples/stream_only.rb +1 -0
- data/examples/xmpp4r/echo.rb +1 -0
- data/lib/blather.rb +5 -1
- data/lib/blather/client/client.rb +29 -154
- data/lib/blather/client/dsl.rb +9 -3
- data/lib/blather/client/dsl/pubsub.rb +2 -0
- data/lib/blather/core_ext/eventmachine.rb +4 -1
- data/lib/blather/core_ext/ipaddr.rb +2 -1
- data/lib/blather/core_ext/nokogiri.rb +3 -1
- data/lib/blather/errors/sasl_error.rb +1 -0
- data/lib/blather/errors/stanza_error.rb +3 -1
- data/lib/blather/errors/stream_error.rb +1 -0
- data/lib/blather/file_transfer.rb +4 -1
- data/lib/blather/file_transfer/s5b.rb +3 -4
- data/lib/blather/jid.rb +2 -0
- data/lib/blather/roster_item.rb +13 -3
- data/lib/blather/stanza.rb +11 -3
- data/lib/blather/stanza/disco/capabilities.rb +161 -0
- data/lib/blather/stanza/disco/disco_info.rb +3 -1
- data/lib/blather/stanza/disco/disco_items.rb +0 -1
- data/lib/blather/stanza/iq.rb +8 -2
- data/lib/blather/stanza/iq/command.rb +18 -3
- data/lib/blather/stanza/iq/ibb.rb +6 -3
- data/lib/blather/stanza/iq/s5b.rb +6 -3
- data/lib/blather/stanza/iq/si.rb +6 -1
- data/lib/blather/stanza/iq/vcard.rb +3 -1
- data/lib/blather/stanza/message.rb +5 -0
- data/lib/blather/stanza/presence.rb +1 -0
- data/lib/blather/stanza/presence/c.rb +1 -0
- data/lib/blather/stanza/presence/status.rb +1 -0
- data/lib/blather/stanza/pubsub/event.rb +2 -4
- data/lib/blather/stanza/pubsub/subscription.rb +1 -0
- data/lib/blather/stanza/x.rb +8 -0
- data/lib/blather/stream.rb +2 -0
- data/lib/blather/stream/client.rb +1 -0
- data/lib/blather/stream/component.rb +1 -0
- data/lib/blather/stream/features.rb +4 -3
- data/lib/blather/stream/features/resource.rb +4 -3
- data/lib/blather/stream/features/sasl.rb +9 -6
- data/lib/blather/stream/features/session.rb +5 -4
- data/lib/blather/stream/features/tls.rb +4 -3
- data/lib/blather/stream/parser.rb +4 -5
- data/lib/blather/version.rb +2 -1
- data/lib/blather/xmpp_node.rb +9 -0
- data/spec/blather/client/client_spec.rb +14 -1
- data/spec/blather/stanza/iq_spec.rb +16 -0
- data/spec/blather/stanza/presence_spec.rb +1 -1
- data/spec/blather/stanza_spec.rb +18 -0
- data/spec/blather/stream/client_spec.rb +2 -2
- metadata +52 -35
- data/lib/blather/core_ext/active_support.rb +0 -45
- data/lib/blather/core_ext/active_support/inheritable_attributes.rb +0 -117
@@ -1,117 +0,0 @@
|
|
1
|
-
# Thanks to Rails ActiveSupport for everything in this file
|
2
|
-
|
3
|
-
# Allows attributes to be shared within an inheritance hierarchy, but where each descendant gets a copy of
|
4
|
-
# their parents' attributes, instead of just a pointer to the same. This means that the child can add elements
|
5
|
-
# to, for example, an array without those additions being shared with either their parent, siblings, or
|
6
|
-
# children, which is unlike the regular class-level attributes that are shared across the entire hierarchy.
|
7
|
-
class Class # @private
|
8
|
-
def class_inheritable_reader(*syms)
|
9
|
-
syms.each do |sym|
|
10
|
-
next if sym.is_a?(Hash)
|
11
|
-
class_eval <<-EOS
|
12
|
-
def self.#{sym}
|
13
|
-
read_inheritable_attribute(:#{sym})
|
14
|
-
end
|
15
|
-
|
16
|
-
def #{sym}
|
17
|
-
self.class.#{sym}
|
18
|
-
end
|
19
|
-
EOS
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def class_inheritable_writer(*syms)
|
24
|
-
syms.each do |sym|
|
25
|
-
class_eval <<-EOS
|
26
|
-
def self.#{sym}=(obj)
|
27
|
-
write_inheritable_attribute(:#{sym}, obj)
|
28
|
-
end
|
29
|
-
EOS
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def class_inheritable_array_writer(*syms)
|
34
|
-
syms.each do |sym|
|
35
|
-
class_eval <<-EOS
|
36
|
-
def self.#{sym}=(obj)
|
37
|
-
write_inheritable_array(:#{sym}, obj)
|
38
|
-
end
|
39
|
-
EOS
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def class_inheritable_hash_writer(*syms)
|
44
|
-
syms.each do |sym|
|
45
|
-
class_eval <<-EOS
|
46
|
-
def self.#{sym}=(obj)
|
47
|
-
write_inheritable_hash(:#{sym}, obj)
|
48
|
-
end
|
49
|
-
EOS
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def class_inheritable_accessor(*syms)
|
54
|
-
class_inheritable_reader(*syms)
|
55
|
-
class_inheritable_writer(*syms)
|
56
|
-
end
|
57
|
-
|
58
|
-
def class_inheritable_array(*syms)
|
59
|
-
class_inheritable_reader(*syms)
|
60
|
-
class_inheritable_array_writer(*syms)
|
61
|
-
end
|
62
|
-
|
63
|
-
def class_inheritable_hash(*syms)
|
64
|
-
class_inheritable_reader(*syms)
|
65
|
-
class_inheritable_hash_writer(*syms)
|
66
|
-
end
|
67
|
-
|
68
|
-
def inheritable_attributes
|
69
|
-
@inheritable_attributes ||= EMPTY_INHERITABLE_ATTRIBUTES
|
70
|
-
end
|
71
|
-
|
72
|
-
def write_inheritable_attribute(key, value)
|
73
|
-
if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
|
74
|
-
@inheritable_attributes = {}
|
75
|
-
end
|
76
|
-
inheritable_attributes[key] = value
|
77
|
-
end
|
78
|
-
|
79
|
-
def write_inheritable_array(key, elements)
|
80
|
-
write_inheritable_attribute(key, []) if read_inheritable_attribute(key).nil?
|
81
|
-
write_inheritable_attribute(key, read_inheritable_attribute(key) + elements)
|
82
|
-
end
|
83
|
-
|
84
|
-
def write_inheritable_hash(key, hash)
|
85
|
-
write_inheritable_attribute(key, {}) if read_inheritable_attribute(key).nil?
|
86
|
-
write_inheritable_attribute(key, read_inheritable_attribute(key).merge(hash))
|
87
|
-
end
|
88
|
-
|
89
|
-
def read_inheritable_attribute(key)
|
90
|
-
inheritable_attributes[key]
|
91
|
-
end
|
92
|
-
|
93
|
-
def reset_inheritable_attributes
|
94
|
-
@inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
|
95
|
-
end
|
96
|
-
|
97
|
-
private
|
98
|
-
# Prevent this constant from being created multiple times
|
99
|
-
EMPTY_INHERITABLE_ATTRIBUTES = {}.freeze unless const_defined?(:EMPTY_INHERITABLE_ATTRIBUTES)
|
100
|
-
|
101
|
-
def inherited_with_inheritable_attributes(child)
|
102
|
-
inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes)
|
103
|
-
|
104
|
-
if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
|
105
|
-
new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
|
106
|
-
else
|
107
|
-
new_inheritable_attributes = inheritable_attributes.inject({}) do |memo, (key, value)|
|
108
|
-
memo.update(key => value.duplicable? ? value.dup : value)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes)
|
113
|
-
end
|
114
|
-
|
115
|
-
alias inherited_without_inheritable_attributes inherited
|
116
|
-
alias inherited inherited_with_inheritable_attributes
|
117
|
-
end # Class
|