chewy 5.0.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +214 -0
  3. data/Appraisals +1 -17
  4. data/CHANGELOG.md +40 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +61 -35
  8. data/chewy.gemspec +4 -4
  9. data/gemfiles/rails.5.2.activerecord.gemfile +4 -3
  10. data/gemfiles/{rails.5.0.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +4 -3
  11. data/gemfiles/{rails.5.0.mongoid.6.1.gemfile → rails.6.0.activerecord.gemfile} +4 -3
  12. data/gemfiles/{rails.5.1.activerecord.gemfile → rails.6.1.activerecord.gemfile} +6 -3
  13. data/gemfiles/ruby3.gemfile +10 -0
  14. data/lib/chewy/backports/duplicable.rb +1 -1
  15. data/lib/chewy/fields/base.rb +1 -1
  16. data/lib/chewy/fields/root.rb +2 -2
  17. data/lib/chewy/index/actions.rb +9 -3
  18. data/lib/chewy/query/loading.rb +1 -1
  19. data/lib/chewy/query/nodes/field.rb +1 -1
  20. data/lib/chewy/query.rb +5 -0
  21. data/lib/chewy/railtie.rb +1 -1
  22. data/lib/chewy/search/loader.rb +1 -1
  23. data/lib/chewy/search/parameters/allow_partial_search_results.rb +27 -0
  24. data/lib/chewy/search/parameters/indices.rb +123 -0
  25. data/lib/chewy/search/parameters.rb +24 -6
  26. data/lib/chewy/search/request.rb +76 -51
  27. data/lib/chewy/search/scrolling.rb +3 -5
  28. data/lib/chewy/search.rb +1 -5
  29. data/lib/chewy/strategy/active_job.rb +1 -1
  30. data/lib/chewy/strategy/sidekiq.rb +1 -1
  31. data/lib/chewy/type/adapter/active_record.rb +1 -1
  32. data/lib/chewy/type/adapter/mongoid.rb +1 -1
  33. data/lib/chewy/type/adapter/orm.rb +1 -1
  34. data/lib/chewy/type/adapter/sequel.rb +1 -1
  35. data/lib/chewy/type/import/bulk_request.rb +4 -2
  36. data/lib/chewy/type/import/journal_builder.rb +1 -1
  37. data/lib/chewy/type/import/routine.rb +1 -1
  38. data/lib/chewy/type/import.rb +3 -3
  39. data/lib/chewy/type/mapping.rb +4 -4
  40. data/lib/chewy/type/observe.rb +3 -3
  41. data/lib/chewy/type/witchcraft.rb +1 -1
  42. data/lib/chewy/type/wrapper.rb +1 -1
  43. data/lib/chewy/version.rb +1 -1
  44. data/lib/chewy.rb +1 -1
  45. data/spec/chewy/config_spec.rb +1 -1
  46. data/spec/chewy/fields/base_spec.rb +11 -9
  47. data/spec/chewy/index/actions_spec.rb +2 -2
  48. data/spec/chewy/journal_spec.rb +1 -1
  49. data/spec/chewy/search/parameters/indices_spec.rb +191 -0
  50. data/spec/chewy/search/parameters_spec.rb +20 -3
  51. data/spec/chewy/search/request_spec.rb +25 -9
  52. data/spec/chewy/search/response_spec.rb +8 -2
  53. data/spec/chewy/search_spec.rb +2 -2
  54. data/spec/chewy/strategy/active_job_spec.rb +15 -2
  55. data/spec/chewy/strategy/shoryuken_spec.rb +6 -2
  56. data/spec/chewy/strategy/sidekiq_spec.rb +6 -2
  57. data/spec/chewy/type/adapter/active_record_spec.rb +3 -3
  58. data/spec/chewy/type/import/bulk_builder_spec.rb +1 -1
  59. data/spec/chewy/type/observe_spec.rb +4 -4
  60. data/spec/spec_helper.rb +4 -1
  61. metadata +21 -22
  62. data/.travis.yml +0 -45
  63. data/gemfiles/rails.4.0.activerecord.gemfile +0 -15
  64. data/gemfiles/rails.4.1.activerecord.gemfile +0 -15
  65. data/gemfiles/rails.4.2.activerecord.gemfile +0 -16
  66. data/gemfiles/rails.4.2.mongoid.5.2.gemfile +0 -16
  67. data/gemfiles/rails.5.1.mongoid.6.3.gemfile +0 -16
  68. data/spec/chewy/search/parameters/indices_boost_spec.rb +0 -83
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2decd9fc56f1c1116f0470c5dfce2fb84b3dbbab25ed42bcc1813f2f91069292
4
- data.tar.gz: 969f6d74cff1f399ffa9752d2559a9affcaa2fe96a63e05cdfe4aa2b0add0af4
3
+ metadata.gz: ce34ae965f4efd39230e5e7fd8cd6d63a17c5e645745f7565ad4feea944244bb
4
+ data.tar.gz: b4fcade45c69fd1003b22d0b3a1a7e6e1f2f042f422fcf5dc510250d7c63bf6f
5
5
  SHA512:
6
- metadata.gz: e55c97184ed6f171f9383087b792b6261167687acad1add6ca2d5196e87676b1600c54277174e213fd07de6d6d811124a20130ac7ca7ccb5b7077a78a710fbbc
7
- data.tar.gz: b0ceb62da09eea3332e1d67bdca2ab56dfadae6366ca27a8009e502da01057891e7c6a33bfb67f81f4b35119eff550b4390d40e9860e2441065d72c4d30fca78
6
+ metadata.gz: 2266cf1f1b14d4dd70f0c34c07f3b722fc8a15b9532bc8a7c332f387634982b3ccac87a1bb692ca0023d588692cfb3f090f2410f3775a3e2678f3d08d762045a
7
+ data.tar.gz: 9ca016cc817585547e994597a08e14c7484dc13a5f9a7d35b1685cb9135b604b0ba94221120c87dbe4a2b6c3e67dec3a105f2de2014eb82e8081b45dad960f31
@@ -0,0 +1,214 @@
1
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
2
+ version: 2.1
3
+
4
+ es56-env: &es56-env
5
+ cluster.name: elasticsearch
6
+ transport.host: localhost
7
+ network.host: 127.0.0.1
8
+ http.port: 9250
9
+ discovery.type: single-node
10
+ xpack.security.enabled: false
11
+ xpack.monitoring.enabled: false
12
+
13
+ workflows:
14
+ build:
15
+ jobs:
16
+ - rubocop
17
+ - rspec-ruby-26-activerecord61
18
+ - rspec-ruby-26-activerecord60
19
+ - rspec-ruby-26-activerecord52
20
+ - rspec-ruby-26-mongoid
21
+ - rspec-ruby-27-activerecord61
22
+ - rspec-ruby-27-activerecord60
23
+ - rspec-ruby-27-activerecord52
24
+ - rspec-ruby-27-mongoid
25
+ - rspec-ruby-30-activerecord61
26
+
27
+ commands:
28
+ rspec-test:
29
+ description: Test rspec in current ruby
30
+ parameters:
31
+ pre-steps:
32
+ description: Necessary steps after checkout
33
+ type: steps
34
+ default: []
35
+ steps:
36
+ - checkout
37
+ - run:
38
+ name: ruby version
39
+ command: |
40
+ ruby -e "STDERR.puts RUBY_VERSION; puts RUBY_VERSION.gsub(/^(\d+)\.(\d+)\..*/, '\1_\2')" > .ruby.version
41
+ - run:
42
+ name: Gemfile.lock version
43
+ command: |
44
+ echo "$GEMFILE.lock" > .Gemfile.lock.path
45
+ - steps: << parameters.pre-steps >>
46
+ - restore_cache:
47
+ keys:
48
+ - dependencies-{{ checksum ".ruby.version" }}-{{ checksum ".Gemfile.lock.path" }}
49
+ - run:
50
+ name: install dependencies
51
+ command: |
52
+ bundle install --jobs=4 --retry=3 --path vendor/bundle --gemfile=$GEMFILE
53
+ - save_cache:
54
+ paths:
55
+ - ./vendor/bundle
56
+ key: dependencies-{{ checksum ".ruby.version" }}-{{ checksum ".Gemfile.lock.path" }}
57
+ - run:
58
+ name: Disable replication of elastic indices
59
+ command: |
60
+ curl -XPUT 'http://localhost:9250/_all/_settings?preserve_existing=true' -d '{
61
+ "index.number_of_replicas":"0"
62
+ }'
63
+ - run:
64
+ name: run tests
65
+ command: |
66
+ ruby -v
67
+ git config --global user.email "you@example.com"
68
+ git config --global user.name "Your Name"
69
+ mkdir /tmp/test-results
70
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
71
+ BUNDLE_GEMFILE=$GEMFILE bundle exec rspec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec.xml $TEST_FILES
72
+ - store_test_results:
73
+ path: /tmp/test-results
74
+
75
+ jobs:
76
+ rubocop:
77
+ docker:
78
+ - image: circleci/ruby:2.6
79
+ working_directory: ~/repo
80
+ steps:
81
+ - checkout
82
+ - run:
83
+ name: ruby version
84
+ command: |
85
+ ruby -e "STDERR.puts RUBY_VERSION; puts RUBY_VERSION.gsub(/^(\d+)\.(\d+)\..*/, '\1_\2')" > .ruby.version
86
+ - run:
87
+ name: Gemfile.lock version
88
+ command: |
89
+ echo "$GEMFILE.lock" > .Gemfile.lock.path
90
+ - restore_cache:
91
+ keys:
92
+ - dependencies-{{ checksum ".ruby.version" }}-{{ checksum ".Gemfile.lock.path" }}
93
+ - run:
94
+ name: install dependencies
95
+ command: |
96
+ bundle install --jobs=4 --retry=3 --path vendor/bundle --binstubs=/usr/local/bundle/bin
97
+ - save_cache:
98
+ paths:
99
+ - ./vendor/bundle
100
+ key: dependencies-{{ checksum ".ruby.version" }}-{{ checksum ".Gemfile.lock.path" }}
101
+ - run:
102
+ name: run rubocop
103
+ command: |
104
+ bundle exec rubocop --format simple
105
+
106
+ rspec-ruby-26-activerecord52:
107
+ docker:
108
+ - image: circleci/ruby:2.6
109
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
110
+ environment:
111
+ <<: *es56-env
112
+ working_directory: ~/repo
113
+ environment:
114
+ GEMFILE: gemfiles/rails.5.2.activerecord.gemfile
115
+ steps:
116
+ - rspec-test
117
+
118
+ rspec-ruby-26-activerecord60:
119
+ docker:
120
+ - image: circleci/ruby:2.6
121
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
122
+ environment:
123
+ <<: *es56-env
124
+ working_directory: ~/repo
125
+ environment:
126
+ GEMFILE: gemfiles/rails.6.0.activerecord.gemfile
127
+ steps:
128
+ - rspec-test
129
+
130
+ rspec-ruby-26-activerecord61:
131
+ docker:
132
+ - image: circleci/ruby:2.6
133
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
134
+ environment:
135
+ <<: *es56-env
136
+ working_directory: ~/repo
137
+ environment:
138
+ GEMFILE: gemfiles/rails.6.1.activerecord.gemfile
139
+ steps:
140
+ - rspec-test
141
+
142
+ rspec-ruby-26-mongoid:
143
+ docker:
144
+ - image: circleci/ruby:2.6
145
+ - image: circleci/mongo:4.2.5
146
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
147
+ environment:
148
+ <<: *es56-env
149
+ working_directory: ~/repo
150
+ environment:
151
+ GEMFILE: gemfiles/rails.5.2.mongoid.6.4.gemfile
152
+ steps:
153
+ - rspec-test
154
+
155
+ rspec-ruby-27-activerecord52:
156
+ docker:
157
+ - image: circleci/ruby:2.7
158
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
159
+ environment:
160
+ <<: *es56-env
161
+ working_directory: ~/repo
162
+ environment:
163
+ GEMFILE: gemfiles/rails.5.2.activerecord.gemfile
164
+ steps:
165
+ - rspec-test
166
+
167
+ rspec-ruby-27-activerecord60:
168
+ docker:
169
+ - image: circleci/ruby:2.7
170
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
171
+ environment:
172
+ <<: *es56-env
173
+ working_directory: ~/repo
174
+ environment:
175
+ GEMFILE: gemfiles/rails.6.0.activerecord.gemfile
176
+ steps:
177
+ - rspec-test
178
+
179
+ rspec-ruby-27-activerecord61:
180
+ docker:
181
+ - image: circleci/ruby:2.7
182
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
183
+ environment:
184
+ <<: *es56-env
185
+ working_directory: ~/repo
186
+ environment:
187
+ GEMFILE: gemfiles/rails.6.1.activerecord.gemfile
188
+ steps:
189
+ - rspec-test
190
+
191
+ rspec-ruby-27-mongoid:
192
+ docker:
193
+ - image: circleci/ruby:2.7
194
+ - image: circleci/mongo:4.2.5
195
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
196
+ environment:
197
+ <<: *es56-env
198
+ working_directory: ~/repo
199
+ environment:
200
+ GEMFILE: gemfiles/rails.5.2.mongoid.6.4.gemfile
201
+ steps:
202
+ - rspec-test
203
+
204
+ rspec-ruby-30-activerecord61:
205
+ docker:
206
+ - image: circleci/ruby:3.0
207
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
208
+ environment:
209
+ <<: *es56-env
210
+ working_directory: ~/repo
211
+ environment:
212
+ GEMFILE: gemfiles/rails.6.1.activerecord.gemfile
213
+ steps:
214
+ - rspec-test
data/Appraisals CHANGED
@@ -16,7 +16,7 @@
16
16
  end
