redi_search 2.0.0 → 4.1.0

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/.travis.yml DELETED
@@ -1,63 +0,0 @@
1
- ---
2
- env:
3
- global:
4
- - CC_TEST_REPORTER_ID=fec34310f03fd2cc767a85fa23d5102f3dca67b9cc967a48d9940027731394e8
5
- sudo: false
6
- language: ruby
7
- cache:
8
- directories:
9
- - gemfiles/vendor/bundle
10
- - /home/travis/.rvm/
11
- services: docker
12
- jobs:
13
- include:
14
- - stage: Integration Tests
15
- script: |
16
- docker run -d -p 6379:6379 redislabs/redisearch:1.4.12 --protected-mode no --loadmodule /usr/lib/redis/modules/redisearch.so
17
- bundle exec rake test:integration
18
- rvm: 2.6
19
- gemfile: Gemfile
20
- name: RediSearch 1.4.12
21
- - stage: Integration Tests
22
- script: |
23
- docker run -d -p 6379:6379 redislabs/redisearch:1.4.11 --protected-mode no --loadmodule /usr/lib/redis/modules/redisearch.so
24
- bundle exec rake test:integration
25
- rvm: 2.6
26
- gemfile: Gemfile
27
- name: RediSearch 1.4.11
28
- - stage: Integration Tests
29
- script: |
30
- docker run -d -p 6379:6379 redislabs/redisearch:1.4.10 --protected-mode no --loadmodule /usr/lib/redis/modules/redisearch.so
31
- bundle exec rake test:integration
32
- rvm: 2.6
33
- gemfile: Gemfile
34
- name: RediSearch 1.4.10
35
- - stage: Unit Tests
36
- script: |
37
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
38
- chmod +x ./cc-test-reporter
39
- ./cc-test-reporter before-build
40
- bundle exec rake test:unit
41
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
42
- rvm: 2.6
43
- gemfile: Gemfile
44
- name: Ruby 2.6 and Rails 6.0rc2
45
- - stage: Unit Tests
46
- script: bundle exec rake test:unit
47
- rvm: 2.6
48
- gemfile: gemfiles/activerecord_52.gemfile
49
- name: Ruby 2.6 and Rails 5.2
50
- - stage: Unit Tests
51
- script: bundle exec rake test:unit
52
- rvm: 2.6
53
- gemfile: gemfiles/activerecord_51.gemfile
54
- name: Ruby 2.6 and Rails 5.1
55
- - stage: Unit Tests
56
- script: bundle exec rake test:unit
57
- rvm: 2.5
58
- gemfile: Gemfile
59
- name: Ruby 2.5 and Rails 6.0rc2
60
- - stage: Lint
61
- script: bundle exec rubocop --config=./.rubocop.yml
62
- rvm: 2.6
63
- name: Rubocop
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "redi_search/validatable"
4
-
5
- module RediSearch
6
- class Add
7
- include Validatable
8
-
9
- validates_numericality_of :score, within: 0.0..1.0
10
-
11
- def initialize(index, document, score: 1.0, replace: {}, language: nil,
12
- no_save: false)
13
- @index = index
14
- @document = document
15
- @score = score || 1.0
16
- @replace = replace
17
- @language = language
18
- @no_save = no_save
19
- end
20
-
21
- def call!
22
- validate!
23
-
24
- RediSearch.client.call!(*command).ok?
25
- end
26
-
27
- def call
28
- call!
29
- rescue Redis::CommandError
30
- false
31
- end
32
-
33
- private
34
-
35
- attr_reader :index, :document, :score, :replace, :language, :no_save
36
-
37
- def command
38
- ["ADD", index.name, document.document_id, score, *extract_options,
39
- "FIELDS", document.redis_attributes].compact
40
- end
41
-
42
- def extract_options
43
- opts = []
44
- opts << ["LANGUAGE", language] if language
45
- opts << "NOSAVE" if no_save
46
- opts << replace_options if replace?
47
- opts
48
- end
49
-
50
- def replace?
51
- if replace.respond_to?(:empty?)
52
- !replace.empty?
53
- else
54
- replace
55
- end
56
- end
57
-
58
- def replace_options
59
- ["REPLACE"].tap do |replace_option|
60
- if replace.is_a?(Hash)
61
- replace_option << "PARTIAL" if replace[:partial]
62
- # replace_option << "NOCREATE" if replace[:no_create]
63
- end
64
- end
65
- end
66
- end
67
- end