Skip to content

Commit ca5d7c5

Browse files
committed
Merge branch 'main' into add-add-document-methods-by-its-type
# Conflicts: # .rubocop_todo.yml # lib/meilisearch/http_request.rb # spec/meilisearch/index/documents_spec.rb
2 parents d21ccfc + c0bfc68 commit ca5d7c5

21 files changed

+146
-96
lines changed

.github/release-draft-template.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ version-resolver:
88
- 'breaking-change'
99
default: patch
1010
categories:
11-
- title: 'Breaking changes ⚠️'
11+
- title: '⚠️ Breaking changes'
1212
label: 'breaking-change'
13+
- title: '🚀 Enhancements'
14+
label: 'enhancement'
15+
- title: '🐛 Bug Fixes'
16+
label: 'bug'
17+
- title: '🔒 Security'
18+
label: 'security'
1319
template: |
14-
## Changes
15-
1620
$CHANGES
1721
1822
Thanks again to $CONTRIBUTORS! 🎉
@@ -27,3 +31,5 @@ replacers:
2731
replace: ''
2832
- search: '/(?:and )?@meili-bot,?/g'
2933
replace: ''
34+
- search: '/(?:and )?@meili-bors(?:\[bot\])?,?/g'
35+
replace: ''

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ Style/SymbolArray:
2020

2121
Style/WordArray:
2222
EnforcedStyle: brackets
23+
24+
Style/Documentation:
25+
Enabled: false

.rubocop_todo.yml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2021-10-27 18:13:40 UTC using RuboCop version 1.22.1.
3+
# on 2021-11-18 03:06:45 UTC using RuboCop version 1.23.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -16,39 +16,24 @@ Gemspec/DateAssignment:
1616

1717
# Offense count: 1
1818
# Cop supports --auto-correct.
19-
Layout/HeredocIndentation:
19+
# Configuration parameters: Include.
20+
# Include: **/*.gemspec
21+
Gemspec/RequireMFA:
2022
Exclude:
21-
- 'spec/meilisearch/index/documents_spec.rb'
23+
- 'meilisearch.gemspec'
2224

2325
# Offense count: 32
2426
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
2527
# IgnoredMethods: refine
2628
Metrics/BlockLength:
27-
Max: 498
29+
Max: 512
2830

29-
# Offense count: 2
31+
# Offense count: 1
3032
# Configuration parameters: CountComments, CountAsOne.
3133
Metrics/ClassLength:
32-
Max: 289
33-
34-
# Offense count: 1
35-
# Configuration parameters: Max, CountKeywordArgs.
36-
Metrics/ParameterLists:
37-
MaxOptionalParameters: 4
34+
Max: 271
3835

3936
# Offense count: 2
4037
Naming/AccessorMethodName:
4138
Exclude:
4239
- 'lib/meilisearch/index.rb'
43-
44-
# Offense count: 7
45-
# Configuration parameters: AllowedConstants.
46-
Style/Documentation:
47-
Exclude:
48-
- 'spec/**/*'
49-
- 'test/**/*'
50-
- 'lib/meilisearch.rb'
51-
- 'lib/meilisearch/client.rb'
52-
- 'lib/meilisearch/error.rb'
53-
- 'lib/meilisearch/http_request.rb'
54-
- 'lib/meilisearch/index.rb'

CONTRIBUTING.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ First of all, thank you for contributing to MeiliSearch! The goal of this docume
44

55
<!-- MarkdownTOC autolink="true" style="ordered" indent=" " -->
66

