uv-rays 1.3.5 → 1.3.6
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 +14 -32
- data/lib/uv-rays/version.rb +1 -1
- data/spec/abstract_tokenizer_spec.rb +11 -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: 4455f4c45f8835bff0c2dd2f0213d229d7d5a567
|
4
|
+
data.tar.gz: 9b575ec7380f6e3c525caa0f752327babb930a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65317d8a548b648e7ef33ffa2437116dcdcbe0407ab3317ec925ad2a48bba484c1dcdd35e56f5c893108ade3b671f92a68e60f4b86d9bd4d55a705425b237f25
|
7
|
+
data.tar.gz: cc6e8a3abf8c5aede9cf23aab253590d0c14a8a19f9672a787090853766f9bdd66527fb56c66272cc4935a14a99682a5600e137a588271e1082eb2714af86a87
|
@@ -39,47 +39,30 @@ module UV
|
|
39
39
|
data.force_encoding(@encoding)
|
40
40
|
@input << data
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
result = @callback.call(msg)
|
50
|
-
entities << msg[0...result] if result
|
51
|
-
end
|
42
|
+
entities = []
|
43
|
+
|
44
|
+
loop do
|
45
|
+
found = false
|
46
|
+
|
47
|
+
check = @input.partition(@indicator)
|
48
|
+
break unless check[1].length > 0
|
52
49
|
|
53
|
-
|
50
|
+
last = check[2]
|
54
51
|
result = @callback.call(last)
|
55
52
|
if result
|
53
|
+
found = true
|
54
|
+
|
56
55
|
# Check for multi-byte indicator edge case
|
57
56
|
if result.is_a? Fixnum
|
58
57
|
entities << last[0...result]
|
59
58
|
@input = last[result..-1]
|
60
59
|
else
|
61
|
-
reset
|
62
60
|
entities << last
|
61
|
+
reset
|
63
62
|
end
|
64
|
-
else
|
65
|
-
# This will work with a regex
|
66
|
-
index = if messages.last.nil?
|
67
|
-
0
|
68
|
-
else
|
69
|
-
# Possible that rindex will not find a match
|
70
|
-
check = @input[0...-last.length].rindex(messages.last)
|
71
|
-
if check.nil?
|
72
|
-
0
|
73
|
-
else
|
74
|
-
check + messages.last.length
|
75
|
-
end
|
76
|
-
end
|
77
|
-
indicator_val = @input[index...-last.length]
|
78
|
-
@input = indicator_val + last
|
79
63
|
end
|
80
|
-
|
81
|
-
|
82
|
-
entities = messages
|
64
|
+
|
65
|
+
break if not found
|
83
66
|
end
|
84
67
|
|
85
68
|
# Check to see if the buffer has exceeded capacity, if we're imposing a limit
|
@@ -118,8 +101,7 @@ module UV
|
|
118
101
|
|
119
102
|
|
120
103
|
def reset
|
121
|
-
@input = ''
|
122
|
-
@input.force_encoding(@encoding)
|
104
|
+
@input = ''.force_encoding(@encoding)
|
123
105
|
end
|
124
106
|
end
|
125
107
|
end
|
data/lib/uv-rays/version.rb
CHANGED
@@ -93,4 +93,15 @@ describe UV::AbstractTokenizer do
|
|
93
93
|
result = @buffer.extract('bcd')
|
94
94
|
expect(result).to eq(['abcd'])
|
95
95
|
end
|
96
|
+
|
97
|
+
it "should work where the indicator is part of the message" do
|
98
|
+
# i.e. We are looking for \x02\x06\xLEN\x00\x00\x02\x06\x00\xEND
|
99
|
+
# Where the indicator may appear as part of the message body
|
100
|
+
|
101
|
+
msg1 = "StartStartStart123456"
|
102
|
+
|
103
|
+
result = @buffer.extract(msg1)
|
104
|
+
expect(result).to eq(['Star', '1234'])
|
105
|
+
expect(@buffer.flush).to eq('56') # as we've indicated a message length of 4
|
106
|
+
end
|
96
107
|
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: 1.3.
|
4
|
+
version: 1.3.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: 2016-06-
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libuv
|