17
17
  end
18
18
 
19
- %w[5.0 5.1].each do |activesupport|
19
+ %w[5.0 5.1 5.2].each do |activesupport|
20
20
  appraise "rails.#{activesupport}.activerecord" do
21
21
  gem 'activerecord', "~> #{activesupport}.0"
22
22
  gem 'activesupport', "~> #{activesupport}.0"
@@ -34,22 +34,6 @@ end
34
34
  end
35
35
  end
36
36
 
37
- appraise 'rails.5.2.activerecord' do
38
- gem 'activerecord', '~> 5.2.0.rc1'
39
- gem 'activesupport', '~> 5.2.0.rc1'
40
-
41
- gem 'activejob', '~> 5.2.0.rc1'
42
- gem 'resque', require: false
43
- gem 'shoryuken', require: false
44
- gem 'aws-sdk-sqs', require: false
45
- gem 'sidekiq', require: false
46
-
47
- gem 'kaminari-core', '~> 1.1.0', require: false
48
- gem 'will_paginate', require: false
49
-
50
- gem 'parallel', require: false
51
- end
52
-
53
37
  appraise 'rails.4.2.mongoid.5.2' do
54
38
  gem 'mongoid', '~> 5.2.0'
55
39
  gem 'activesupport', '~> 4.2.0'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # master
