uv-rays 1.0.5 → 1.0.6

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: 144879cc69e227ca059cecbd2b4abf92d6fd0284
4
- data.tar.gz: e57957308a1ba65488d48e8c451794161af23476
3
+ metadata.gz: 7b968faec5c418f8ee37b41606159333d3f0458f
4
+ data.tar.gz: d0ba56974349746c9db68e4b52abdf26bc60803c
5
5
  SHA512:
6
- metadata.gz: 518a38b3f152899f36af5cd9488ffd1cd6ec7f983ca01cb8e909e8f831de9a7ee049fe8dbffe6e9b6bf2d2366e34907fb2ff5dd3f945b55de63a5ec6319510c7
7
- data.tar.gz: 21751e286a6a2aa6e9dbd873c1712611dff769a52778fadaeb6d1b88600682c6be8d243f6995c64ae960578356cdc20b9a36e3b432704cf6bff59a0f8d2a4bae
6
+ metadata.gz: 2eb3efe38bb16b15ee9b90fbe049c40b09effecdcdd142eb309a90fb07ddbf287d3cfe090668b141aad692f595f568d913e03a2d656ccfea78f7d931b14adadf
7
+ data.tar.gz: ff93f781f3e477cdaa01040ce49c150555254366a5b344a15152e9e5b8825354cb6a29aac5d1b01733060b2cc1adcc4652485de00ca756ff94ad724d86f529d8
@@ -47,7 +47,8 @@ module UV
47
47
 
48
48
  entities = []
49
49
  messages.each do |msg|
50
- entities << msg if @callback.call(msg)
50
+ result = @callback.call(msg)
51
+ entities << msg[0...result] if result
51
52
  end
52
53
 
53
54
  # Check if buffering is required
@@ -31,7 +31,6 @@ module UV
31
31
  if @delimiter
32
32
  @extract_method = method(:delimiter_extract)
33
33
  elsif @indicator && @msg_length
34
- @length_index = @msg_length - 1
35
34
  @extract_method = method(:length_extract)
36
35
  else
37
36
  raise ArgumentError, 'no delimiter provided'
@@ -112,13 +111,13 @@ module UV
112
111
 
113
112
  # Select messages of the right size then remove junk data
114
113
  messages.select! { |msg| msg.length >= @msg_length ? true : false }
115
- messages.map! { |msg| msg[0..@length_index] }
114
+ messages.map! { |msg| msg[0...@msg_length] }
116
115
 
117
116
  if last.length >= @msg_length
118
- messages << last[0..@length_index]
117
+ messages << last[0...@msg_length]
119
118
  @input = last[@msg_length..-1]
120
119
  else
121
- @input = "#{@indicator}#{last}"
120
+ reset("#{@indicator}#{last}")
122
121
  end
123
122
 
124
123
  check_buffer_limits
@@ -151,8 +150,8 @@ module UV
151
150
  end
152
151
  end
153
152
 
154
- def reset
155
- @input = ''
153
+ def reset(value = '')
154
+ @input = value
156
155
  @input.force_encoding(@encoding) if @encoding
157
156
  end
158
157
  end
@@ -1,3 +1,3 @@
1
1
  module UV
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
@@ -41,6 +41,14 @@ describe UV::AbstractTokenizer do
41
41
  expect(result).to eq(['1234', '1234'])
42
42
  expect(@buffer.flush).to eq('56') # as we've indicated a message length of 4
43
43
  end
44
+
45
+ it "should not return junk data" do
46
+ msg1 = "Start123456Start123456"
47
+
48
+ result = @buffer.extract(msg1)
49
+ expect(result).to eq(['1234', '1234'])
50
+ expect(@buffer.flush).to eq('56') # as we've indicated a message length of 4
51
+ end
44
52
 
45
53
  it "should tokenize messages where the indicator is split" do
46
54
  msg1 = "123Star"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uv-rays
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libuv