meilisearch-rails 0.9.1 → 0.10.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcc344e4fd67e6c871a2bd17a90f9f2ddfd621b455ab25ea4925bd97c797db97
4
- data.tar.gz: 6849bd317a751754beab3642c29405d6022da03cb1266fd0b77c6c12e57f5765
3
+ metadata.gz: 5533b797c2c1df4ba52eee7e73d68c81b8a329353b896d7e5d6b17560f2b9c6d
4
+ data.tar.gz: c65d9fc11a89d2d054392b44c8858b59429e84fc707f569ba7d3888c4685c0df
5
5
  SHA512:
6
- metadata.gz: a575ccd86876ac883955ec6f660635da5f9927802253d011131e7c16a3e681bd9942740785d16c117cd01e2e919ca036ab7439f84c8d6da609df95dcc3e95afe
7
- data.tar.gz: a03067f0ab9e8acfad6ace43421c80e332f118a16b15f8642537e0cc4749aaa04caf7cd33a19064560d0864614cd56807b933b1a06a56f6ceb9a070d4468b2d5
6
+ metadata.gz: f86c37174ef35dce271cc4dbd0ef51355828e9c1bb16c266b019883afc7fb1856f73b4d6dd61982c74e41c716122684d7307a31ee86d0015b3538bbc3c3f6616
7
+ data.tar.gz: 88038b5cae1f6611e4793cf5051f03f88e9c01683bde793c38134340eb68126b38d3784b3e73bf7b79b07e0bbdf9d44d08c08938abee35b7a950728f6fc4c43b
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ group :development do
13
13
  end
14
14
 
15
15
  group :test do
16
- rails_version = ENV['RAILS_VERSION'] || '5.2'
16
+ rails_version = ENV['RAILS_VERSION'] || '6.1'
17
17
  sequel_version = ENV['SEQUEL_VERSION'] ? "~> #{ENV['SEQUEL_VERSION']}" : '>= 4.0'
18
18
 
19
19
  gem 'active_model_serializers'
@@ -31,6 +31,7 @@ group :test do
31
31
  gem 'jdbc-sqlite3', platform: :jruby
32
32
  gem 'rspec', '~> 3.0'
33
33
  gem 'simplecov', require: 'false'
34
+ gem 'codecov', require: 'false'
34
35
  gem 'threads'
35
36
 
36
37
  gem 'byebug'
data/README.md CHANGED
@@ -6,17 +6,21 @@
6
6
 
7
7
  <h4 align="center">
8
8
  <a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> |
9
+ <a href="https://www.meilisearch.com/pricing?utm_campaign=oss&utm_source=integration&utm_medium=meilisearch-rails">Meilisearch Cloud</a> |
9
10
  <a href="https://docs.meilisearch.com">Documentation</a> |
10
11
  <a href="https://discord.meilisearch.com">Discord</a> |
11
12
  <a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> |
12
13
  <a href="https://www.meilisearch.com">Website</a> |
13
- <a href="https://docs.meilisearch.com/faq">FAQ</a>
14
+ <a href="https://www.meilisearch.com/docs/faq">FAQ</a>
14
15
  </h4>
15
16
 
16
17
  <p align="center">
17
18
  <a href="https://github.com/meilisearch/meilisearch-rails/actions"><img src="https://github.com/meilisearch/meilisearch-rails/workflows/Tests/badge.svg" alt="Test"></a>
19
+ <a href="https://app.codecov.io/gh/meilisearch/meilisearch-rails/tree/main" >
20
+ <img src="https://codecov.io/gh/meilisearch/meilisearch-rails/branch/main/graph/badge.svg?token=9J7LRP11IR"/>
21
+ </a>
18
22
  <a href="https://github.com/meilisearch/meilisearch-rails/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
19
- <a href="https://app.bors.tech/repositories/33032"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
23
+ <a href="https://ms-bors.herokuapp.com/repositories/68"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
20
24
  </p>
21
25
 
22
26
  <p align="center">⚡ The Meilisearch integration for Ruby on Rails 💎</p>
@@ -28,6 +32,7 @@
28
32
  ## Table of Contents <!-- omit in toc -->
29
33
 
