komainu 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,19 +27,22 @@ module Komainu
27
27
  words = split_into_words(@data_to_search.map { |searchable| searchable.text }.join(" "))
28
28
  levenshtein = Levenshtein.new(words)
29
29
 
30
- found_suggestion = false
31
30
  suggestion = split_into_words(query).map do |word|
32
31
  matches = levenshtein.search(word, 2)
33
32
 
34
33
  if matches.empty? != true && matches.keys.first != word
35
- found_suggestion = true
36
34
  matches.sort {|a,b| a[1] <=> b[1]}.first.first
37
35
  else
38
36
  word
39
37
  end
40
38
  end
41
39
 
42
- suggestion.join(" ") if found_suggestion
40
+ suggestion = suggestion.join(" ")
41
+ if suggestion != query
42
+ suggestion
43
+ else
44
+ nil
45
+ end
43
46
  end
44
47
 
45
48
  def split_into_words(string)
@@ -1,3 +1,3 @@
1
1
  module Komainu
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70315498054880 !ruby/object:Gem::Requirement
16
+ requirement: &70113471466500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70315498054880
24
+ version_requirements: *70113471466500
25
25
  description: ''
26
26
  email:
27
27
  - andrew.vos@gmail.com