meilisearch-rails 0.8.1 → 0.9.0

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: 95c22d57895ceb454d6026064d0e27d4f0abcba6cf6e8d30171bde564174bf83
4
- data.tar.gz: 45e490dae97786d644cbd0c4bd3f63e84d02b7cffc3b4cb1fc5f393c53a61b80
3
+ metadata.gz: 25c4de2cc918a39c265d31b9191302e42e66a80f1b9d4b9e07c89074bb9e8eec
4
+ data.tar.gz: d6572c3e463044c8401d0916aed8c396ac7559e980e5be03ba874af9d10ab54b
5
5
  SHA512:
6
- metadata.gz: 9cf32c4a4a74f4c29be2e89ed97fc592de962402001473ddfb0a9cbb8d8c258aec87f2ccca18efce1db338e403065df08159e6f31d96d83060cf0815d2c0c2e6
7
- data.tar.gz: cdcbc8944ab5be9ddf5e8b60a56620ab843488a8699b81e5df152127d8ce7dab79ab1bfc1430680d3f15b472f121196b248c69fae30c67d9fc405b421da1c010
6
+ metadata.gz: bf2356509509b70d9ebe00715faa680cd76b58802643712f5447d8d2de93aaae934f7b0048da2eaeb69fcee549654d5e80e24be5a5e71ee2a92c3b5a2c6a5280
7
+ data.tar.gz: 1f99790e054f917bc3c79df3eacb0471e7883dd414a8e03631d1382ef9b186eb53dffb2c1178e4625577231a03534c9348c4114f93b80655e9f242c60bf94de4
data/README.md CHANGED
@@ -62,7 +62,7 @@ To learn more about Meilisearch, check out our [Documentation](https://docs.meil
62
62
 
63
63
  ## 🤖 Compatibility with Meilisearch
64
64
 
65
- This package only guarantees the compatibility with the [version v1.0.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v1.0.0).
65
+ This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-rails/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.
66
66
 
67
67
  ## 🔧 Installation <!-- omit in toc -->
68
68
 
@@ -185,6 +185,7 @@ class Book < ApplicationRecord
185
185
  attributes_to_highlight ['*']
186
186
  attributes_to_crop [:description]
187
187
  crop_length 10
188
+ faceting max_values_per_facet: 2000
188
189
  pagination max_total_hits: 1000
189
190
  end
190
191
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module MeiliSearch
4
4
  module Rails
5
- VERSION = '0.8.1'
5
+ VERSION = '0.9.0'
6
6
 
7
7
  def self.qualified_version
8
8
  "Meilisearch Rails (v#{VERSION})"
@@ -60,9 +60,11 @@ module MeiliSearch
60
60
  attributesToCrop
61
61
  cropLength
62
62
  pagination
63
+ faceting
64
+ typoTolerance
63
65
  ].freeze
64
66
 
65
- CAMELIZE_OPTIONS = %i[pagination].freeze
67
+ CAMELIZE_OPTIONS = %i[pagination faceting typoTolerance].freeze
66
68
 
67
69
  OPTIONS.each do |option|
68
70
  define_method option do |value|
@@ -198,6 +200,10 @@ module MeiliSearch
198
200
  instance_variable_get("@#{name}")
199
201
  end
200
202
 
203
+ def camelize_keys(hash)
204
+ hash.transform_keys { |key| key.to_s.camelize(:lower) }
205
+ end
206
+
201
207
  def to_settings
202
208
  settings = {}
203
209
  OPTIONS.each do |k|
@@ -205,7 +211,12 @@ module MeiliSearch
205
211
  next if v.nil?
206
212
 
207
213
  settings[k] = if CAMELIZE_OPTIONS.include?(k) && v.is_a?(Hash)
208
- v.transform_keys { |key| key.to_s.camelize(:lower) }
214
+ v = camelize_keys(v)
215
+
216
+ # camelize keys of nested hashes
217
+ v.each do |key, value|
218
+ v[key] = camelize_keys(value) if value.is_a?(Hash)
219
+ end
209
220
  else
210
221
  v
211
222
  end
@@ -587,13 +598,6 @@ module MeiliSearch
587
598
  end
588
599
 
589
600
  module AdditionalMethods
590
- def self.extended(base)
591
- class << base
592
- alias_method :raw_answer, :ms_raw_answer unless method_defined? :raw_answer
593
- alias_method :facets_distribution, :ms_facets_distribution unless method_defined? :facets_distribution
594
- end
595
- end
596
-
597
601
  def ms_raw_answer
598
602
  @ms_json
599
603
  end
@@ -602,6 +606,9 @@ module MeiliSearch
602
606
  @ms_json['facetDistribution']
603
607
  end
604
608
 
609
+ alias raw_answer ms_raw_answer unless method_defined? :raw_answer
610
+ alias facets_distribution ms_facets_distribution unless method_defined? :facets_distribution
611
+
605
612
  private
606
613
 
607
614
  def ms_init_raw_answer(json)
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.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-08 00:00:00.000000000 Z
11
+ date: 2023-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: meilisearch