2
2
 
3
+ # Version 5.2.0
4
+
5
+ ## Changes
6
+
7
+ * Add support for Ruby 3 (@lowang, #734)
8
+
9
+ * Correct deprecation warning for Elasticsearch 5.6 to 6: empty query for`_delete_by_query`, delete by alias, `index_already_exists_exception` renaming (@bhacaz, #735)
10
+
11
+ * Update gemspec dependencies for Rails. Update CI gemfiles and matrix to tests against current LTS Rails versions. (@bhacaz, #733)
12
+
13
+ * Tweak some wording and formatting; add a note about compatibility; update copyright; remove broken logo; update the CI badge (@bbatsov)
14
+
15
+ * Update instructions for AWS ElasticSearch (@olancheg, #714)
16
+
17
+ * Fix more ruby 2.7 keyword params deprecation warnings (@aglushkov, #728)
18
+
19
+ * Fixed all deprecation warnings in Ruby 2.7 (@gseddon, #715)
20
+
21
+ * Added Ruby 2.7 to CircleCI config (@mrzasa, #718)
22
+
23
+ * Allow configuration of Active Job queue name (@mrzasa, #707)
24
+
25
+ * Setup CI on CircleCI (@mrzasa, #711)
26
+
27
+ * Fix deprecation warning for contructing new BigDecimal (@AlexVPopov, #710)
28
+
29
+ # Version 5.1.0
30
+
31
+ ## Breaking changes
32
+
33
+ * Add support for multiple indices in request (@pyromaniac, #657)
34
+
35
+ * Support `search_type`, `request_cache`, and `allow_partial_search_results` as query string parameters (@mattzollinhofer, #647)
36
+
37
+ ## Changes
38
+
39
+ * Speed up imports when `bulk_size` is specified (@yahooguntu, #606)
40
+
41
+ * Insert `RequestStrategy` middleware before `ActionDispatch::ShowExceptions` (@dck, #682)
42
+
3
43
  # Version 5.0.0
4
44
 
5
45
  ## Breaking changes
data/Gemfile CHANGED
@@ -24,3 +24,5 @@ gem 'guard-rspec'
24
24
 
25
25
  gem 'redcarpet'
26
26
  gem 'yard'
27
+
28
+ eval(File.read('gemfiles/ruby3.gemfile'), nil, 'gemfiles/ruby3.gemfile') if RUBY_VERSION >= '3.0.0' # rubocop:disable Security/Eval
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 pyromaniac
1
+ Copyright (c) 2013-2021 Toptal, LLC
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,14 +1,11 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/chewy.svg)](http://badge.fury.io/rb/chewy)
2
- [![Build Status](https://travis-ci.org/toptal/chewy.svg)](https://travis-ci.org/toptal/chewy)
2
+ [![CircleCI](https://circleci.com/gh/toptal/chewy/tree/master.svg?style=svg)](https://circleci.com/gh/toptal/chewy/tree/master)
3
3
  [![Code Climate](https://codeclimate.com/github/toptal/chewy.svg)](https://codeclimate.com/github/toptal/chewy)
4
4
  [![Inline docs](http://inch-ci.org/github/toptal/chewy.svg?branch=master)](http://inch-ci.org/github/toptal/chewy)
5
5
 
6
- <p align="right">Sponsored by</p>
7
- <p align="right"><a href="https://www.toptal.com/"><img src="https://www.toptal.com/assets/public/blocks/logo/big.png" alt="Toptal" width="105" height="34"></a></p>
8
-
9
6
  # Chewy
10
7
 
11
- Chewy is an ODM and wrapper for [the official Elasticsearch client](https://github.com/elastic/elasticsearch-ruby).
8
+ Chewy is an ODM (Object Document Mapper), built on top of the [the official Elasticsearch client](https://github.com/elastic/elasticsearch-ruby).
12
9
 
13
10
  ## Table of Contents
14
11
 
@@ -34,7 +31,7 @@ Chewy is an ODM and wrapper for [the official Elasticsearch client](https://gith
34
31
  * [Non-block notation](#non-block-notation)
35
32
  * [Designing your own strategies](#designing-your-own-strategies)
36
33
  * [Rails application strategies integration](#rails-application-strategies-integration)
37
- * [ActiveSupport::Notifications support](#activesupport-notifications-support)
34
+ * [ActiveSupport::Notifications support](#activesupportnotifications-support)
38
35
  * [NewRelic integration](#newrelic-integration)
39
36
  * [Search requests](#search-requests)
40
37
  * [Composing requests](#composing-requests)
@@ -51,13 +48,14 @@ Chewy is an ODM and wrapper for [the official Elasticsearch client](https://gith
51
48
  * [chewy:deploy](#chewydeploy)
52
49
  * [Parallelizing rake tasks](#parallelizing-rake-tasks)
53
50
  * [chewy:journal](#chewyjournal)
54
- * [Rspec integration](#rspec-integration)
51
+ * [RSpec integration](#rspec-integration)
55
52
  * [Minitest integration](#minitest-integration)
56
- * [TODO a.k.a coming soon](#todo-aka-coming-soon)
57
53
  * [Contributing](#contributing)
58
54
 
59
55
  ## Why Chewy?
60
56
 
57
+ In this section we'll cover why you might want to use Chewy instead of the official `elasticsearch-ruby` client gem.
58
+
61
59
  * Multi-model indices.
62
60
 
63
61
  Index classes are independent from ORM/ODM models. Now, implementing e.g. cross-model autocomplete is much easier. You can just define the index and work with it in an object-oriented style. You can define several types for index - one per indexed model.
@@ -76,10 +74,9 @@ Chewy is an ODM and wrapper for [the official Elasticsearch client](https://gith
76
74
 
77
75
  * Support for ActiveRecord, [Mongoid](https://github.com/mongoid/mongoid) and [Sequel](https://github.com/jeremyevans/sequel).
78
76
 
79
-
80
77
  ## Installation
81
78
 
82
- Add this line to your application's Gemfile:
79
+ Add this line to your application's `Gemfile`:
83
80
 
84
81
  gem 'chewy'
85
82
 
@@ -91,13 +88,29 @@ Or install it yourself as:
91
88
 
92
89
  $ gem install chewy
93
90
 
91
+ ## Compatibility
92
+
93
+ ### Ruby
94
+
95
+ Chewy is compatible with MRI 2.5-3.0¹.
96
+
97
+ > ¹ Ruby 3 is only supported with Rails 6.1
98
+
99
+ ### Elasticsearch
100
+
101
+ Chewy 5 is compatible with Elasticsearch 5. Future versions of Chewy will support Elasticsearch 6 and Elasticsearch 7.
102
+
94
103
  ## Usage
95
104
 
96
105
  ### Client settings
97
106
 
98
- There are two ways to configure the Chewy client: the `Chewy.settings` hash and `chewy.yml`
107
+ There are two ways to configure the Chewy client:
99
108
 
100
- You can create this file manually or run `rails g chewy:install`.
109
+ * via the hash `Chewy.settings`
110
+ * via the configuration file `chewy.yml`
111
+
112
+ You can create `chewy.yml` manually or run `rails g chewy:install` to
113
+ generate it.
101
114
 
102
115
  ```ruby
103
116
  # config/initializers/chewy.rb
@@ -129,25 +142,29 @@ Chewy.logger = Logger.new(STDOUT)
129
142
 
130
143
  See [config.rb](lib/chewy/config.rb) for more details.
131
144
 
132
- #### Aws Elastic Search
133
- If you would like to use AWS's ElasticSearch using an IAM user policy, you will need to sign your requests for the `es:*` action by injecting the appropriate headers passing a proc to `transport_options`.
145
+ #### AWS Elasticsearch
146
+
147
+ If you would like to use AWS's Elasticsearch using an IAM user policy, you will need to sign your requests for the `es:*` action by injecting the appropriate headers passing a proc to `transport_options`.
148
+ You'll need an additional gem for Faraday middleware: add `gem 'faraday_middleware-aws-sigv4'` to your Gemfile.
134
149
 
135
150
  ```ruby
136
- Chewy.settings = {
137
- host: 'http://my-es-instance-on-aws.us-east-1.es.amazonaws.com:80',
138
- transport_options: {
139
- headers: { content_type: 'application/json' },
140
- proc: -> (f) do
141
- f.request :aws_signers_v4,
142
- service_name: 'es',
143
- region: 'us-east-1',
144
- credentials: Aws::Credentials.new(
145
- ENV['AWS_ACCESS_KEY'],
146
- ENV['AWS_SECRET_ACCESS_KEY'])
147
- end
148
- }
151
+ require 'faraday_middleware/aws_sigv4'
152
+
153
+ Chewy.settings = {
154
+ host: 'http://my-es-instance-on-aws.us-east-1.es.amazonaws.com:80',
155
+ port: 80, # 443 for https host
156
+ transport_options: {
157
+ headers: { content_type: 'application/json' },
158
+ proc: -> (f) do
159
+ f.request :aws_sigv4,
160
+ service: 'es',
161
+ region: 'us-east-1',
162
+ access_key_id: ENV['AWS_ACCESS_KEY'],
163
+ secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
164
+ end
149
165
  }
150
- ```
166
+ }
167
+ ```
151
168
 
152
169
  ### Index definition
153
170
 
@@ -678,6 +695,11 @@ Chewy.strategy(:sidekiq) do
678
695
  end
679
696
  ```
680
697
 
698
+ The default queue name is `chewy`, you can customize it in settings: `sidekiq.queue_name`
699
+ ```
700
+ Chewy.settings[:sidekiq] = {queue: :low}
701
+ ```
702
+
681
703
  #### `:active_job`
682
704
 
683
705
  This does the same thing as `:atomic`, but using ActiveJob. This will inherit the ActiveJob configuration settings including the `active_job.queue_adapter` setting for the environment. Patch `Chewy::Strategy::ActiveJob::Worker` for index updates improving.
@@ -688,6 +710,11 @@ Chewy.strategy(:active_job) do
688
710
  end
689
711
  ```
690
712
 
713
+ The default queue name is `chewy`, you can customize it in settings: `active_job.queue_name`
714
+ ```
715
+ Chewy.settings[:active_job] = {queue: :low}
716
+ ```
717
+
691
718
  #### `:shoryuken`
692
719
 
693
720
  This does the same thing as `:atomic`, but asynchronously using shoryuken. Patch `Chewy::Strategy::Shoryuken::Worker` for index updates improving.
@@ -1061,7 +1088,7 @@ rake chewy:journal:apply["$(date -v-1H -u +%FT%TZ)"] # apply journaled changes f
1061
1088
  rake chewy:journal:apply["$(date -v-1H -u +%FT%TZ)",users] # apply journaled changes for the past hour on UsersIndex only
1062
1089
  ```
1063
1090
 
1064
- ### Rspec integration
1091
+ ### RSpec integration
1065
1092
 
1066
1093
  Just add `require 'chewy/rspec'` to your spec_helper.rb and you will get additional features: See [update_index.rb](lib/chewy/rspec/update_index.rb) for more details.
1067
1094
 
@@ -1082,12 +1109,6 @@ If you use `DatabaseCleaner` in your tests with [the `transaction` strategy](htt
1082
1109
  Chewy.use_after_commit_callbacks = !Rails.env.test?
1083
1110
  ```
1084
1111
 
1085
- ## TODO a.k.a coming soon:
1086
-
1087
- * Typecasting support
1088
- * update_all support
1089
- * Maybe, closer ORM/ODM integration, creating index classes implicitly
1090
-
1091
1112
  ## Contributing
1092
1113
 
1093
1114
  1. Fork it (http://github.com/toptal/chewy/fork)
@@ -1103,3 +1124,8 @@ Use the following Rake tasks to control the Elasticsearch cluster while developi
1103
1124
  rake elasticsearch:start # start Elasticsearch cluster on 9250 port for tests
1104
1125
  rake elasticsearch:stop # stop Elasticsearch
1105
1126
  ```
1127
+
1128
+ ## Copyright
1129
+
1130
+ Copyright (c) 2013-2021 Toptal, LLC. See [LICENSE.txt](LICENSE.txt) for
1131
+ further details.
data/chewy.gemspec CHANGED
@@ -5,8 +5,8 @@ require 'chewy/version'
5
5
  Gem::Specification.new do |spec| # rubocop:disable BlockLength
6
6
  spec.name = 'chewy'
7
7
  spec.version = Chewy::VERSION
8
- spec.authors = ['pyromaniac']
9
- spec.email = ['kinwizard@gmail.com']
8
+ spec.authors = ['Toptal, LLC', 'pyromaniac']
9
+ spec.email = ['open-source@toptal.com', 'kinwizard@gmail.com']
10
10
  spec.summary = 'Elasticsearch ODM client wrapper'
11
11
  spec.description = 'Chewy provides functionality for Elasticsearch index handling, documents import mappings and chainable query DSL'
12
12
  spec.homepage = 'https://github.com/toptal/chewy'
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec| # rubocop:disable BlockLength
22
22
  spec.add_development_dependency 'elasticsearch-extensions'
23
23
  spec.add_development_dependency 'rake'
24
24
  spec.add_development_dependency 'resque_spec'
25
- spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'rspec', '>= 3.7.0'
26
26
  spec.add_development_dependency 'rspec-collection_matchers'
27
27
  spec.add_development_dependency 'rspec-its'
28
28
  spec.add_development_dependency 'rubocop', '0.52.1'
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec| # rubocop:disable BlockLength
32
32
  spec.add_development_dependency 'method_source'
33
33
  spec.add_development_dependency 'unparser'
34
34
 
35
- spec.add_dependency 'activesupport', '>= 4.0'
35
+ spec.add_dependency 'activesupport', '>= 5.2'
36
36
  spec.add_dependency 'elasticsearch', '>= 2.0.0'
37
37
  spec.add_dependency 'elasticsearch-dsl'
38
38
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.2.0.rc1"
6
- gem "activesupport", "~> 5.2.0.rc1"
7
- gem "activejob", "~> 5.2.0.rc1"
5
+ gem "activerecord", "~> 5.2.0"
6
+ gem "activesupport", "~> 5.2.0"
7
+ gem "activejob", "~> 5.2.0"
8
8
  gem "resque", require: false
9
9
  gem "shoryuken", require: false
10
10
  gem "aws-sdk-sqs", require: false
@@ -12,5 +12,6 @@ gem "sidekiq", require: false
12
12
  gem "kaminari-core", "~> 1.1.0", require: false
13
13
  gem "will_paginate", require: false
14
14
  gem "parallel", require: false
15
+ gem 'rspec_junit_formatter', '~> 0.4.1'
15
16
 
16
17
  gemspec path: "../"
@@ -2,9 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.0"
6
- gem "activesupport", "~> 5.0.0"
7
- gem "activejob", "~> 5.0.0"
5
+ gem "mongoid", "~> 6.4.0"
6
+ gem "activesupport", "~> 5.2.0"
7
+ gem "activejob", "~> 5.2.0"
8
8
  gem "resque", require: false
9
9
  gem "shoryuken", require: false
10
10
  gem "aws-sdk-sqs", require: false
@@ -12,5 +12,6 @@ gem "sidekiq", require: false
12
12
  gem "kaminari-core", "~> 1.1.0", require: false
13
13
  gem "will_paginate", require: false
14
14
  gem "parallel", require: false
15
+ gem 'rspec_junit_formatter', '~> 0.4.1'
15
16
 
16
17
  gemspec path: "../"
@@ -2,9 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "mongoid", "~> 6.1.0"
6
- gem "activesupport", "~> 5.0.0"
7
- gem "activejob", "~> 5.0.0"
5
+ gem "activerecord", "~> 6.0.0"
6
+ gem "activesupport", "~> 6.0.0"
7
+ gem "activejob", "~> 6.0.0"
8
8
  gem "resque", require: false
9
9
  gem "shoryuken", require: false
10
10
  gem "aws-sdk-sqs", require: false
@@ -12,5 +12,6 @@ gem "sidekiq", require: false
12
12
  gem "kaminari-core", "~> 1.1.0", require: false
13
13
  gem "will_paginate", require: false
14
14
  gem "parallel", require: false
15
+ gem 'rspec_junit_formatter', '~> 0.4.1'
15
16
 
16
17
  gemspec path: "../"
@@ -2,9 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.1.0"
6
- gem "activesupport", "~> 5.1.0"
7
- gem "activejob", "~> 5.1.0"
5
+ gem "activerecord", "~> 6.1.0"
6
+ gem "activesupport", "~> 6.1.0"
7
+ gem "activejob", "~> 6.1.0"
8
8
  gem "resque", require: false
9
9
  gem "shoryuken", require: false
10
10
  gem "aws-sdk-sqs", require: false
@@ -12,5 +12,8 @@ gem "sidekiq", require: false
12
12
  gem "kaminari-core", "~> 1.1.0", require: false
13
13
  gem "will_paginate", require: false
14
14
  gem "parallel", require: false
15
+ gem 'rspec_junit_formatter', '~> 0.4.1'
16
+
17
+ eval(File.read('gemfiles/ruby3.gemfile'), nil, 'gemfiles/ruby3.gemfile') if RUBY_VERSION >= '3.0.0'
15
18
 
16
19
  gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # kwargs support was added here:
2
+ # https://github.com/rspec/rspec-mocks/blob/main/lib/rspec/mocks/method_double.rb#L66
3
+ # but this change was not released yet so for the time being use main branch
4
+ gem 'rspec', github: 'rspec/rspec', branch: 'main'
5
+ gem 'rspec-core', github: 'rspec/rspec-core', branch: 'main'
6
+ gem 'rspec-expectations', github: 'rspec/rspec-expectations', branch: 'main'
7
+ gem 'rspec-mocks', github: 'rspec/rspec-mocks', branch: 'main'
8
+ gem 'rspec-support', github: 'rspec/rspec-support', branch: 'main'
9
+ # extracted from stdlib
10
+ gem 'rexml'
@@ -79,7 +79,7 @@ end
79
79
  require 'bigdecimal'
80
80
  class BigDecimal
81
81
  begin
82
- BigDecimal.new('4.56').dup
82
+ BigDecimal('4.56').dup
83
83
 
84
84
  def duplicable?
85
85
  true
@@ -7,7 +7,7 @@ module Chewy
7
7
  def initialize(name, value: nil, **options)
8
8
  @name = name.to_sym
9
9
  @options = {}
10
- update_options!(options)
10
+ update_options!(**options)
11
11
  @value = value
12
12
  @children = []
13
13
  end
@@ -6,8 +6,8 @@ module Chewy
6
6
  attr_reader :parent
7
7
  attr_reader :parent_id
8
8
 
9
- def initialize(*)
10
- super
9
+ def initialize(name, **options)
10
+ super(name, **options)
11
11
 
12
12
  @value ||= -> { self }
13
13
  @dynamic_templates = []