string-eater 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/string-eater/c-tokenizer.c +2 -3
- data/lib/version.rb +1 -1
- data/spec/nginx_spec.rb +5 -0
- data/spec/string_eater_spec.rb +6 -0
- metadata +2 -3
@@ -109,15 +109,14 @@ static VALUE tokenize_string(VALUE self,
|
|
109
109
|
}
|
110
110
|
}
|
111
111
|
|
112
|
-
ix = str_len;
|
113
112
|
curr_token_ix = n_tokens - 1;
|
114
113
|
|
115
|
-
if(curr_token_ix == next_token_to_extract_ix)
|
114
|
+
if(ix < str_len && curr_token_ix == next_token_to_extract_ix)
|
116
115
|
{
|
117
116
|
rb_hash_aset(extracted_tokens,
|
118
117
|
rb_ary_entry(tokens_to_extract_names, curr_token_ix),
|
119
118
|
rb_usascii_str_new(input_string + startpoint,
|
120
|
-
|
119
|
+
str_len - startpoint));
|
121
120
|
}
|
122
121
|
|
123
122
|
return extracted_tokens;
|
data/lib/version.rb
CHANGED
data/spec/nginx_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe NginxLogTokenizer do
|
|
9
9
|
before(:each) do
|
10
10
|
@tokenizer = NginxLogTokenizer.new
|
11
11
|
@str = '73.80.217.212 - - [01/Aug/2012:09:14:25 -0500] "GET /this_is_a_url HTTP/1.1" 304 152 "http://referrer.com" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)" "-" "there could be" other "stuff here"'
|
12
|
+
@str2 = '73.80.217.212 - - [01/Aug/2012:09:14:25 -0500] "GET /this_is_a_url HTTP/1.1" 304 152 "http://referrer.com" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)" "-"'
|
12
13
|
end
|
13
14
|
|
14
15
|
{
|
@@ -24,4 +25,8 @@ describe NginxLogTokenizer do
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
it "should handle there not being a remainder correctly" do
|
29
|
+
@tokenizer.tokenize!(@str2).remainder.should be_nil
|
30
|
+
end
|
31
|
+
|
27
32
|
end
|
data/spec/string_eater_spec.rb
CHANGED
@@ -93,6 +93,12 @@ describe Example1 do
|
|
93
93
|
@tokenizer.tokenize!("a b|#{s}").third_word.should == s
|
94
94
|
end
|
95
95
|
|
96
|
+
it "should work if the last delimeter is missing and the second-to-last field is not used" do
|
97
|
+
s = "a b"
|
98
|
+
# @tokenizer.extract_all_fields
|
99
|
+
@tokenizer.tokenize!(s).third_word.should be_nil
|
100
|
+
end
|
101
|
+
|
96
102
|
end
|
97
103
|
|
98
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-eater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Fast string tokenizer. Nom strings.
|
15
15
|
email:
|
@@ -64,4 +64,3 @@ test_files:
|
|
64
64
|
- spec/nginx_spec.rb
|
65
65
|
- spec/spec_helper.rb
|
66
66
|
- spec/string_eater_spec.rb
|
67
|
-
has_rdoc:
|