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 CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -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
- FuzzyMatches.new(nest[namespace], fuzzy_key, fuzzy_value).distkey
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
- sets << KeywordMatches.new(nest[namespace], key, value).distkey
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
@@ -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)
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lunar}
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
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"]
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 2
9
- version: 0.5.2
8
+ - 3
9
+ version: 0.5.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Cyril David