busca 0.0.2 → 0.0.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +6 -0
- data/busca.gemspec +1 -1
- data/lib/busca.rb +5 -4
- data/lib/lua/search.lua +1 -1
- data/tests/search_test.rb +7 -0
- metadata +1 -2
- data/busca-0.0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8425f876f6e487cc58ed9cf5e264433f92e9d7cb
|
4
|
+
data.tar.gz: 0768989e5003650a36d6cc4bc896f12a71d3dfe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e1e1466a8a131e44e41826c3aa3d6d3331a1094f7edf181a27ae9d896e7b22831023dfb6ba6917dc1959b9f956f3c53ab3a51269061602972d42169f476b855
|
7
|
+
data.tar.gz: b463959444b72d1df55483da46cc065511037354e24a5452fe43a0f58a15af1fc9453fcf49f87352f60d58ebdef2e696454f0e183e796c4f05ba1fec9eb5a92d
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/busca.gemspec
CHANGED
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("
|
11
|
-
LUA_SEARCH = File.expand_path("
|
12
|
-
LUA_REMOVE = File.expand_path("
|
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.
|
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
|