30
34
  - [📖 Documentation](#-documentation)
35
+ - [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience)
31
36
  - [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)
32
37
  - [🚀 Getting started](#-getting-started)
33
38
  - [Compatibility](#-compatibility)
@@ -58,7 +63,11 @@
58
63
 
59
64
  The whole usage of this gem is detailed in this README.
60
65
 
61
- To learn more about Meilisearch, check out our [Documentation](https://docs.meilisearch.com/learn/tutorials/getting_started.html) or our [API References](https://docs.meilisearch.com/reference/api/).
66
+ To learn more about Meilisearch, check out our [Documentation](https://www.meilisearch.com/docs/learn/tutorials/getting_started.html) or our [API References](https://www.meilisearch.com/docs/reference/api/).
67
+
68
+ ## ⚡ Supercharge your Meilisearch experience
69
+
70
+ Say goodbye to server deployment and manual updates with [Meilisearch Cloud](https://www.meilisearch.com/pricing?utm_campaign=oss&utm_source=integration&utm_medium=meilisearch-rails). No credit card required.
62
71
 
63
72
  ## 🤖 Compatibility with Meilisearch
64
73
 
@@ -66,7 +75,7 @@ This package guarantees compatibility with [version v1.x of Meilisearch](https:/
66
75
 
67
76
  ## 🔧 Installation <!-- omit in toc -->
68
77
 
69
- This package requires Ruby version 2.6.0 or later and Rails 5.2 or later.
78
+ This package requires Ruby version 2.7.0 or later and Rails 6.1 or later. It may work in older versions but it is not officially supported.
70
79
 
71
80
  With `gem` in command line:
72
81
  ```bash
@@ -82,7 +91,7 @@ gem 'meilisearch-rails'
82
91
 
83
92
  ### Run Meilisearch <!-- omit in toc -->
84
93
 
85
- There are many easy ways to [download and run a Meilisearch instance](https://docs.meilisearch.com/reference/features/installation.html#download-and-launch).
94
+ There are many easy ways to [download and run a Meilisearch instance](https://www.meilisearch.com/docs/reference/features/installation.html#download-and-launch).
86
95
 
87
96
  For example, if you use Docker:
88
97
 
@@ -101,13 +110,21 @@ Create a new file `config/initializers/meilisearch.rb` to setup your `MEILISEARC
101
110
 
102
111
  ```ruby
103
112
  MeiliSearch::Rails.configuration = {
104
- meilisearch_url: 'YourMeilisearchUrl', # example: http://localhost:7700
105
- meilisearch_api_key: 'YourMeilisearchAPIKey',
113
+ meilisearch_url: ENV.fetch('MEILISEARCH_HOST', 'http://localhost:7700'),
114
+ meilisearch_api_key: ENV.fetch('MEILISEARCH_API_KEY', 'YourMeilisearchAPIKey')
106
115
  }
107
116
  ```
108
117
 
118
+ Or you can run a rake task to create the initializer file for you:
119
+
120
+ ```bash
121
+ bin/rails meilisearch:install
122
+ ```
123
+
109
124
  The gem is compatible with [ActiveRecord](https://github.com/rails/rails/tree/master/activerecord), [Mongoid](https://github.com/mongoid/mongoid) and [Sequel](https://github.com/jeremyevans/sequel).
110
125
 
126
+ ⚠️ Note that even if you want to use all the default options, you must declare an empty `meilisearch` block in your model.
127
+
111
128
  #### Add documents <!-- omit in toc -->
112
129
 
113
130
  The following code will create a `Book` index and add search capabilities to your `Book` model.
@@ -123,7 +140,9 @@ class Book < ActiveRecord::Base
123
140
  end
124
141
  ```
125
142
 
126
- ⚠️ Note that even if you want to use all the default options, you must declare an empty `meilisearch` block in your model.
143
+ #### Automatic indexing
144
+
145
+ As soon as you configure your model as mentioned above, `meilisearch-rails` will keep your database table data in sync with your Meilisearch instance using the `ActiveRecord` callbacks automatically.
127
146
 
128
147
  #### Basic Backend Search <!-- omit in toc -->
129
148
 
@@ -191,11 +210,11 @@ class Book < ApplicationRecord
191
210
  end
192
211
  ```
193
212
 
194
- Check the dedicated section of the documentation, for more information on the [settings](https://docs.meilisearch.com/reference/features/settings.html).
213
+ Check the dedicated section of the documentation, for more information on the [settings](https://www.meilisearch.com/docs/reference/api/settings#settings_parameters).
195
214
 
196
215
  ## 🔍 Custom search
197
216
 
198
- All the supported options are described in the [search parameters](https://docs.meilisearch.com/reference/features/search_parameters.html) section of the documentation.
217
+ All the supported options are described in the [search parameters](https://www.meilisearch.com/docs/reference/api/search#search-parameters) section of the documentation.
199
218
 
200
219
  ```ruby
201
220
  Book.search('Harry', attributes_to_highlight: ['*'])
@@ -19,4 +19,11 @@ namespace :meilisearch do
19
19
 
20
20
  MeiliSearch::Rails::Utilities.clear_all_indexes
21
21
  end
22
+
23
+ desc 'Create initializer file'
24
+ task install: :environment do
25
+ puts 'Creating initializer file'
26
+
27
+ copy_file "#{__dir__}/../templates/initializer.rb", 'config/initializers/meilisearch.rb'
28
+ end
22
29
  end
@@ -0,0 +1,4 @@
1
+ MeiliSearch::Rails.configuration = {
2
+ meilisearch_url: ENV.fetch('MEILISEARCH_HOST', 'http://localhost:7700'),
3
+ meilisearch_api_key: ENV.fetch('MEILISEARCH_API_KEY', 'YourMeilisearchAPIKey')
4
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  module MeiliSearch
4
4
  module Rails
5
- VERSION = '0.9.1'
5
+ VERSION = '0.10.1'
6
6
 
7
7
  def self.qualified_version
8
8
  "Meilisearch Rails (v#{VERSION})"
@@ -48,23 +48,23 @@ module MeiliSearch
48
48
 
49
49
  # Meilisearch settings
50
50
  OPTIONS = %i[
51
- searchableAttributes
52
- filterableAttributes
53
- sortableAttributes
54
- displayedAttributes
55
- distinctAttribute
51
+ searchable_attributes
52
+ filterable_attributes
53
+ sortable_attributes
54
+ displayed_attributes
55
+ distinct_attribute
56
56
  synonyms
57
- stopWords
58
- rankingRules
59
- attributesToHighlight
60
- attributesToCrop
61
- cropLength
57
+ stop_words
58
+ ranking_rules
59
+ attributes_to_highlight
60
+ attributes_to_crop
61
+ crop_length
62
62
  pagination
63
63
  faceting
64
- typoTolerance
64
+ typo_tolerance
65
65
  ].freeze
66
66
 
67
- CAMELIZE_OPTIONS = %i[pagination faceting typoTolerance].freeze
67
+ CAMELIZE_OPTIONS = %i[pagination faceting typo_tolerance].freeze
68
68
 
69
69
  OPTIONS.each do |option|
70
70
  define_method option do |value|
@@ -265,9 +265,9 @@ module MeiliSearch
265
265
  ::MeiliSearch::Index.instance_methods(false).each do |m|
266
266
  define_method(m) do |*args, &block|
267
267
  if m == :update_settings
268
- args[0].delete(:attributesToHighlight) if args[0][:attributesToHighlight]
269
- args[0].delete(:attributesToCrop) if args[0][:attributesToCrop]
270
- args[0].delete(:cropLength) if args[0][:cropLength]
268
+ args[0].delete(:attributes_to_highlight) if args[0][:attributes_to_highlight]
269
+ args[0].delete(:attributes_to_crop) if args[0][:attributes_to_crop]
270
+ args[0].delete(:crop_length) if args[0][:crop_length]
271
271
  end
272
272
 
273
273
  SafeIndex.log_or_throw(m, @raise_on_failure) do
@@ -581,15 +581,15 @@ module MeiliSearch
581
581
  def ms_raw_search(q, params = {})
582
582
  index_uid = params.delete(:index) || params.delete('index')
583
583
 
584
- unless meilisearch_settings.get_setting(:attributesToHighlight).nil?
585
- params[:attributesToHighlight] = meilisearch_settings.get_setting(:attributesToHighlight)
584
+ unless meilisearch_settings.get_setting(:attributes_to_highlight).nil?
585
+ params[:attributes_to_highlight] = meilisearch_settings.get_setting(:attributes_to_highlight)
586
586
  end
587
587
 
588
- unless meilisearch_settings.get_setting(:attributesToCrop).nil?
589
- params[:attributesToCrop] = meilisearch_settings.get_setting(:attributesToCrop)
588
+ unless meilisearch_settings.get_setting(:attributes_to_crop).nil?
589
+ params[:attributes_to_crop] = meilisearch_settings.get_setting(:attributes_to_crop)
590
590
 
591
- unless meilisearch_settings.get_setting(:cropLength).nil?
592
- params[:cropLength] = meilisearch_settings.get_setting(:cropLength)
591
+ unless meilisearch_settings.get_setting(:crop_length).nil?
592
+ params[:crop_length] = meilisearch_settings.get_setting(:crop_length)
593
593
  end
594
594
  end
595
595
 
@@ -34,5 +34,5 @@ Gem::Specification.new do |s|
34
34
 
35
35
  s.required_ruby_version = '>= 2.6.0'
36
36
 
37
- s.add_dependency 'meilisearch', '~> 0.23.0'
37
+ s.add_dependency 'meilisearch', '~> 0.25.0'
38
38
  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.9.1
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-27 00:00:00.000000000 Z
11
+ date: 2023-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: meilisearch
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.23.0
19
+ version: 0.25.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.23.0
26
+ version: 0.25.0
27
27
  description: Meilisearch integration for Ruby on Rails. See https://github.com/meilisearch/meilisearch
28
28
  email: bonjour@meilisearch.com
29
29
  executables: []
@@ -47,6 +47,7 @@ files:
47
47
  - lib/meilisearch/rails/pagination/will_paginate.rb
48
48
  - lib/meilisearch/rails/railtie.rb
49
49
  - lib/meilisearch/rails/tasks/meilisearch.rake
50
+ - lib/meilisearch/rails/templates/initializer.rb
50
51
  - lib/meilisearch/rails/utilities.rb
51
52
  - lib/meilisearch/rails/version.rb
52
53
  - meilisearch-rails.gemspec