komainu 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/komainu/searches_text.rb +2 -2
- data/lib/komainu/version.rb +1 -1
- data/spec/komainu/searches_text_spec.rb +4 -2
- metadata +7 -7
@@ -60,12 +60,12 @@ module Komainu
|
|
60
60
|
def find_matches text, string
|
61
61
|
text = text.downcase
|
62
62
|
matches = []
|
63
|
+
offset = 0
|
63
64
|
string.split(" ").each { |word|
|
64
65
|
word = word.downcase
|
65
|
-
offset = 0
|
66
66
|
while matched_index = text.index(word, offset)
|
67
67
|
matches << Match.new(matched_index, word)
|
68
|
-
offset
|
68
|
+
offset = matched_index + 1
|
69
69
|
end
|
70
70
|
}
|
71
71
|
matches
|
data/lib/komainu/version.rb
CHANGED
@@ -52,11 +52,13 @@ module Komainu
|
|
52
52
|
|
53
53
|
result = SearchesText.new([item]).search("derp herp")
|
54
54
|
|
55
|
+
result.items.first.matches.size.must_equal 2
|
56
|
+
|
55
57
|
result.items.first.matches[0].text.must_equal "derp"
|
56
58
|
result.items.first.matches[0].index.must_equal 0
|
57
59
|
|
58
|
-
result.items.first.matches[
|
59
|
-
result.items.first.matches[
|
60
|
+
result.items.first.matches[1].text.must_equal "herp"
|
61
|
+
result.items.first.matches[1].index.must_equal 5
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: komainu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-01 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &70258054636300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70258054636300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70258054634820 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70258054634820
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: docu
|
38
|
-
requirement: &
|
38
|
+
requirement: &70258054633900 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70258054633900
|
47
47
|
description: Simple text search using a mixture of basic string search and Levenshtein
|
48
48
|
Distance
|
49
49
|
email:
|