lunar 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.4
1
+ 0.5.5
@@ -4,7 +4,7 @@ require 'nest'
4
4
  require 'text'
5
5
 
6
6
  module Lunar
7
- VERSION = '0.5.2'
7
+ VERSION = '0.5.3'
8
8
 
9
9
  autoload :Connection, "lunar/connection"
10
10
  autoload :LunarNest, "lunar/lunar_nest"
@@ -11,6 +11,8 @@ module Lunar
11
11
  end
12
12
 
13
13
  def distkey
14
+ return if keys.empty?
15
+
14
16
  nest[{ att => value }.hash].tap do |dk|
15
17
  dk.zunionstore keys.flatten
16
18
  end
@@ -18,7 +20,7 @@ module Lunar
18
20
 
19
21
  protected
20
22
  def keys
21
- Words.new(value).map { |w| nest[:Fuzzies][att][Lunar.encode(w)] }
23
+ Words.new(value, false).map { |w| nest[:Fuzzies][att][Lunar.encode(w)] }
22
24
  end
23
25
  end
24
- end
26
+ end
@@ -6,11 +6,12 @@ module Lunar
6
6
  class Words < Array
7
7
  SEPARATOR = /\s+/
8
8
 
9
- def initialize(str)
9
+ def initialize(str, stopwords = true)
10
10
  words = str.split(SEPARATOR).
11
11
  reject { |w| w.to_s.strip.empty? }.
12
- map { |w| sanitize(w) }.
13
- reject { |w| Stopwords.include?(w) }
12
+ map { |w| sanitize(w) }
13
+
14
+ words.reject! { |w| Stopwords.include?(w) } if stopwords
14
15
 
15
16
  super(words)
16
17
  end
@@ -21,4 +22,4 @@ module Lunar
21
22
  gsub(/[^a-zA-Z0-9\-_]/, '').downcase
22
23
  end
23
24
  end
24
- end
25
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lunar}
8
- s.version = "0.5.4"
8
+ s.version = "0.5.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Cyril David"]
12
- s.date = %q{2010-05-27}
12
+ s.date = %q{2010-05-31}
13
13
  s.description = %q{Features full text searching via metaphones, range querying for numbers, fuzzy searching and sorting based on custom fields}
14
14
  s.email = %q{cyx.ucron@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -15,7 +15,7 @@ class TestLunar < Test::Unit::TestCase
15
15
  i.text :tags, 'mobile smartphone apple'
16
16
  i.number :price, 200
17
17
  i.number :score, 35.5
18
- i.fuzzy :code, 'apple iphone mobile'
18
+ i.fuzzy :code, 'apple iphone mobile tmobile'
19
19
 
20
20
  i.sortable :price, 200
21
21
  i.sortable :score, 35.5
@@ -164,6 +164,8 @@ class TestLunar < Test::Unit::TestCase
164
164
  end
165
165
 
166
166
  test "fuzzy matching on code apple iphone" do
167
+ assert_equal %w{1001}, q(:fuzzy => { :code => 'T' })
168
+
167
169
  assert_equal %w{1001}, q(:fuzzy => { :code => 'a' })
168
170
  assert_equal %w{1001}, q(:fuzzy => { :code => 'ap' })
169
171
  assert_equal %w{1001}, q(:fuzzy => { :code => 'app' })
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 4
9
- version: 0.5.4
8
+ - 5
9
+ version: 0.5.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Cyril David
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-27 00:00:00 +08:00
17
+ date: 2010-05-31 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency