meilisearch-rails 0.1.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd9fd3dfd135348e2daea1797697e8b879f08705e2878b3683e59b28d51676c7
4
- data.tar.gz: 7226660145964ae88bac72436690aad1a890e76cacd8d4c3fa1e1d3a1d3036e0
3
+ metadata.gz: dff716ea4a13c0f64718942f4988550a36076ae5dc52ac8ec7282000d116a99d
4
+ data.tar.gz: 1346eb18ddb24bf718693b7b3efa89d4b0084ecffe9f7ccae1d71956b3b8bf56
5
5
  SHA512:
6
- metadata.gz: 66a1950a5b9bf12469f40053ee01bae86f1379f8a6437de2dff7cc65e55ef64ead442cccc23b39a9d609b4693a1ced987ae51136671fe2d1a53f494fa1ee66dd
7
- data.tar.gz: 1e8e5b33d6cb193a432ae09c10f9611ff709a2e9d744fad40e069c7098f39db582b250e8d33288b2beb4ccc72d740a6b9e6f3b439163b6d271e250897e836ea8
6
+ metadata.gz: 38e1657c75e4eec945502ead72001ba56dc194d3ce5217e65f40abc49de34312087aa30d401d342a15c4c0701f0d41d49faf8c94aef5cc40d79ed9bdc345f414
7
+ data.tar.gz: 2cd31c3b6b70fb4d2c38977870ab28256de22422c410280e7615e11dfe64dd8eaa98295c7bdf553655b427837b8864ee60930a0aafa39e8f1272af34210c0479
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'json', '~> 2.5', '>= 2.5.1'
4
- gem 'meilisearch', '~> 0.15.3'
4
+ gem 'meilisearch', '~> 0.16.0'
5
5
 
6
6
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
7
7
  gem 'rubysl', '~> 2.0', :platform => :rbx
@@ -27,4 +27,5 @@ group :test do
27
27
  gem 'will_paginate', '>= 2.3.15'
28
28
  gem 'kaminari'
29
29
  gem 'dotenv', '~> 2.7', '>= 2.7.6'
30
+ gem 'byebug'
30
31
  end
