redi_search 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +1 -1
- data/.rubocop.yml +1 -0
- data/Gemfile +1 -1
- data/Rakefile +1 -0
- data/bin/console +6 -2
- data/gemfiles/activerecord_60.gemfile +0 -1
- data/gemfiles/activerecord_61.gemfile +0 -1
- data/lib/redi_search/add_field.rb +1 -1
- data/lib/redi_search/document.rb +8 -4
- data/lib/redi_search/index.rb +1 -1
- data/lib/redi_search/schema.rb +10 -5
- data/lib/redi_search/schema/field.rb +8 -0
- data/lib/redi_search/schema/geo_field.rb +1 -1
- data/lib/redi_search/schema/numeric_field.rb +1 -1
- data/lib/redi_search/schema/tag_field.rb +5 -1
- data/lib/redi_search/schema/text_field.rb +1 -1
- data/lib/redi_search/version.rb +1 -1
- data/redi_search.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ae66b8370802c6acf6c50487cc751e526bd7afa69be14bf56e0e5b8db416511
|
4
|
+
data.tar.gz: ccffbbb3db86598eb132225091cf3cfae3bfac692bca430d2484e7c97f0ab81c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 037fd2b21e9e296e3b143f4d878a9e9cb37406f99c66b22f54a218d1a3d12c046034b19d011b875b2cd5ab3d9a1bb81c4f10b4c862196d01e8a408a2d6436156
|
7
|
+
data.tar.gz: 17e0f4dccd59d130c3d76314cff4b2a94da725b1b5bdc2478aaf39dde5c3a34d178cbafb04db45bf5488a8a7006bb043ed14247e46a47a64d362cc94b6fe52f1
|
data/.github/workflows/lint.yml
CHANGED
@@ -17,6 +17,6 @@ jobs:
|
|
17
17
|
ruby-version: 3.0
|
18
18
|
- name: Install rubocop
|
19
19
|
run: |
|
20
|
-
gem install rubocop rubocop-performance rubocop-minitest
|
20
|
+
gem install rubocop rubocop-performance rubocop-minitest rubocop-rake
|
21
21
|
- name: Lint
|
22
22
|
run: rubocop --config=./.rubocop.yml --parallel
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -5,7 +5,7 @@ require "bundler/setup"
|
|
5
5
|
require "redi_search"
|
6
6
|
|
7
7
|
require "faker"
|
8
|
-
require "
|
8
|
+
require "irb"
|
9
9
|
require "active_support/logger"
|
10
10
|
require "active_record"
|
11
11
|
|
@@ -34,4 +34,8 @@ def seed_users(count = 10_000)
|
|
34
34
|
User.reindex
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
def reload!
|
38
|
+
exec($0)
|
39
|
+
end
|
40
|
+
|
41
|
+
IRB.start
|
data/lib/redi_search/document.rb
CHANGED
@@ -11,8 +11,8 @@ module RediSearch
|
|
11
11
|
def for_object(index, record, serializer: nil, only: [])
|
12
12
|
object_to_serialize = serializer&.new(record) || record
|
13
13
|
|
14
|
-
field_values = index.schema.fields.map do |field|
|
15
|
-
next unless only.empty? || only.include?(field
|
14
|
+
field_values = index.schema.fields.map(&:name).map do |field|
|
15
|
+
next unless only.empty? || only.include?(field)
|
16
16
|
|
17
17
|
[field.to_s, object_to_serialize.public_send(field)]
|
18
18
|
end.compact.to_h
|
@@ -41,11 +41,15 @@ module RediSearch
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def schema_fields
|
44
|
-
@schema_fields ||= index.schema.fields.map
|
44
|
+
@schema_fields ||= index.schema.fields.map do |field|
|
45
|
+
field.name.to_s
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
49
|
def redis_attributes
|
48
|
-
attributes.
|
50
|
+
attributes.flat_map do |field, value|
|
51
|
+
[field, index.schema[field.to_sym].serialize(value)]
|
52
|
+
end
|
49
53
|
end
|
50
54
|
|
51
55
|
def document_id
|
data/lib/redi_search/index.rb
CHANGED
data/lib/redi_search/schema.rb
CHANGED
@@ -12,7 +12,7 @@ module RediSearch
|
|
12
12
|
schema, options = options.to_a.flatten
|
13
13
|
|
14
14
|
Object.const_get("RediSearch::Schema::#{schema.to_s.capitalize}Field").
|
15
|
-
new(field_name, **options.to_h)
|
15
|
+
new(field_name, **options.to_h)
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize(raw)
|
@@ -20,17 +20,22 @@ module RediSearch
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_a
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
fields.map(&:to_a).flatten
|
24
|
+
end
|
25
|
+
|
26
|
+
def [](field)
|
27
|
+
fields.group_by(&:name)[field]&.first
|
26
28
|
end
|
27
29
|
|
28
30
|
def fields
|
29
|
-
raw.
|
31
|
+
@fields ||= raw.map do |field_name, options|
|
32
|
+
self.class.make_field(field_name, options)
|
33
|
+
end.flatten
|
30
34
|
end
|
31
35
|
|
32
36
|
def add_field(field_name, options)
|
33
37
|
raw[field_name] = options
|
38
|
+
@fields = nil
|
34
39
|
self
|
35
40
|
end
|
36
41
|
|
@@ -20,9 +20,13 @@ module RediSearch
|
|
20
20
|
query
|
21
21
|
end
|
22
22
|
|
23
|
+
def serialize(value)
|
24
|
+
value.join(separator)
|
25
|
+
end
|
26
|
+
|
23
27
|
private
|
24
28
|
|
25
|
-
attr_reader :
|
29
|
+
attr_reader :separator, :sortable, :no_index
|
26
30
|
|
27
31
|
def boolean_options
|
28
32
|
%i(sortable no_index)
|
data/lib/redi_search/version.rb
CHANGED
data/redi_search.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = "redi_search"
|
9
9
|
spec.version = RediSearch::VERSION
|
10
10
|
spec.authors = "Nick Pezza"
|
11
|
-
spec.email = "
|
11
|
+
spec.email = "pezza@hey.com"
|
12
12
|
|
13
13
|
spec.summary = %q(RediSearch ruby wrapper that can integrate with Rails)
|
14
14
|
spec.homepage = "https://github.com/npezza93/redi_search"
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.required_ruby_version = ">= 2.5.0"
|
28
28
|
|
29
|
-
spec.add_runtime_dependency "activesupport", ">= 5.
|
29
|
+
spec.add_runtime_dependency "activesupport", ">= 5.1", "< 6.2"
|
30
30
|
spec.add_runtime_dependency "redis", ">= 4.0", "< 5.0"
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler", ">= 1.17", "< 3"
|
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: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pezza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '6.2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '5.
|
29
|
+
version: '5.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '6.2'
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '13.0'
|
101
101
|
description:
|
102
|
-
email:
|
102
|
+
email: pezza@hey.com
|
103
103
|
executables: []
|
104
104
|
extensions: []
|
105
105
|
extra_rdoc_files: []
|