7-
- [Hacktoberfest](#hacktoberfest)
87
- [Assumptions](#assumptions)
98
- [How to Contribute](#how-to-contribute)
109
- [Development Workflow](#development-workflow)
@@ -13,16 +12,6 @@ First of all, thank you for contributing to MeiliSearch! The goal of this docume
1312

1413
<!-- /MarkdownTOC -->
1514

16-
## Hacktoberfest
17-
18-
It's [Hacktoberfest month](https://blog.meilisearch.com/contribute-hacktoberfest-2021/)! 🥳
19-
20-
🚀 If your PR gets accepted it will count into your participation to Hacktoberfest!
21-
22-
✅ To be accepted it has either to have been merged, approved or tagged with the `hacktoberfest-accepted` label.
23-
24-
🧐 Don't forget to check the [quality standards](https://hacktoberfest.digitalocean.com/resources/qualitystandards)! Low-quality PRs might get marked as `spam` or `invalid`, and will not count toward your participation in Hacktoberfest.
25-
2615
## Assumptions
2716

2817
1. **You're familiar with [GitHub](https://github.com) and the [Pull Request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)(PR) workflow.**
@@ -151,7 +140,7 @@ Some notes on GitHub PRs:
151140

152141
- [Convert your PR as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-stage-of-a-pull-request) if your changes are a work in progress: no one will review it until you pass your PR as ready for review.<br>
153142
The draft PR can be very useful if you want to show that you are working on something and make your work visible.
154-
- The branch related to the PR must be **up-to-date with `main`** before merging. Fortunately, this project [integrates a bot](https://github.com/meilisearch/integration-guides/blob/main/guides/bors.md) to automatically enforce this requirement without the PR author having to do it manually.
143+
- The branch related to the PR must be **up-to-date with `main`** before merging. Fortunately, this project [integrates a bot](https://github.com/meilisearch/integration-guides/blob/main/resources/bors.md) to automatically enforce this requirement without the PR author having to do it manually.
155144
- All PRs must be reviewed and approved by at least one maintainer.
156145
- The PR title should be accurate and descriptive of the changes. The title of the PR will be indeed automatically added to the next [release changelogs](https://github.com/meilisearch/meilisearch-ruby/releases/).
157146

@@ -162,24 +151,24 @@ MeiliSearch tools follow the [Semantic Versioning Convention](https://semver.org
162151
### Automation to Rebase and Merge the PRs <!-- omit in toc -->
163152

164153
This project integrates a bot that helps us manage pull requests merging.<br>
165-
_[Read more about this](https://github.com/meilisearch/integration-guides/blob/main/guides/bors.md)._
154+
_[Read more about this](https://github.com/meilisearch/integration-guides/blob/main/resources/bors.md)._
166155

167156
### Automated Changelogs <!-- omit in toc -->
168157

169158
This project integrates a tool to create automated changelogs.<br>
170-
_[Read more about this](https://github.com/meilisearch/integration-guides/blob/main/guides/release-drafter.md)._
159+
_[Read more about this](https://github.com/meilisearch/integration-guides/blob/main/resources/release-drafter.md)._
171160

172161
### How to Publish the Release <!-- omit in toc -->
173162

174-
⚠️ Before doing anything, make sure you got through the guide about [Releasing an Integration](https://github.com/meilisearch/integration-guides/blob/main/guides/integration-release.md).
163+
⚠️ Before doing anything, make sure you got through the guide about [Releasing an Integration](https://github.com/meilisearch/integration-guides/blob/main/resources/integration-release.md).
175164

176165
Make a PR modifying the file [`lib/meilisearch/version.rb`](/lib/meilisearch/version.rb) with the right version.
177166

178167
```ruby
179168
VERSION = 'X.X.X'
180169
```
181170

182-
Once the changes are merged on `main`, you can publish the current draft release via the [GitHub interface](https://github.com/meilisearch/meilisearch-ruby/releases).
171+
Once the changes are merged on `main`, you can publish the current draft release via the [GitHub interface](https://github.com/meilisearch/meilisearch-ruby/releases): on this page, click on `Edit` (related to the draft release) > update the description (be sure you apply [these recommandations](https://github.com/meilisearch/integration-guides/blob/main/resources/integration-release.md#writting-the-release-description)) > when you are ready, click on `Publish release`.
183172

184173
GitHub Actions will be triggered and push the package to [RubyGems](https://rubygems.org/gems/meilisearch).
185174

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ group :development, :test do
1414
end
1515

1616
group :development do
17-
gem 'rubocop', '~> 1.22.1', require: false
17+
gem 'rubocop', '~> 1.23.0', require: false
1818
end

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ JSON output:
198198

199199
## 🤖 Compatibility with MeiliSearch
200200

201-
This package only guarantees the compatibility with the [version v0.23.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.23.0).
201+
This package only guarantees the compatibility with the [version v0.24.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.24.0).
202202

203203
## 💡 Learn More
204204

lib/meilisearch.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'meilisearch/version'
4+
require 'meilisearch/utils'
45
require 'meilisearch/client'
56
require 'meilisearch/index'
67

lib/meilisearch/client.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def indexes
2020
# client.create_index('indexUID')
2121
# client.create_index('indexUID', primaryKey: 'id')
2222
def create_index(index_uid, options = {})
23-
body = options.merge(uid: index_uid)
23+
body = Utils.transform_attributes(options.merge(uid: index_uid))
24+
2425
index_hash = http_post '/indexes', body
2526
index_object(index_hash['uid'], index_hash['primaryKey'])
2627
end

lib/meilisearch/error.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def initialize(http_code, http_message, http_body)
2929

3030
def get_meilisearch_error_info(http_body)
3131
@http_body = JSON.parse(http_body)
32-
@ms_code = @http_body['errorCode']
32+
@ms_code = @http_body['code']
3333
@ms_message = @http_body['message']
34-
@ms_type = @http_body['errorType']
35-
@ms_link = @http_body['errorLink']
34+
@ms_type = @http_body['type']
35+
@ms_link = @http_body['link']
3636
rescue JSON::ParserError
3737
# We might receive a JSON::ParserError when, for example, MeiliSearch is running behind
3838
# some proxy (ELB or Nginx, for example), and the request timeouts, returning us

lib/meilisearch/http_request.rb

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ def clone_options(options)
8585
cloned_options
8686
end
8787

88-
SNAKE_CASE = /[^a-zA-Z0-9]+(.)/.freeze
89-
9088
def send_request(http_method, relative_path, query_params: nil, body: nil, options: {})
9189
config = http_config(query_params, body, options)
9290
begin
@@ -98,7 +96,7 @@ def send_request(http_method, relative_path, query_params: nil, body: nil, optio
9896
end
9997

10098
def http_config(query_params, body, options)
101-
body = transform_attributes(body).to_json if options[:transform_body?] == true
99+
body = body.to_json if options[:transform_body?] == true
102100
{
103101
headers: options[:headers],
104102
query: query_params,
@@ -108,25 +106,6 @@ def http_config(query_params, body, options)
108106
}.compact
109107
end
110108

111-
def transform_attributes(body)
112-
case body
113-
when Array
114-
body.map { |item| transform_attributes(item) }
115-
when Hash
116-
parse(body)
117-
else
118-
body
119-
end
120-
end
121-
122-
def parse(body)
123-
body
124-
.transform_keys(&:to_s)
125-
.transform_keys do |key|
126-
key.include?('_') ? key.downcase.gsub(SNAKE_CASE, &:upcase).gsub('_', '') : key
127-
end
128-
end
129-
130109
def validate(response)
131110
raise ApiError.new(response.code, response.message, response.body) unless response.success?
132111

0 commit comments

Comments
 (0)