ruby_fs 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/lib/ruby_fs/event.rb +1 -1
- data/lib/ruby_fs/lexer.rb +3 -4
- data/lib/ruby_fs/stream.rb +8 -2
- data/lib/ruby_fs/version.rb +1 -1
- data/spec/ruby_fs/stream_spec.rb +63 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 793eaf957a7ea614c7f4ee1f12c1f4abe171274e
|
4
|
+
data.tar.gz: 39dbc95b03ebe95e8985aafa7fcdb206fa2929f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aa7b7c3f0783108b296a7b3fd0d36d9baf3d1b10dbaf206a5e3b8f7db5a09e0d839170bfdca9c65a1cf326bfabe6dc17c0bcd12c833bedfdbe4ed0038b51964
|
7
|
+
data.tar.gz: 4b5cf980549c77d98bb91417242c2ee8f3198f35d3537d213b4b21ca166d6905801ae2f686f6e92bf4edf41036cfb9e77f756f86fc407b867853c642c0f1d9a2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# develop
|
2
2
|
|
3
|
+
# 1.1.0
|
4
|
+
* Feature: Allow specifying an event mask (other than 'ALL') when connecting
|
5
|
+
* CS: Minor performance improvements from removing repeated regex compilation
|
6
|
+
|
3
7
|
# 1.0.5
|
4
8
|
* Bugfix: Allow sending large app arguments. Application arguments (headers in general) are limited to 2048 bytes. The work-around is to send them in the body of the message with a content-length header.
|
5
9
|
* CS: Avoid Celluloid deprecation warnings
|
data/lib/ruby_fs/event.rb
CHANGED
data/lib/ruby_fs/lexer.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module RubyFS
|
2
2
|
class Lexer
|
3
3
|
ContentLengthPattern = /Content-length:\s*(\d+)/i
|
4
|
-
|
5
|
-
MaxBinaryLength = 32 * 1024 * 1024
|
4
|
+
HeaderFormatPattern = /\A([^\s:]+)\s*:\s*/
|
6
5
|
|
7
6
|
def initialize(callback)
|
8
7
|
@callback = callback
|
@@ -137,9 +136,9 @@ module RubyFS
|
|
137
136
|
def headers_2_hash(headers)
|
138
137
|
{}.tap do |hash|
|
139
138
|
headers.each do |h|
|
140
|
-
if
|
139
|
+
if HeaderFormatPattern =~ h
|
141
140
|
tail = $'.dup
|
142
|
-
hash[$1.downcase.gsub(
|
141
|
+
hash[$1.downcase.gsub('-', "_").intern] = tail
|
143
142
|
end
|
144
143
|
end
|
145
144
|
end
|
data/lib/ruby_fs/stream.rb
CHANGED
@@ -168,7 +168,7 @@ module RubyFS
|
|
168
168
|
@command_callbacks.pop.call CommandReply.new(headers, (content == '' ? nil : content))
|
169
169
|
when 'auth/request'
|
170
170
|
command "auth #{@secret}" do
|
171
|
-
async.command "event json
|
171
|
+
async.command "event json #{event_mask}" if @events
|
172
172
|
end
|
173
173
|
when 'text/disconnect-notice'
|
174
174
|
terminate
|
@@ -181,7 +181,7 @@ module RubyFS
|
|
181
181
|
json = JSON.parse content
|
182
182
|
{}.tap do |hash|
|
183
183
|
json.each_pair do |k, v|
|
184
|
-
hash[k.downcase.gsub(
|
184
|
+
hash[k.downcase.gsub('-',"_").intern] = v
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
@@ -190,5 +190,11 @@ module RubyFS
|
|
190
190
|
@state = :started
|
191
191
|
fire_event Connected.new
|
192
192
|
end
|
193
|
+
|
194
|
+
def event_mask
|
195
|
+
return 'ALL' if @events == true
|
196
|
+
|
197
|
+
Array(@events).join(' ')
|
198
|
+
end
|
193
199
|
end
|
194
200
|
end
|
data/lib/ruby_fs/version.rb
CHANGED
data/spec/ruby_fs/stream_spec.rb
CHANGED
@@ -301,7 +301,7 @@ Reply-Text: +OK accepted
|
|
301
301
|
end
|
302
302
|
|
303
303
|
context 'with events turned off' do
|
304
|
-
it 'does not the event mask after authenticating' do
|
304
|
+
it 'does not set the event mask after authenticating' do
|
305
305
|
mocked_server(1, lambda { |server| server.send_data "Content-Type: auth/request\n\n" }) do |val, server|
|
306
306
|
val.should == "auth ClueCon\n\n"
|
307
307
|
server.send_data %Q(
|
@@ -318,6 +318,68 @@ Reply-Text: +OK accepted
|
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
+
context 'with an event mask fully specified as a string' do
|
322
|
+
let(:events) { 'CODEC CHANNEL_STATE' }
|
323
|
+
|
324
|
+
it 'sets the event mask after authenticating' do
|
325
|
+
mocked_server(2, lambda { |server| server.send_data "Content-Type: auth/request\n\n" }) do |val, server|
|
326
|
+
case @sequence
|
327
|
+
when 1
|
328
|
+
val.should == "auth ClueCon\n\n"
|
329
|
+
server.send_data %Q(
|
330
|
+
Content-Type: command/reply
|
331
|
+
Reply-Text: +OK accepted
|
332
|
+
|
333
|
+
)
|
334
|
+
when 2
|
335
|
+
val.should == "event json CODEC CHANNEL_STATE\n\n"
|
336
|
+
server.send_data %Q(
|
337
|
+
Content-Type: command/reply
|
338
|
+
Reply-Text: +OK accepted
|
339
|
+
|
340
|
+
)
|
341
|
+
end
|
342
|
+
@sequence += 1
|
343
|
+
end
|
344
|
+
|
345
|
+
client_messages.should be == [
|
346
|
+
Stream::Connected.new,
|
347
|
+
Stream::Disconnected.new
|
348
|
+
]
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
context 'with an event mask fully specified as an array' do
|
353
|
+
let(:events) { ['CODEC', 'CHANNEL_STATE'] }
|
354
|
+
|
355
|
+
it 'sets the event mask after authenticating' do
|
356
|
+
mocked_server(2, lambda { |server| server.send_data "Content-Type: auth/request\n\n" }) do |val, server|
|
357
|
+
case @sequence
|
358
|
+
when 1
|
359
|
+
val.should == "auth ClueCon\n\n"
|
360
|
+
server.send_data %Q(
|
361
|
+
Content-Type: command/reply
|
362
|
+
Reply-Text: +OK accepted
|
363
|
+
|
364
|
+
)
|
365
|
+
when 2
|
366
|
+
val.should == "event json CODEC CHANNEL_STATE\n\n"
|
367
|
+
server.send_data %Q(
|
368
|
+
Content-Type: command/reply
|
369
|
+
Reply-Text: +OK accepted
|
370
|
+
|
371
|
+
)
|
372
|
+
end
|
373
|
+
@sequence += 1
|
374
|
+
end
|
375
|
+
|
376
|
+
client_messages.should be == [
|
377
|
+
Stream::Connected.new,
|
378
|
+
Stream::Disconnected.new
|
379
|
+
]
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
321
383
|
context 'when receiving a disconnect notice' do
|
322
384
|
it 'puts itself in the stopped state and fires a disconnected event' do
|
323
385
|
expect_connected_event
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Langfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid-io
|