uv-rays 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uv-rays/abstract_tokenizer.rb +18 -3
- data/lib/uv-rays/buffered_tokenizer.rb +18 -2
- data/lib/uv-rays/version.rb +1 -1
- data/spec/abstract_tokenizer_spec.rb +2 -1
- data/spec/buffered_tokenizer_spec.rb +2 -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: d9129069a6f55b2da01da10a313ac480c64f82b0
|
4
|
+
data.tar.gz: 31e6c36a166ff84b21a3b2471c58f3f0e07bac86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d4a72b09ecbd97658880a7bc92fd4b9401705fef7f1f5ba74cd69b77d5138bac02cedce6b189357d187508a7feccd61e6bfe5ddeef567d2390bbb7c195d7974
|
7
|
+
data.tar.gz: 737c20c2d4b99d8c9b7cc162025b27a9e94410355882a17451c0f195f63d3b62daacbfb979a19a15e2a58aa53281511a5e51a619b575289fc4c6bf385d23d23c
|
@@ -15,11 +15,16 @@ module UV
|
|
15
15
|
@indicator = options[:indicator]
|
16
16
|
@size_limit = options[:size_limit]
|
17
17
|
@verbose = options[:verbose] if @size_limit
|
18
|
+
@encoding = options[:encoding]
|
18
19
|
|
19
20
|
raise ArgumentError, 'no indicator provided' unless @indicator
|
20
21
|
raise ArgumentError, 'no callback provided' unless @callback
|
21
22
|
|
22
23
|
@input = ''
|
24
|
+
if @encoding
|
25
|
+
@input.force_encoding(@encoding)
|
26
|
+
@indicator.force_encoding(@encoding) if @indicator.is_a?(String)
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
30
|
# Extract takes an arbitrary string of input data and returns an array of
|
@@ -32,6 +37,7 @@ module UV
|
|
32
37
|
#
|
33
38
|
# @param [String] data
|
34
39
|
def extract(data)
|
40
|
+
data.force_encoding(@encoding) if @encoding
|
35
41
|
@input << data
|
36
42
|
|
37
43
|
messages = @input.split(@indicator, -1)
|
@@ -52,7 +58,7 @@ module UV
|
|
52
58
|
entities << last[0...result]
|
53
59
|
@input = last[result..-1]
|
54
60
|
else
|
55
|
-
|
61
|
+
reset
|
56
62
|
entities << last
|
57
63
|
end
|
58
64
|
else
|
@@ -84,7 +90,7 @@ module UV
|
|
84
90
|
# best we can do with a full buffer.
|
85
91
|
@input = @input[-(@indicator.length - 1)..-1]
|
86
92
|
else
|
87
|
-
|
93
|
+
reset
|
88
94
|
end
|
89
95
|
raise 'input buffer exceeded limit' if @verbose
|
90
96
|
end
|
@@ -98,7 +104,7 @@ module UV
|
|
98
104
|
# @return [String]
|
99
105
|
def flush
|
100
106
|
buffer = @input
|
101
|
-
|
107
|
+
reset
|
102
108
|
buffer
|
103
109
|
end
|
104
110
|
|
@@ -106,5 +112,14 @@ module UV
|
|
106
112
|
def empty?
|
107
113
|
@input.empty?
|
108
114
|
end
|
115
|
+
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
|
120
|
+
def reset
|
121
|
+
@input = ''
|
122
|
+
@input.force_encoding(@encoding) if @encoding
|
123
|
+
end
|
109
124
|
end
|
110
125
|
end
|
@@ -25,10 +25,16 @@ module UV
|
|
25
25
|
@size_limit = options[:size_limit]
|
26
26
|
@min_length = options[:min_length] || 1
|
27
27
|
@verbose = options[:verbose] if @size_limit
|
28
|
+
@encoding = options[:encoding]
|
28
29
|
|
29
30
|
raise ArgumentError, 'no delimiter provided' unless @delimiter
|
30
31
|
|
31
32
|
@input = ''
|
33
|
+
if @encoding
|
34
|
+
@input.force_encoding(@encoding)
|
35
|
+
@delimiter.force_encoding(@encoding) if @delimiter.is_a?(String)
|
36
|
+
@indicator.force_encoding(@encoding) if @indicator.is_a?(String)
|
37
|
+
end
|
32
38
|
end
|
33
39
|
|
34
40
|
# Extract takes an arbitrary string of input data and returns an array of
|
@@ -41,6 +47,7 @@ module UV
|
|
41
47
|
#
|
42
48
|
# @param [String] data
|
43
49
|
def extract(data)
|
50
|
+
data.force_encoding(@encoding) if @encoding
|
44
51
|
@input << data
|
45
52
|
|
46
53
|
# Extract token-delimited entities from the input string with the split command.
|
@@ -72,7 +79,7 @@ module UV
|
|
72
79
|
# delimiter it would be unfortunate
|
73
80
|
@input = @input[-(@indicator.length - 1)..-1]
|
74
81
|
else
|
75
|
-
|
82
|
+
reset
|
76
83
|
end
|
77
84
|
raise 'input buffer exceeded limit' if @verbose
|
78
85
|
end
|
@@ -89,7 +96,7 @@ module UV
|
|
89
96
|
# @return [String]
|
90
97
|
def flush
|
91
98
|
buffer = @input
|
92
|
-
|
99
|
+
reset
|
93
100
|
buffer
|
94
101
|
end
|
95
102
|
|
@@ -97,5 +104,14 @@ module UV
|
|
97
104
|
def empty?
|
98
105
|
@input.empty?
|
99
106
|
end
|
107
|
+
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
|
112
|
+
def reset
|
113
|
+
@input = ''
|
114
|
+
@input.force_encoding(@encoding) if @encoding
|
115
|
+
end
|
100
116
|
end
|
101
117
|
end
|
data/lib/uv-rays/version.rb
CHANGED
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.
|
4
|
+
version: 1.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: 2014-11-
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libuv
|