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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32b68c933f40664fb0b884507a542b4d10914e91
4
- data.tar.gz: e7e1821584741db70d7040deeadd2017f15bc1f3
3
+ metadata.gz: 793eaf957a7ea614c7f4ee1f12c1f4abe171274e
4
+ data.tar.gz: 39dbc95b03ebe95e8985aafa7fcdb206fa2929f8
5
5
  SHA512:
6
- metadata.gz: 4a1ddf66fe30a97596f9bf9f83fcde3909e69aeb3fb05480e21781eb0207af4c811ef345c8768b7b1d9ff1da8e05a8b88d963f3fea7475d34e8bc559fe729bc8
7
- data.tar.gz: 9f138ddc9b654c4e9f7188ace388920413fceefa08461ec959cf76f055b096027139ebdd41677d7b4c3f28895fedd1833207eb655da45309aec20e2a619cb8d1
6
+ metadata.gz: 7aa7b7c3f0783108b296a7b3fd0d36d9baf3d1b10dbaf206a5e3b8f7db5a09e0d839170bfdca9c65a1cf326bfabe6dc17c0bcd12c833bedfdbe4ed0038b51964
7
+ data.tar.gz: 4b5cf980549c77d98bb91417242c2ee8f3198f35d3537d213b4b21ca166d6905801ae2f686f6e92bf4edf41036cfb9e77f756f86fc407b867853c642c0f1d9a2
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
5
6
  - rbx-19mode
6
7
  - jruby-19mode
7
8
  - ruby-head
@@ -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
@@ -3,7 +3,7 @@ require 'ruby_fs/response'
3
3
  module RubyFS
4
4
  class Event < Response
5
5
  #
6
- # @return [String[ The name of the event
6
+ # @return [String] The name of the event
7
7
  def event_name
8
8
  content[:event_name]
9
9
  end
@@ -1,8 +1,7 @@
1
1
  module RubyFS
2
2
  class Lexer
3
3
  ContentLengthPattern = /Content-length:\s*(\d+)/i
4
- MaxLineLength = 16 * 1024
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 /\A([^\s:]+)\s*:\s*/ =~ h
139
+ if HeaderFormatPattern =~ h
141
140
  tail = $'.dup
142
- hash[$1.downcase.gsub(/-/, "_").intern] = tail
141
+ hash[$1.downcase.gsub('-', "_").intern] = tail
143
142
  end
144
143
  end
145
144
  end
@@ -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 ALL" if @events
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(/-/,"_").intern] = v
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
@@ -1,3 +1,3 @@
1
1
  module RubyFS
2
- VERSION = "1.0.5"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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.5
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-03-23 00:00:00.000000000 Z
11
+ date: 2013-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid-io