xrc 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/xrc.rb +1 -0
- data/lib/xrc/client.rb +19 -7
- data/lib/xrc/message_builder.rb +6 -0
- data/lib/xrc/messages/invite.rb +9 -0
- data/lib/xrc/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09c52dabd4cb36ef0aa8f4fe0a47e58513bde212
|
4
|
+
data.tar.gz: e7de2dc52efff5426ac88f1e1250cf3d54f1e7b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e6a674ed0dc77b987a883d9e8b7f6064b0dc6d786d96813a163c676d058f03b1952823ab136dc90cb40aec841d7610578e5589177c067f872afe6bb27af615f
|
7
|
+
data.tar.gz: 5dd6a07664227ca0e391a6f0ee2cb424aba0e4d36f9facee7f9fdbfcaf2853c21629cae5cd4032860f961e98195e939f726d6acb597ceb50fa13c0de8e045577
|
data/CHANGELOG.md
CHANGED
data/lib/xrc.rb
CHANGED
@@ -30,6 +30,7 @@ require "xrc/elements/stream"
|
|
30
30
|
require "xrc/hosts_resolver"
|
31
31
|
require "xrc/message_builder"
|
32
32
|
require "xrc/messages/base"
|
33
|
+
require "xrc/messages/invite"
|
33
34
|
require "xrc/messages/null"
|
34
35
|
require "xrc/messages/message"
|
35
36
|
require "xrc/messages/private_message"
|
data/lib/xrc/client.rb
CHANGED
@@ -77,6 +77,12 @@ module Xrc
|
|
77
77
|
@on_event_block = block
|
78
78
|
end
|
79
79
|
|
80
|
+
# Registers a callback for invitation message
|
81
|
+
# @return [Proc] Returns given block
|
82
|
+
def on_invite(&block)
|
83
|
+
@on_invite_block = block
|
84
|
+
end
|
85
|
+
|
80
86
|
# Replies to given message
|
81
87
|
# @option options [Xrc::Messages::Base] :to A message object given from server
|
82
88
|
# @option options [String] :body A text to be sent to server
|
@@ -116,6 +122,12 @@ module Xrc
|
|
116
122
|
users[jid].try(:mention_name)
|
117
123
|
end
|
118
124
|
|
125
|
+
def join(jids)
|
126
|
+
Array(jids).each do |room_jid|
|
127
|
+
post(Elements::Join.new(from: jid.strip, to: "#{room_jid}/#{nickname}"))
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
119
131
|
private
|
120
132
|
|
121
133
|
def on_event_block
|
@@ -134,6 +146,10 @@ module Xrc
|
|
134
146
|
@on_subject_block ||= ->(element) {}
|
135
147
|
end
|
136
148
|
|
149
|
+
def on_invite_block
|
150
|
+
@on_invite_block ||= ->(element) {}
|
151
|
+
end
|
152
|
+
|
137
153
|
def on_received(element)
|
138
154
|
on_event_block.call(element)
|
139
155
|
case
|
@@ -191,6 +207,8 @@ module Xrc
|
|
191
207
|
on_private_message_block.call(message)
|
192
208
|
when Messages::Subject
|
193
209
|
on_subject_block.call(message)
|
210
|
+
when Messages::Invite
|
211
|
+
on_invite_block.call(message)
|
194
212
|
end
|
195
213
|
end
|
196
214
|
|
@@ -248,7 +266,7 @@ module Xrc
|
|
248
266
|
end
|
249
267
|
|
250
268
|
def on_connection_established
|
251
|
-
join
|
269
|
+
join(room_jids)
|
252
270
|
start_ping_thread
|
253
271
|
end
|
254
272
|
|
@@ -299,12 +317,6 @@ module Xrc
|
|
299
317
|
post(Elements::Presence.new)
|
300
318
|
end
|
301
319
|
|
302
|
-
def join
|
303
|
-
room_jids.each do |room_jid|
|
304
|
-
post(Elements::Join.new(from: jid.strip, to: "#{room_jid}/#{nickname}"))
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
320
|
def ping
|
309
321
|
post(Elements::Ping.new(from: jid.to_s, to: jid.domain))
|
310
322
|
end
|
data/lib/xrc/message_builder.rb
CHANGED
@@ -26,6 +26,8 @@ module Xrc
|
|
26
26
|
Messages::PrivateMessage
|
27
27
|
when has_subject?
|
28
28
|
Messages::Subject
|
29
|
+
when has_invite?
|
30
|
+
Messages::Invite
|
29
31
|
else
|
30
32
|
Messages::Null
|
31
33
|
end
|
@@ -55,6 +57,10 @@ module Xrc
|
|
55
57
|
!!@element.elements["subject"]
|
56
58
|
end
|
57
59
|
|
60
|
+
def has_invite?
|
61
|
+
!!@element.elements["x/invite"]
|
62
|
+
end
|
63
|
+
|
58
64
|
def type
|
59
65
|
@element.attributes["type"].to_s
|
60
66
|
end
|
data/lib/xrc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xrc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/xrc/jid.rb
|
113
113
|
- lib/xrc/message_builder.rb
|
114
114
|
- lib/xrc/messages/base.rb
|
115
|
+
- lib/xrc/messages/invite.rb
|
115
116
|
- lib/xrc/messages/message.rb
|
116
117
|
- lib/xrc/messages/null.rb
|
117
118
|
- lib/xrc/messages/private_message.rb
|