data/README.md CHANGED
@@ -65,7 +65,7 @@ To learn more about MeiliSearch, check out our [Documentation](https://docs.meil
65
65
 
66
66
  ## 🤖 Compatibility with MeiliSearch
67
67
 
68
- This package only guarantees the compatibility with the [version v0.20.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.20.0).
68
+ This package only guarantees the compatibility with the [version v0.21.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.21.0).
69
69
 
70
70
  ## 🔧 Installation
71
71
 
@@ -104,8 +104,8 @@ Create a new file `config/initializers/meilisearch.rb` to setup your `MEILISEARC
104
104
 
105
105
  ```ruby
106
106
  MeiliSearch.configuration = {
107
- meilisearch_host: 'YourMeiliSearchHost',
108
- meilisearch_api_key: 'YourMeiliSearchAPIKey',
107
+ meilisearch_host: 'YourMeiliSearchHost',
108
+ meilisearch_api_key: 'YourMeiliSearchAPIKey',
109
109
  }
110
110
  ```
111
111
 
@@ -126,6 +126,8 @@ class Book < ActiveRecord::Base
126
126
  end
127
127
  ```
128
128
 
129
+ ⚠️ Note that even if you want to use all the default options, you must declare an empty `meilisearch` block in your model.
130
+
129
131
  #### Basic Backend Search <!-- omit in toc -->
130
132
 
131
133
  We **strongly recommend the use of front-end search** through our [JavaScript API Client](https://github.com/meilisearch/meilisearch-js/) or [Instant Meilisearch plugin](https://github.com/meilisearch/instant-meilisearch)
@@ -143,15 +145,18 @@ end
143
145
 
144
146
  #### Backend Pagination <!-- omit in toc -->
145
147
 
146
- We support both [kaminari](https://github.com/amatsuda/kaminari) and [will_paginate](https://github.com/mislav/will_paginate).
148
+ This gem supports:
149
+ - [kaminari](https://github.com/amatsuda/kaminari)
150
+ - [pagy](https://github.com/ddnexus/pagy)
151
+ - [will_paginate](https://github.com/mislav/will_paginate).
147
152
 
148
153
  Specify the `:pagination_backend` in the configuration file:
149
154
 
150
155
  ```ruby
151
156
  MeiliSearch.configuration = {
152
- meilisearch_host: 'YourMeiliSearchHost',
153
- meilisearch_api_key: 'YourMeiliSearchAPIKey',
154
- pagination_backend: :kaminari #:will_paginate
157
+ meilisearch_host: 'YourMeiliSearchHost',
158
+ meilisearch_api_key: 'YourMeiliSearchAPIKey',
159
+ pagination_backend: :kaminari #:will_paginate
155
160
  }
156
161
  ```
157
162
 
@@ -178,7 +183,21 @@ The **number of hits per page defaults to 20**, you can customize it by adding t
178
183
  Book.search('harry potter', hitsPerPage: 10)
179
184
  ```
180
185
 
181
- ## ⚙️ Settings
186
+ #### Extra Configuration <!-- omit in toc -->
187
+
188
+ Requests made to MeiliSearch may timeout and retry. To adapt the behavior to
189
+ your needs, you can change the parameters during configuration:
190
+
191
+ ```ruby
192
+ MeiliSearch.configuration = {
193
+ meilisearch_host: 'YourMeiliSearchHost',
194
+ meilisearch_api_key: 'YourMeiliSearchAPIKey',
195
+ timeout: 2,
196
+ max_retries: 1,
197
+ }
198
+ ```
199
+
200
+ ## ⚙️ Settings
182
201
 
183
202
  You can configure the index settings by adding them inside the `meilisearch` block as shown below:
184
203
 
@@ -187,22 +206,22 @@ class Book < ApplicationRecord
187
206
  include MeiliSearch
188
207
 
189
208
  meilisearch do
190
- searchableAttributes ['title', 'author', 'publisher', 'description']
191
- attributesForFaceting ['genre']
192
- rankingRules [
193
- "proximity",
194
- "typo",
195
- "words",
196
- "attribute",
197
- "wordsPosition",
198
- "exactness",
199
- "desc(publication_year)"
209
+ searchable_attributes [:title, :author, :publisher, :description]
210
+ filterable_attributes [:genre]
211
+ ranking_rules [
212
+ 'proximity',
213
+ 'typo',
214
+ 'words',
215
+ 'attribute',
216
+ 'exactness',
217
+ 'desc(publication_year)'
200
218
  ]
201
219
  synonyms nyc: ['new york']
202
- // The following parameters are applied when calling the search() method:
203
- attributesToHighlight ['*']
204
- attributesToCrop ['description']
205
- cropLength 10
220
+
221
+ # The following parameters are applied when calling the search() method:
222
+ attributes_to_highlight ['*']
223
+ attributes_to_crop [:description]
224
+ crop_length 10
206
225
  end
207
226
  end
208
227
  ```
@@ -214,9 +233,10 @@ Check the dedicated section of the documentation, for more information on the [s
214
233
  All the supported options are described in the [search parameters](https://docs.meilisearch.com/reference/features/search_parameters.html) section of the documentation.
215
234
 
216
235
  ```ruby
217
- Book.search('Harry', { filters: 'author = J. K. Rowling' })
236
+ Book.search('Harry', attributesToHighlight: ['*'])
218
237
  ```
219
- 👉 Don't forget that `attributesToHighlight`, `attributesToCrop`, and `cropLength` can be set up in the `meilisearch` block of your model.
238
+ 👉 Don't forget that `attributes_to_highlight`, `attributes_to_crop`, and
239
+ `crop_length` can be set up in the `meilisearch` block of your model.
220
240
 
221
241
  ## 🪛 Options
222
242
 
@@ -224,12 +244,13 @@ Book.search('Harry', { filters: 'author = J. K. Rowling' })
224
244
 
225
245
  #### Custom index_uid
226
246
 
227
- By default, the **index_uid** will be the class name, e.g. `Book`. You can customize the index_uid by using the `index_uid` option.
247
+ By default, the **index_uid** will be the class name, e.g. `Book`. You can customize the index_uid by using the `index_uid:` option.
228
248
 
229
249
  ```ruby
230
250
  class Book < ActiveRecord::Base
231
251
  include MeiliSearch
232
- meilisearch :index_uid => 'MyCustomUID' do
252
+
253
+ meilisearch index_uid: 'MyCustomUID' do
233
254
  end
234
255
  end
235
256
  ```
@@ -241,6 +262,7 @@ You can suffix the index UID with the current Rails environment using the follow
241
262
  ```ruby
242
263
  class Book < ActiveRecord::Base
243
264
  include MeiliSearch
265
+
244
266
  meilisearch per_environment: true do # The index UID will be "Book_#{Rails.env}"
245
267
  end
246
268
  end
@@ -261,13 +283,13 @@ class Author < ApplicationRecord
261
283
  meilisearch do
262
284
  attribute :first_name, :last_name
263
285
  attribute :full_name do
264
- '#{first_name} #{last_name}'
286
+ "#{first_name} #{last_name}"
265
287
  end
266
288
  add_attribute :full_name_reversed
267
289
  end
268
290
 
269
291
  def full_name_reversed
270
- '#{last_name} #{first_name}'
292
+ "#{last_name} #{first_name}"
271
293
  end
272
294
 
273
295
  def will_save_change_to_full_name?
@@ -282,27 +304,28 @@ end
282
304
 
283
305
  #### Custom primary key
284
306
 
285
- By default, the `primary key` is based on your record's id. You can change this behavior specifying the `:primary_key` option.
307
+ By default, the primary key is based on your record's id. You can change this behavior by specifying the `primary_key:` option.
286
308
 
287
309
  Note that the primary key must have a **unique value**.
288
310
 
289
311
  ```ruby
290
312
  class Book < ActiveRecord::Base
291
313
  include MeiliSearch
292
- meilisearch :primary_key => 'ISBN' do
314
+
315
+ meilisearch primary_key: 'ISBN' do
293
316
  end
294
317
  end
295
318
  ```
296
319
  #### Conditional indexing
297
320
 
298
- You can control if a record must be indexed by using the `:if` or `:unless` options.<br>
321
+ You can control if a record must be indexed by using the `if:` or `unless:` options.<br>
299
322
  As soon as you use those constraints, `add_documents` and `delete_documents` calls will be performed in order to keep the index synced with the DB. To prevent this behavior, you can create a `will_save_change_to_#{attr_name}?` method.
300
323
 
301
324
  ```ruby
302
325
  class Book < ActiveRecord::Base
303
326
  include MeiliSearch
304
327
 
305
- meilisearch :if published?, :unless premium? do
328
+ meilisearch if: :published?, unless: :premium? do
306
329
  end
307
330
 
308
331
  def published?
@@ -314,7 +337,7 @@ class Book < ActiveRecord::Base
314
337
  end
315
338
 
316
339
  def will_save_change_to_published?
317
- # return true only if you know that the 'published' state changed
340
+ # return true only if you know that the 'published' state changed
318
341
  end
319
342
  end
320
343
  ```
@@ -324,7 +347,6 @@ You can index a record in several indexes using the `add_index` option:
324
347
 
325
348
  ```ruby
326
349
  class Book < ActiveRecord::Base
327
-
328
350
  include MeiliSearch
329
351
 
330
352
  PUBLIC_INDEX_UID = 'Books'
@@ -332,17 +354,17 @@ class Book < ActiveRecord::Base
332
354
 
333
355
  # store all books in index 'SECURED_INDEX_UID'
334
356
  meilisearch index_uid: SECURED_INDEX_UID do
335
- searchableAttributes [:title, :author]
357
+ searchable_attributes [:title, :author]
336
358
 
337
359
  # store all 'public' (released and not premium) books in index 'PUBLIC_INDEX_UID'
338
360
  add_index PUBLIC_INDEX_UID, if: :public? do
339
- searchableAttributes [:title, :author]
361
+ searchable_attributes [:title, :author]
340
362
  end
341
363
  end
342
364
 
343
365
  private
344
366
  def public?
345
- released && !premium
367
+ released? && !premium?
346
368
  end
347
369
  end
348
370
  ```
@@ -394,18 +416,31 @@ end
394
416
 
395
417
  In this case you can bypass loading the record from **ActiveRecord** and just communicate with the index directly.
396
418
 
419
+ With **ActiveJob**:
420
+
397
421
  ```ruby
422
+ class Book < ActiveRecord::Base
423
+ include MeiliSearch
424
+
425
+ meilisearch enqueue: :trigger_job do
426
+ attribute :title, :author, :description
427
+ end
428
+
429
+ def self.trigger_job(record, remove)
430
+ MyActiveJob.perform_later(record.id, remove)
431
+ end
432
+ end
433
+
398
434
  class MyActiveJob < ApplicationJob
399
435
  def perform(id, remove)
400
436
  if remove
401
- # the record has likely already been removed from your database so we cannot
402
- # use ActiveRecord#find to load it
403
- # We access the underlying MeiliSearch index object
437
+ # The record has likely already been removed from your database so we cannot
438
+ # use ActiveRecord#find to load it.
439
+ # We access the underlying MeiliSearch index object.
404
440
  Book.index.delete_document(id)
405
441
  else
406
- # the record should be present
407
- c = Book.find(id)
408
- c.index!
442
+ # The record should be present.
443
+ Book.find(id).index!
409
444
  end
410
445
  end
411
446
  end
@@ -429,14 +464,13 @@ end
429
464
  class MySidekiqWorker
430
465
  def perform(id, remove)
431
466
  if remove
432
- # the record has likely already been removed from your database so we cannot
433
- # use ActiveRecord#find to load it
434
- # We access the underlying MeiliSearch index object
435
- index = Book.index.delete_document(id)
467
+ # The record has likely already been removed from your database so we cannot
468
+ # use ActiveRecord#find to load it.
469
+ # We access the underlying MeiliSearch index object.
470
+ Book.index.delete_document(id)
436
471
  else
437
- # the record should be present
438
- c = Contact.find(id)
439
- c.index!
472
+ # The record should be present.
473
+ Book.find(id).index!
440
474
  end
441
475
  end
442
476
  end
@@ -466,7 +500,7 @@ end
466
500
 
467
501
  Extend a change to a related record.
468
502
 
469
- **With Active Record**, you'll need to use `touch` and `after_touch`.
503
+ **With ActiveRecord**, you'll need to use `touch` and `after_touch`.
470
504
 
471
505
  ```ruby
472
506
  class Author < ActiveRecord::Base
@@ -546,7 +580,7 @@ You can strip all HTML tags from your attributes with the `sanitize` option.
546
580
  class Book < ActiveRecord::Base
547
581
  include MeiliSearch
548
582
 
549
- meilisearch :sanitize => true do
583
+ meilisearch sanitize: true do
550
584
  end
551
585
  end
552
586
  ```
@@ -559,7 +593,7 @@ You can force the UTF-8 encoding of all your attributes using the `force_utf8_en
559
593
  class Book < ActiveRecord::Base
560
594
  include MeiliSearch
561
595
 
562
- meilisearch :force_utf8_encoding => true do
596
+ meilisearch force_utf8_encoding: true do
563
597
  end
564
598
  end
565
599
  ```
@@ -568,7 +602,7 @@ end
568
602
 
569
603
  #### Indexing & deletion
570
604
 
571
- You can manually index a record by using the `index!` instance method and remove it by using the `remove_from_index!` instance method
605
+ You can manually index a record by using the `index!` instance method and remove it by using the `remove_from_index!` instance method.
572
606
 
573
607
  ```ruby
574
608
  book = Book.create!(title: 'The Little Prince', author: 'Antoine de Saint-Exupéry')
@@ -603,7 +637,6 @@ index = Book.index
603
637
 
604
638
  ### Development & testing
605
639
 
606
-
607
640
  #### Exceptions
608
641
 
609
642
  You can disable exceptions that could be raised while trying to reach MeiliSearch's API by using the `raise_on_failure` option:
@@ -612,14 +645,16 @@ You can disable exceptions that could be raised while trying to reach MeiliSearc
612
645
  class Book < ActiveRecord::Base
613
646
  include MeiliSearch
614
647
 
615
- # only raise exceptions in development environment
616
- meilisearch :raise_on_failure => Rails.env.development? do
648
+ # Only raise exceptions in development environment.
649
+ meilisearch raise_on_failure: Rails.env.development? do
617
650
  end
618
651
  end
619
652
  ```
620
653
 
621
654
  #### Testing
655
+
622
656
  ##### Synchronous testing
657
+
623
658
  You can force indexing and removing to be synchronous by setting the following option:
624
659
 
625
660
  ```ruby
@@ -649,7 +684,8 @@ You can temporarily disable auto-indexing using the without_auto_index scope:
649
684
 
650
685
  ```ruby
651
686
  Book.without_auto_index do
652
- 1.upto(10000) { Book.create! attributes } # inside this block, auto indexing task will not run.
687
+ # Inside this block, auto indexing task will not run.
688
+ 1.upto(10000) { Book.create! attributes }
653
689
  end
654
690
  ```
655
691
 
@@ -9,7 +9,11 @@ module MeiliSearch
9
9
  end
10
10
 
11
11
  def client
12
- ::MeiliSearch::Client.new(@@configuration[:meilisearch_host], @@configuration[:meilisearch_api_key])
12
+ ::MeiliSearch::Client.new(
13
+ configuration[:meilisearch_host],
14
+ configuration[:meilisearch_api_key],
15
+ configuration.slice(:timeout, :max_retries)
16
+ )
13
17
  end
14
18
  end
15
19
  end
@@ -9,7 +9,11 @@ module MeiliSearch
9
9
  class Kaminari < ::Kaminari::PaginatableArray
10
10
 
11
11
  def initialize(array, options)
12
- super(array, options)
12
+ if RUBY_VERSION >= '3'
13
+ super(array, **options)
14
+ else
15
+ super(array, options)
16
+ end
13
17
  end
14
18
 
15
19
  def limit(num)
@@ -25,12 +29,12 @@ module MeiliSearch
25
29
  class << self
26
30
  def create(results, total_hits, options = {})
27
31
  offset = ((options[:page] - 1) * options[:per_page])
28
- array = new results, :limit => options[:per_page], :offset => offset, :total_count => total_hits
32
+ array = new results, limit: options[:per_page], offset: offset, total_count: total_hits
29
33
  if array.empty? and !results.empty?
30
34
  # since Kaminari 0.16.0, you need to pad the results with nil values so it matches the offset param
31
35
  # otherwise you'll get an empty array: https://github.com/amatsuda/kaminari/commit/29fdcfa8865f2021f710adaedb41b7a7b081e34d
32
36
  results = ([nil] * offset) + results
33
- array = new results, :offset => offset, :limit => options[:per_page], :total_count => total_hits
37
+ array = new results, offset: offset, limit: options[:per_page], total_count: total_hits
34
38
  end
35
39
  array
36
40
  end
@@ -7,7 +7,8 @@ module MeiliSearch
7
7
  elsif Rails.application
8
8
  Rails.application.eager_load!
9
9
  end
10
- MeiliSearch.instance_variable_get :@included_in
10
+ klasses = MeiliSearch.instance_variable_get(:@included_in)
11
+ (klasses + klasses.map{ |klass| klass.descendants }.flatten).uniq
11
12
  end
12
13
 
13
14
  def clear_all_indexes
@@ -26,7 +27,7 @@ module MeiliSearch
26
27
  klasses.each do |klass|
27
28
  puts klass
28
29
  puts "Reindexing #{klass.count} records..."
29
- klass.ms_reindex
30
+ klass.ms_reindex!
30
31
  end
31
32
  end
32
33
 
@@ -1,3 +1,3 @@
1
1
  module MeiliSearch
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -52,16 +52,25 @@ module MeiliSearch
52
52
 
53
53
  # MeiliSearch settings
54
54
  OPTIONS = [
55
- :searchableAttributes, :attributesForFaceting, :displayedAttributes, :distinctAttribute,
56
- :synonyms, :stopWords, :rankingRules,
55
+ :searchableAttributes,
56
+ :filterableAttributes,
57
+ :displayedAttributes,
58
+ :distinctAttribute,
59
+ :synonyms,
60
+ :stopWords,
61
+ :rankingRules,
57
62
  :attributesToHighlight,
58
- :attributesToCrop, :cropLength
63
+ :attributesToCrop,
64
+ :cropLength,
59
65
  ]
60
66
 
61
- OPTIONS.each do |k|
62
- define_method k do |v|
63
- instance_variable_set("@#{k}", v)
67
+ OPTIONS.each do |option|
68
+ define_method option do |value|
69
+ instance_variable_set("@#{option}", value)
64
70
  end
71
+
72
+ underscored_name = option.to_s.gsub(/(.)([A-Z])/, '\1_\2').downcase
73
+ alias_method underscored_name, option if underscored_name != option
65
74
  end
66
75
 
67
76
  def initialize(options, &block)
@@ -315,7 +324,7 @@ module MeiliSearch
315
324
 
316
325
  def meilisearch(options = {}, &block)
317
326
  self.meilisearch_settings = IndexSettings.new(options, &block)
318
- self.meilisearch_options = { :type => ms_full_const_get(model_name.to_s), :per_page => meilisearch_settings.get_setting(:hitsPerPage) || 20, :page => 1 }.merge(options)
327
+ self.meilisearch_options = { type: ms_full_const_get(model_name.to_s), per_page: meilisearch_settings.get_setting(:hitsPerPage) || 20, page: 1 }.merge(options)
319
328
 
320
329
  attr_accessor :formatted
321
330
 
@@ -552,8 +561,6 @@ module MeiliSearch
552
561
  params[:cropLength] = meilisearch_settings.get_setting(:cropLength) if !meilisearch_settings.get_setting(:cropLength).nil?
553
562
  end
554
563
  index = ms_index(index_uid)
555
- # index = ms_index(ms_index_uid)
556
- # index.search(q, Hash[params.map { |k,v| [k.to_s, v.to_s] }])
557
564
  index.search(q, Hash[params.map { |k,v| [k, v] }])
558
565
  end
559
566
 
@@ -590,14 +597,6 @@ module MeiliSearch
590
597
  params[:limit] = 200
591
598
  end
592
599
 
593
- if !meilisearch_settings.get_setting(:attributesToHighlight).nil?
594
- params[:attributesToHighlight] = meilisearch_settings.get_setting(:attributesToHighlight)
595
- end
596
-
597
- if !meilisearch_settings.get_setting(:attributesToCrop).nil?
598
- params[:attributesToCrop] = meilisearch_settings.get_setting(:attributesToCrop)
599
- params[:cropLength] = meilisearch_settings.get_setting(:cropLength) if !meilisearch_settings.get_setting(:cropLength).nil?
600
- end
601
600
  # Returns raw json hits as follows:
602
601
  # {"hits"=>[{"id"=>"13", "href"=>"apple", "name"=>"iphone"}], "offset"=>0, "limit"=>|| 20, "nbHits"=>1, "exhaustiveNbHits"=>false, "processingTimeMs"=>0, "query"=>"iphone"}
603
602
  json = ms_raw_search(q, params)
@@ -632,7 +631,7 @@ module MeiliSearch
632
631
  hits_per_page ||= 20
633
632
  page ||= 1
634
633
 
635
- res = MeiliSearch::Pagination.create(results, total_hits, meilisearch_options.merge({ :page => page , :per_page => hits_per_page }))
634
+ res = MeiliSearch::Pagination.create(results, total_hits, meilisearch_options.merge({ page: page , per_page: hits_per_page }))
636
635
  res.extend(AdditionalMethods)
637
636
  res.send(:ms_init_raw_answer, json)
638
637
  res
@@ -823,7 +822,7 @@ module MeiliSearch
823
822
 
824
823
  def ms_find_in_batches(batch_size, &block)
825
824
  if (defined?(::ActiveRecord) && ancestors.include?(::ActiveRecord::Base)) || respond_to?(:find_in_batches)
826
- find_in_batches(:batch_size => batch_size, &block)
825
+ find_in_batches(batch_size: batch_size, &block)
827
826
  elsif defined?(::Sequel) && self < Sequel::Model
828
827
  dataset.extension(:pagination).each_page(batch_size, &block)
829
828
  else
@@ -41,6 +41,6 @@ Gem::Specification.new do |s|
41
41
  s.licenses = ["MIT"]
42
42
  s.require_paths = ["lib"]
43
43
  s.summary = "MeiliSearch integration for Ruby on Rails."
44
- s.add_dependency(%q<json>, [">= 1.5.1"])
45
- s.add_dependency(%q<meilisearch>, [">= 0.15.3"])
44
+ s.add_dependency("json", [">= 1.5.1"])
45
+ s.add_dependency("meilisearch", [">= 0.15.4"])
46
46
  end
data/spec/spec_helper.rb CHANGED
@@ -18,7 +18,7 @@ Thread.current[:meilisearch_hosts] = nil
18
18
 
19
19
  RSpec.configure do |c|
20
20
  c.mock_with :rspec
21
- c.filter_run :focus => true
21
+ c.filter_run focus: true
22
22
  c.run_all_when_everything_filtered = true
23
23
  c.formatter = 'documentation'
24
24
 
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
 
3
- MeiliSearch.configuration = { :meilisearch_host => ENV['MEILISEARCH_HOST'], :meilisearch_api_key => ENV['MEILISEARCH_API_KEY'] }
3
+ MeiliSearch.configuration = { meilisearch_host: ENV['MEILISEARCH_HOST'], meilisearch_api_key: ENV['MEILISEARCH_API_KEY'] }
4
4
 
5
5
  describe MeiliSearch::Utilities do
6
6
 
@@ -17,6 +17,12 @@ describe MeiliSearch::Utilities do
17
17
 
18
18
  meilisearch
19
19
  end
20
+
21
+ class DummyChild < Dummy
22
+ end
23
+
24
+ class DummyGrandChild < DummyChild
25
+ end
20
26
  end
21
27
 
22
28
  after(:each) do
@@ -24,7 +30,7 @@ describe MeiliSearch::Utilities do
24
30
  end
25
31
 
26
32
  it "should get the models where MeiliSearch module was included" do
27
- (MeiliSearch::Utilities.get_model_classes - [Dummy]).should == []
33
+ (MeiliSearch::Utilities.get_model_classes - [Dummy, DummyChild, DummyGrandChild]).should == []
28
34
  end
29
35
 
30
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meilisearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-09 00:00:00.000000000 Z
11
+ date: 2021-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.15.3
33
+ version: 0.15.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.15.3
40
+ version: 0.15.4
41
41
  description: MeiliSearch integration for Ruby on Rails. See https://github.com/meilisearch/MeiliSearch
42
42
  email: bonjour@meilisearch.com
43
43
  executables: []