lunar 0.5.2 → 0.5.3
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/VERSION +1 -1
- data/lib/lunar.rb +7 -3
- data/lib/lunar/result_set.rb +12 -1
- data/lunar.gemspec +1 -1
- data/test/test_lunar.rb +8 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.3
|
data/lib/lunar.rb
CHANGED
@@ -110,11 +110,15 @@ private
|
|
110
110
|
sets << RangeMatches.new(nest[namespace], key, value).distkey
|
111
111
|
elsif key == :fuzzy
|
112
112
|
fuzzy_matches = value.map { |fuzzy_key, fuzzy_value|
|
113
|
-
|
113
|
+
unless fuzzy_value.to_s.empty?
|
114
|
+
FuzzyMatches.new(nest[namespace], fuzzy_key, fuzzy_value).distkey
|
115
|
+
end
|
114
116
|
}
|
115
|
-
sets.push(*fuzzy_matches)
|
117
|
+
sets.push(*fuzzy_matches.compact)
|
116
118
|
else
|
117
|
-
|
119
|
+
unless value.to_s.empty?
|
120
|
+
sets << KeywordMatches.new(nest[namespace], key, value).distkey
|
121
|
+
end
|
118
122
|
end
|
119
123
|
|
120
124
|
sets
|
data/lib/lunar/result_set.rb
CHANGED
@@ -89,11 +89,22 @@ module Lunar
|
|
89
89
|
# @see http://code.google.com/p/redis/wiki/SortCommand
|
90
90
|
def sort(opts = {})
|
91
91
|
return [] if not distkey
|
92
|
-
|
92
|
+
|
93
93
|
opts[:by] = sortables[opts[:by]] if opts[:by]
|
94
|
+
|
95
|
+
if opts[:start] && opts[:limit]
|
96
|
+
opts[:limit] = [opts[:start], opts[:limit]]
|
97
|
+
end
|
98
|
+
|
94
99
|
objects(distkey.sort(opts))
|
95
100
|
end
|
96
101
|
|
102
|
+
def size
|
103
|
+
return 0 if not distkey
|
104
|
+
|
105
|
+
distkey.zcard
|
106
|
+
end
|
107
|
+
|
97
108
|
protected
|
98
109
|
def objects(ids)
|
99
110
|
ids.map(&@finder)
|
data/lunar.gemspec
CHANGED
data/test/test_lunar.rb
CHANGED
@@ -76,6 +76,14 @@ class TestLunar < Test::Unit::TestCase
|
|
76
76
|
assert_equal [], q(:q => "ericson", :price => 150..200)
|
77
77
|
end
|
78
78
|
|
79
|
+
test "searching combinations of empty strings" do
|
80
|
+
assert_equal %w{1001}, q(:q => 'apple', :tags => 'mobile', :title => "")
|
81
|
+
assert_equal %w{1001}, q(:q => 'apple', :tags => 'smartphone', :title => "")
|
82
|
+
assert_equal %w{1001}, q(:q => 'apple', :tags => 'apple', :title => "")
|
83
|
+
|
84
|
+
assert_equal %w{1001 1002 1003}, q(:q => 'mobile', :tags => 'smartphone', :title => "")
|
85
|
+
end
|
86
|
+
|
79
87
|
test "sorting empty result sets" do
|
80
88
|
assert_equal [], Lunar.search(Gadget, :q => "ericson").sort(:by => :price)
|
81
89
|
end
|