string-eater 0.2.1 → 0.2.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.
data/README.md CHANGED
@@ -74,7 +74,7 @@ Then, we can tokenize the string like this:
74
74
  string = "Flinstone, Fred | 301 Cobblestone Way, Bedrock, NA, 00000"
75
75
  tokenizer.tokenize! string
76
76
 
77
- puts tokenizer.last_name # => "Flinestone"
77
+ puts tokenizer.last_name # => "Flinstone"
78
78
  puts tokenizer.city # => "Bedrock"
79
79
  puts tokenizer.state # => "NA"
80
80
 
@@ -107,6 +107,12 @@ static VALUE tokenize_string(VALUE self,
107
107
  }
108
108
  looking_for = looking_for_token[looking_for_ix];
109
109
  }
110
+ else
111
+ {
112
+ /* reset token (or just keep looking, which is also fine) */
113
+ looking_for_ix = 0;
114
+ looking_for = looking_for_token[looking_for_ix];
115
+ }
110
116
  }
111
117
 
112
118
  curr_token_ix = n_tokens - 1;
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@ module StringEater
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 1
5
+ PATCH = 2
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
8
8
  end
@@ -129,6 +129,29 @@ describe Example2 do
129
129
 
130
130
  end
131
131
 
132
+ # an example where the split is more than one char
133
+ class Example3 < TestedClass
134
+ look_for "foo="
135
+ add_field :foo_val
136
+ look_for "&"
137
+ end
138
+
139
+ describe Example3 do
140
+ before(:each) do
141
+ @tokenizer = Example3.new
142
+ end
143
+
144
+ describe "tokenize!" do
145
+ it "should find the token if there is only one occurrence of the characters in the separator" do
146
+ @tokenizer.tokenize!("abcd?foo=val&blah").foo_val.should == "val"
147
+ end
148
+
149
+ it "should still work if part of the separator token occurs" do
150
+ @tokenizer.tokenize!("abcd?foo_blah=baz&foo=bar&buh").foo_val.should == "bar"
151
+ end
152
+ end
153
+ end
154
+
132
155
  # CTokenizer doesn't do combine_fields because
133
156
  # writing out breakpoints is a significant slow-down
134
157
  if TestedClass.respond_to?(:combine_fields)
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.1
4
+ version: 0.2.2
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-22 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Fast string tokenizer. Nom strings.
15
15
  email: