redi_search 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redi_search.rb +4 -3
- data/lib/redi_search/client/response.rb +4 -8
- data/lib/redi_search/lazily_load.rb +2 -3
- data/lib/redi_search/search.rb +0 -1
- data/lib/redi_search/search/clauses/boolean.rb +3 -1
- data/lib/redi_search/search/clauses/where.rb +3 -1
- data/lib/redi_search/search/result.rb +21 -5
- data/lib/redi_search/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3216a28eadb3691da0519e94c5fe4fe726e834f8c401adecb1fb4695289780c5
|
4
|
+
data.tar.gz: 6982922d17c64ab29d16f4b67384c19981f2c5d9669742373b3ef30b285a6d20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e52abfcecd94976223fe81cccf576b30d21dedc85fa0b3dbe88520524e351323670bfa057b55ddcafa06b73a1f8732b0622e2bbaba29bd9946fca23c7f1d718
|
7
|
+
data.tar.gz: 6a0b070cfbcdf749b57661bb8219b772d28acd6b6a7e11c37978b1e9c85860e00eebd4b1fb8d865e592777a0b97db6ab7d8346d333cf0bb5e0a36a4cb8f7bdcc
|
data/lib/redi_search.rb
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
require "redis"
|
4
4
|
require "active_support"
|
5
5
|
require "active_model"
|
6
|
-
require "active_support/core_ext/object"
|
7
|
-
require "active_support/core_ext/module/delegation"
|
6
|
+
require "active_support/core_ext/object/blank"
|
8
7
|
|
9
8
|
require "redi_search/configuration"
|
10
9
|
|
@@ -15,6 +14,8 @@ require "redi_search/document"
|
|
15
14
|
|
16
15
|
module RediSearch
|
17
16
|
class << self
|
17
|
+
extend Forwardable
|
18
|
+
|
18
19
|
attr_writer :configuration
|
19
20
|
|
20
21
|
def configuration
|
@@ -29,7 +30,7 @@ module RediSearch
|
|
29
30
|
yield(configuration)
|
30
31
|
end
|
31
32
|
|
32
|
-
|
33
|
+
def_delegator :configuration, :client
|
33
34
|
|
34
35
|
def env
|
35
36
|
@env ||= ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
|
@@ -3,12 +3,6 @@
|
|
3
3
|
module RediSearch
|
4
4
|
class Client
|
5
5
|
class Response < SimpleDelegator
|
6
|
-
def initialize(response)
|
7
|
-
@response = response
|
8
|
-
|
9
|
-
super(response)
|
10
|
-
end
|
11
|
-
|
12
6
|
def ok?
|
13
7
|
case response
|
14
8
|
when String then response == "OK"
|
@@ -20,13 +14,15 @@ module RediSearch
|
|
20
14
|
|
21
15
|
private
|
22
16
|
|
23
|
-
attr_reader :response
|
24
|
-
|
25
17
|
def array_ok?
|
26
18
|
response.all? do |pipeline_response|
|
27
19
|
Response.new(pipeline_response).ok?
|
28
20
|
end
|
29
21
|
end
|
22
|
+
|
23
|
+
def response
|
24
|
+
__getobj__
|
25
|
+
end
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
@@ -3,12 +3,11 @@
|
|
3
3
|
module RediSearch
|
4
4
|
module LazilyLoad
|
5
5
|
extend ActiveSupport::Concern
|
6
|
+
extend Forwardable
|
6
7
|
|
7
8
|
include Enumerable
|
8
9
|
|
9
|
-
|
10
|
-
delegate :size, :each, to: :to_a
|
11
|
-
end
|
10
|
+
def_delegators :to_a, :size, :each
|
12
11
|
|
13
12
|
def loaded?
|
14
13
|
@loaded = false unless defined? @loaded
|
data/lib/redi_search/search.rb
CHANGED
@@ -4,6 +4,8 @@ module RediSearch
|
|
4
4
|
class Search
|
5
5
|
module Clauses
|
6
6
|
class Boolean
|
7
|
+
extend Forwardable
|
8
|
+
|
7
9
|
def initialize(search, term, prior_clause = nil, **term_options)
|
8
10
|
@search = search
|
9
11
|
@prior_clause = prior_clause
|
@@ -18,7 +20,7 @@ module RediSearch
|
|
18
20
|
[prior_clause.presence, queryify_term].compact.join(operand)
|
19
21
|
end
|
20
22
|
|
21
|
-
|
23
|
+
def_delegator :to_s, :inspect
|
22
24
|
|
23
25
|
def not(term, **term_options)
|
24
26
|
@not = true
|
@@ -4,6 +4,8 @@ module RediSearch
|
|
4
4
|
class Search
|
5
5
|
module Clauses
|
6
6
|
class Where
|
7
|
+
extend Forwardable
|
8
|
+
|
7
9
|
def initialize(search, condition, prior_clause = nil)
|
8
10
|
@search = search
|
9
11
|
@prior_clause = prior_clause
|
@@ -19,7 +21,7 @@ module RediSearch
|
|
19
21
|
].compact.join(" ")
|
20
22
|
end
|
21
23
|
|
22
|
-
|
24
|
+
def_delegator :to_s, :inspect
|
23
25
|
|
24
26
|
def not(condition)
|
25
27
|
@not = true
|
@@ -2,24 +2,40 @@
|
|
2
2
|
|
3
3
|
module RediSearch
|
4
4
|
class Search
|
5
|
-
class Result
|
5
|
+
class Result
|
6
|
+
extend Forwardable
|
7
|
+
include Enumerable
|
8
|
+
|
6
9
|
def initialize(index, used_clauses, count, documents)
|
7
10
|
@count = count
|
8
11
|
@used_clauses = used_clauses
|
9
|
-
|
10
|
-
super(parse_results(index, documents))
|
12
|
+
@results = parse_results(index, documents)
|
11
13
|
end
|
12
14
|
|
13
15
|
def count
|
14
|
-
@count ||
|
16
|
+
@count || results.count
|
15
17
|
end
|
16
18
|
|
17
19
|
def size
|
18
|
-
@count ||
|
20
|
+
@count || results.size
|
21
|
+
end
|
22
|
+
|
23
|
+
def_delegators :results, :each, :empty?
|
24
|
+
|
25
|
+
#:nocov:
|
26
|
+
def inspect
|
27
|
+
results
|
28
|
+
end
|
29
|
+
|
30
|
+
def pretty_print(printer)
|
31
|
+
printer.pp(results)
|
19
32
|
end
|
33
|
+
#:nocov:
|
20
34
|
|
21
35
|
private
|
22
36
|
|
37
|
+
attr_reader :results
|
38
|
+
|
23
39
|
def response_slice
|
24
40
|
slice_length = 2
|
25
41
|
slice_length -= 1 if no_content?
|
data/lib/redi_search/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redi_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pezza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|