lunar 0.2.0 → 0.2.1

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.2.0
1
+ 0.2.1
data/lib/lunar/search.rb CHANGED
@@ -18,6 +18,9 @@ module Lunar
18
18
  end
19
19
 
20
20
  def results(&block)
21
+ return [] if sets.empty?
22
+
23
+ # TODO : cache this for X seconds, X seconds being customizable
21
24
  Lunar.redis.zunion dist_key, sets.size, *sets
22
25
 
23
26
  if block_given?
data/lunar.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lunar}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
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"]
@@ -7,6 +7,30 @@ class Item < Struct.new(:id)
7
7
  end
8
8
 
9
9
  class LunarSearchTest < Test::Unit::TestCase
10
+ context "searching when there exists no index yet" do
11
+ should "return an empty set" do
12
+ items = Lunar.search(Item, "foobar")
13
+
14
+ assert_equal 0, items.size
15
+ end
16
+ end
17
+
18
+ context "when searching a non existent term, with an index existing" do
19
+ setup do
20
+ Lunar::Index.create "Item" do |i|
21
+ i.key 1001
22
+ i.attr :name, 'iphone 3GS'
23
+ end
24
+ end
25
+
26
+ should "still return an empty set" do
27
+ items = Lunar.search(Item, "foobar")
28
+
29
+ assert_equal 0, items.size
30
+
31
+ end
32
+ end
33
+
10
34
  context "given an Item named iphone 3GS and apple macbook pro 17 exists" do
11
35
  setup do
12
36
  Lunar::Index.create "Item" do |i|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Cyril David