camper_van 0.0.4 → 0.0.5
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/Gemfile.lock +1 -1
- data/lib/camper_van/channel.rb +7 -4
- data/lib/camper_van/ircd.rb +6 -1
- data/lib/camper_van/version.rb +1 -1
- data/spec/camper_van/channel_spec.rb +13 -4
- metadata +5 -2
data/Gemfile.lock
CHANGED
data/lib/camper_van/channel.rb
CHANGED
@@ -86,6 +86,7 @@ module CamperVan
|
|
86
86
|
# connections: allowing them to time out rather than leaving explicitly.
|
87
87
|
def part
|
88
88
|
client.user_reply :part, channel
|
89
|
+
# FIXME this doesn't work. Not even on next_tick. EM/em-http-request bug?
|
89
90
|
stream.close_connection if stream
|
90
91
|
# room.leave # let the timeout do it rather than being explicit!
|
91
92
|
end
|
@@ -242,8 +243,10 @@ module CamperVan
|
|
242
243
|
|
243
244
|
# Stream messages from campfire and map them to IRC commands for the
|
244
245
|
# connected client.
|
246
|
+
#
|
247
|
+
# Only starts the stream once.
|
245
248
|
def stream_campfire_to_channel
|
246
|
-
@stream
|
249
|
+
@stream ||= room.stream do |message|
|
247
250
|
map_message_to_irc message
|
248
251
|
end
|
249
252
|
end
|
@@ -309,11 +312,11 @@ module CamperVan
|
|
309
312
|
lines = message.body.split("\n")
|
310
313
|
|
311
314
|
lines[0..2].each do |line|
|
312
|
-
client.campfire_reply :privmsg, name, channel, "
|
315
|
+
client.campfire_reply :privmsg, name, channel, ":> " + line
|
313
316
|
end
|
314
317
|
|
315
318
|
if lines.size > 3
|
316
|
-
client.campfire_reply :privmsg, name, channel, "
|
319
|
+
client.campfire_reply :privmsg, name, channel, ":> more: " +
|
317
320
|
"https://#{client.subdomain}.campfirenow.com/room/#{room.id}/paste/#{message.id}"
|
318
321
|
end
|
319
322
|
|
@@ -349,7 +352,7 @@ module CamperVan
|
|
349
352
|
else
|
350
353
|
body = message.body
|
351
354
|
end
|
352
|
-
client.campfire_reply :privmsg, name, channel, body
|
355
|
+
client.campfire_reply :privmsg, name, channel, ":" + body
|
353
356
|
end
|
354
357
|
|
355
358
|
when "TopicChange"
|
data/lib/camper_van/ircd.rb
CHANGED
@@ -187,6 +187,11 @@ module CamperVan
|
|
187
187
|
|
188
188
|
handle :part do |args|
|
189
189
|
name = args.first
|
190
|
+
# FIXME parting a channel should remove the channel from channels, except
|
191
|
+
# that there's a bug with EM that won't disconnect the streaming request.
|
192
|
+
# Because of that, leave the channel in the list, and assume the irc
|
193
|
+
# client attached to this IRCD will ignore messages from channels it's not
|
194
|
+
# currently in.
|
190
195
|
if channel = channels[name]
|
191
196
|
channel.part
|
192
197
|
else
|
@@ -326,7 +331,7 @@ module CamperVan
|
|
326
331
|
def join_channel(name)
|
327
332
|
campfire.rooms do |rooms|
|
328
333
|
if room = rooms.detect { |r| "#" + irc_name(r.name) == name }
|
329
|
-
channel = Channel.new(name, self, room)
|
334
|
+
channel = channels[name] || Channel.new(name, self, room)
|
330
335
|
if channel.join
|
331
336
|
channels[name] = channel
|
332
337
|
end
|
data/lib/camper_van/version.rb
CHANGED
@@ -21,6 +21,7 @@ describe CamperVan::Channel do
|
|
21
21
|
class TestRoom
|
22
22
|
attr_reader :locked, :full, :topic, :membership_limit
|
23
23
|
attr_reader :sent
|
24
|
+
attr_reader :stream_count
|
24
25
|
|
25
26
|
attr_writer :users, :topic, :locked, :full, :open_to_guests
|
26
27
|
attr_writer :stream
|
@@ -29,6 +30,7 @@ describe CamperVan::Channel do
|
|
29
30
|
@users = []
|
30
31
|
@sent = []
|
31
32
|
@membership_limit = 12
|
33
|
+
@stream_count = 0
|
32
34
|
end
|
33
35
|
|
34
36
|
def id
|
@@ -62,10 +64,11 @@ describe CamperVan::Channel do
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def stream
|
67
|
+
@stream_count += 1
|
65
68
|
if @messages
|
66
69
|
@messages.each { |m| yield m }
|
67
70
|
end
|
68
|
-
|
71
|
+
@stream ||= "message stream" # must be truthy
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
@@ -106,6 +109,12 @@ describe CamperVan::Channel do
|
|
106
109
|
@channel.join
|
107
110
|
@client.sent[2].must_equal ":camper_van 353 nathan = #test :nathan bob joe"
|
108
111
|
end
|
112
|
+
|
113
|
+
it "does not stream messages from the room on a second join" do
|
114
|
+
@channel.join
|
115
|
+
@channel.join
|
116
|
+
@room.stream_count.must_equal 1
|
117
|
+
end
|
109
118
|
end
|
110
119
|
|
111
120
|
describe "#part" do
|
@@ -311,8 +320,8 @@ describe CamperVan::Channel do
|
|
311
320
|
end
|
312
321
|
|
313
322
|
it "sends a privmsg with the message when a user says something" do
|
314
|
-
@channel.map_message_to_irc msg("Text", :body => "hello")
|
315
|
-
@client.sent.last.must_match ":joe!joe@campfire PRIVMSG #test hello"
|
323
|
+
@channel.map_message_to_irc msg("Text", :body => "hello there")
|
324
|
+
@client.sent.last.must_match ":joe!joe@campfire PRIVMSG #test :hello there"
|
316
325
|
end
|
317
326
|
|
318
327
|
it "sends a privmsg with the pasted url and the first line when a user pastes something" do
|
@@ -346,7 +355,7 @@ describe CamperVan::Channel do
|
|
346
355
|
]
|
347
356
|
@channel.list_users
|
348
357
|
@channel.map_message_to_irc msg("Text", :body => "Bob Fred")
|
349
|
-
@client.sent.last.must_match %r(PRIVMSG #test bob_fred)
|
358
|
+
@client.sent.last.must_match %r(PRIVMSG #test :bob_fred)
|
350
359
|
end
|
351
360
|
|
352
361
|
it "converts leading names plus punctuation to nicks" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camper_van
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -148,6 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
- - ! '>='
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
hash: 4196066118135228285
|
151
154
|
requirements: []
|
152
155
|
rubyforge_project: camper_van
|
153
156
|
rubygems_version: 1.8.24
|