busca 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4bb8a3f394f361469f5737cff36bbf104fadfdc
4
- data.tar.gz: 9427a9b9fbe01dae878c272de043b810e560f63d
3
+ metadata.gz: 8425f876f6e487cc58ed9cf5e264433f92e9d7cb
4
+ data.tar.gz: 0768989e5003650a36d6cc4bc896f12a71d3dfe0
5
5
  SHA512:
6
- metadata.gz: 19b15e5d14ba75446d2b5edf0880e16857b5a7b98a1df26e8839061e4b4bd7bc0f0b8835a710da534af88978832c1775c72ac8ad00a1e7b231a5ac56c4282d2d
7
- data.tar.gz: b05df704a480f6e9a6e7be0549dea7bf264f67b5a6708620d6c01bb9a531a24dffa8af69e029bc6112b0362c49785b739e2549104f57c7dd6e55ab9f997b0feb
6
+ metadata.gz: 6e1e1466a8a131e44e41826c3aa3d6d3331a1094f7edf181a27ae9d896e7b22831023dfb6ba6917dc1959b9f956f3c53ab3a51269061602972d42169f476b855
7
+ data.tar.gz: b463959444b72d1df55483da46cc065511037354e24a5452fe43a0f58a15af1fc9453fcf49f87352f60d58ebdef2e696454f0e183e796c4f05ba1fec9eb5a92d
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  busca.sublime-project
2
2
  busca.sublime-workspace
3
- dump.rdb
3
+ dump.rdb
4
+ *.gem
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Busca Changelog
2
2
 
3
+ ## [0.0.3] - 2015-07-26
4
+
5
+ ### Changed
6
+ - Fixed require in LUA scripts.
7
+ - Fixed `search` and `index` when words is empty
8
+
3
9
  ## [0.0.2] - 2015-07-26
4
10
 
5
11
  ### Changed
data/busca.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "busca"
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
  s.summary = "Busca is a simple redis search"
7
7
  s.description = "Busca is a simple redis search that uses bitmaps to index words"
8
8
  s.authors = ["Julián Porta"]
data/lib/busca.rb CHANGED
@@ -7,9 +7,9 @@ require 'filtra'
7
7
  class Busca
8
8
  NAMESPACE = 'Busca' #TODO: Confirm gem name
9
9
  LUA_CACHE = Hash.new { |h, k| h[k] = Hash.new }
10
- LUA_INDEX = File.expand_path("./lib/lua/index.lua")
11
- LUA_SEARCH = File.expand_path("./lib/lua/search.lua")
12
- LUA_REMOVE = File.expand_path("./lib/lua/remove.lua")
10
+ LUA_INDEX = File.expand_path("../lua/index.lua", __FILE__)
11
+ LUA_SEARCH = File.expand_path("../lua/search.lua", __FILE__)
12
+ LUA_REMOVE = File.expand_path("../lua/remove.lua", __FILE__)
13
13
 
14
14
  attr_reader :namespace, :redis, :separa, :filtra
15
15
 
@@ -28,7 +28,7 @@ class Busca
28
28
 
29
29
  def index(document_id, string)
30
30
  words = split_and_filter(string)
31
-
31
+ return [] if words.empty?
32
32
  index_id = script( LUA_INDEX, 0,
33
33
  @namespace.to_msgpack,
34
34
  document_id.to_msgpack,
@@ -40,6 +40,7 @@ class Busca
40
40
 
41
41
  def search(string)
42
42
  words = split_and_filter(string)
43
+ return [] if words.empty?
43
44
  document_ids = script( LUA_SEARCH, 0,
44
45
  @namespace.to_msgpack,
45
46
  words.to_msgpack
data/lib/lua/search.lua CHANGED
@@ -20,7 +20,7 @@ local function namespace_keys(list)
20
20
  end
21
21
 
22
22
  local function temp_dest_key(words)
23
- local temp_key = join(words, '_')
23
+ local temp_key = join(words, '_')
24
24
  local cached_key = namespace .. ':query_cache:' .. temp_key
25
25
 
26
26
  local cached = redis.call('GET', cached_key)
data/tests/search_test.rb CHANGED
@@ -62,6 +62,13 @@ Grace is here
62
62
  [busca, document, compare, control, chongo]
63
63
  end
64
64
 
65
+ test "searching an empty string" do |busca, document, compare, control, chongo|
66
+ first = busca.index(1, document)
67
+ result = busca.search('')
68
+ assert_equal result, []
69
+
70
+ end
71
+
65
72
  test "search a document" do |busca, document, compare, control, chongo|
66
73
  first = busca.index(1, document)
67
74
  second = busca.index(2, compare)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: busca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julián Porta
@@ -91,7 +91,6 @@ files:
91
91
  - CHANGELOG.md
92
92
  - LICENSE
93
93
  - README.md
94
- - busca-0.0.1.gem
95
94
  - busca.gemspec
96
95
  - lib/busca.rb
97
96
  - lib/lua/index.lua
data/busca-0.0.1.gem DELETED
Binary file