uv-rays 2.0.1 → 2.0.2
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.
- checksums.yaml +4 -4
- data/lib/uv-rays/abstract_tokenizer.rb +11 -5
- data/lib/uv-rays/version.rb +1 -1
- data/spec/abstract_tokenizer_spec.rb +22 -0
- 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: 83d541d90fa45a28696168870b4c5933354ba968
|
4
|
+
data.tar.gz: 29b0fe26514eb737aa11b912e3549eb509a789b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 049c4c400a002bfa9c1829b1be76c7db3b77d6b7f1052b6327a0c0deab667b2cd654220bb440039af1c580ffde5e72cf79da7a4462e0099c50cbf02baa9c31b2
|
7
|
+
data.tar.gz: 0f13601f2a8e5f3892bd5632a234478bb12f6b3d368531c4512417fcdd5e5532c0ba315396ecc6ff29783e9723b1ddc29cd2e15314fb9ca43444035cb74ae0a8
|
@@ -19,7 +19,6 @@ module UV
|
|
19
19
|
@verbose = options[:verbose] if @size_limit
|
20
20
|
@encoding = options[:encoding] || DEFAULT_ENCODING
|
21
21
|
|
22
|
-
raise ArgumentError, 'no indicator provided' unless @indicator
|
23
22
|
raise ArgumentError, 'no callback provided' unless @callback
|
24
23
|
|
25
24
|
reset
|
@@ -46,16 +45,23 @@ module UV
|
|
46
45
|
loop do
|
47
46
|
found = false
|
48
47
|
|
49
|
-
|
50
|
-
|
48
|
+
last = if @indicator
|
49
|
+
check = @input.partition(@indicator)
|
50
|
+
break unless check[1].length > 0
|
51
|
+
|
52
|
+
check[2]
|
53
|
+
else
|
54
|
+
@input
|
55
|
+
end
|
51
56
|
|
52
|
-
last = check[2]
|
53
57
|
result = @callback.call(last)
|
58
|
+
|
54
59
|
if result
|
55
60
|
found = true
|
56
61
|
|
57
62
|
# Check for multi-byte indicator edge case
|
58
|
-
|
63
|
+
case result
|
64
|
+
when Integer, Fixnum
|
59
65
|
entities << last[0...result]
|
60
66
|
@input = last[result..-1]
|
61
67
|
else
|
data/lib/uv-rays/version.rb
CHANGED
@@ -104,4 +104,26 @@ describe UV::AbstractTokenizer do
|
|
104
104
|
expect(result).to eq(['Star', '1234'])
|
105
105
|
expect(@buffer.flush).to eq('56') # as we've indicated a message length of 4
|
106
106
|
end
|
107
|
+
|
108
|
+
it "should work with messages that don't have an indicator" do
|
109
|
+
# i.e. there is a header that defines message length
|
110
|
+
msg1 = "\x0612345\x081234567\x031"
|
111
|
+
|
112
|
+
@buffer = UV::AbstractTokenizer.new({
|
113
|
+
callback: lambda { |data|
|
114
|
+
len = data.bytes[0]
|
115
|
+
if data.length >= len
|
116
|
+
len
|
117
|
+
else
|
118
|
+
false
|
119
|
+
end
|
120
|
+
},
|
121
|
+
size_limit: 10,
|
122
|
+
encoding: "ASCII-8BIT"
|
123
|
+
})
|
124
|
+
|
125
|
+
result = @buffer.extract(msg1)
|
126
|
+
expect(result).to eq(["\x0612345", "\x081234567"])
|
127
|
+
expect(@buffer.flush).to eq("\x031") # as we've indicated a message length of 3
|
128
|
+
end
|
107
129
|
end
|
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: 2.0.
|
4
|
+
version: 2.0.2
|
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:
|
11
|
+
date: 2017-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libuv
|