Skip to content

Commit 6add5a0

Browse files
committed
chore: lint
1 parent 8079226 commit 6add5a0

4 files changed

Lines changed: 29 additions & 27 deletions

File tree

lib/typesense.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ module Typesense
3434
require_relative 'typesense/error'
3535
require_relative 'typesense/stemming'
3636
require_relative 'typesense/stemming_dictionaries'
37-
require_relative 'typesense/stemming_dictionary'
37+
require_relative 'typesense/stemming_dictionary'

lib/typesense/stemming.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# frozen_string_literal: true
2+
23
module Typesense
34
class Stemming
4-
RESOURCE_PATH = "/stemming"
5+
RESOURCE_PATH = '/stemming'
56

67
def initialize(api_call)
78
@api_call = api_call

lib/typesense/stemming_dictionaries.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Typesense
44
class StemmingDictionaries
5-
RESOURCE_PATH = "/stemming/dictionaries"
5+
RESOURCE_PATH = '/stemming/dictionaries'
66

77
def initialize(api_call)
88
@api_call = api_call
@@ -11,21 +11,21 @@ def initialize(api_call)
1111

1212
def upsert(dict_id, words_and_roots_combinations)
1313
words_and_roots_combinations_in_jsonl = if words_and_roots_combinations.is_a?(Array)
14-
words_and_roots_combinations.map { |combo| Oj.dump(combo, mode: :compat) }.join("\n")
15-
else
16-
words_and_roots_combinations
17-
end
14+
words_and_roots_combinations.map { |combo| Oj.dump(combo, mode: :compat) }.join('\n')
15+
else
16+
words_and_roots_combinations
17+
end
1818

1919
result_in_jsonl = @api_call.perform_request(
20-
"post",
21-
endpoint_path("import"),
20+
'post',
21+
endpoint_path('import'),
2222
query_parameters: { id: dict_id },
2323
body_parameters: words_and_roots_combinations_in_jsonl,
24-
additional_headers: { "Content-Type" => "text/plain" },
24+
additional_headers: { 'Content-Type' => 'text/plain' }
2525
)
2626

2727
if words_and_roots_combinations.is_a?(Array)
28-
result_in_jsonl.split("\n").map { |r| Oj.load(r) }
28+
result_in_jsonl.split('\n').map { |r| Oj.load(r) }
2929
else
3030
result_in_jsonl
3131
end
@@ -42,7 +42,7 @@ def [](dict_id)
4242
private
4343

4444
def endpoint_path(operation = nil)
45-
"#{StemmingDictionaries::RESOURCE_PATH}#{operation.nil? ? "" : "/#{URI.encode_www_form_component(operation)}"}"
45+
"#{StemmingDictionaries::RESOURCE_PATH}#{operation.nil? ? '' : "/#{URI.encode_www_form_component(operation)}"}"
4646
end
4747
end
4848
end

spec/typesense/stemming_spec.rb

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
11
# frozen_string_literal: true
2-
require_relative "../spec_helper"
32

4-
describe "Stemming Dictionaries" do
3+
require_relative '../spec_helper'
4+
5+
describe 'StemmingDictionaries' do
56
let(:client) do
67
Typesense::Client.new(
7-
nodes: [{ host: "localhost", port: "8108", protocol: "http" }],
8-
api_key: "xyz",
9-
connection_timeout_seconds: 10,
8+
nodes: [{ host: 'localhost', port: '8108', protocol: 'http' }],
9+
api_key: 'xyz',
10+
connection_timeout_seconds: 10
1011
)
1112
end
1213

13-
let(:dictionary_id) { "test_dictionary" }
14+
let(:dictionary_id) { 'test_dictionary' }
1415
let(:dictionary) do
1516
[
16-
{ "root" => "exampleRoot1", "word" => "exampleWord1" },
17-
{ "root" => "exampleRoot2", "word" => "exampleWord2" },
17+
{ 'root' => 'exampleRoot1', 'word' => 'exampleWord1' },
18+
{ 'root' => 'exampleRoot2', 'word' => 'exampleWord2' }
1819
]
1920
end
2021

2122
before { WebMock.disable! }
2223
after { WebMock.enable! }
2324

24-
it "can upsert a dictionary" do
25+
it 'can upsert a dictionary' do
2526
response = client.stemming.dictionaries.upsert(dictionary_id, dictionary)
2627
expect(response).to eq(dictionary)
2728
end
2829

29-
it "can retrieve a dictionary" do
30+
it 'can retrieve a dictionary' do
3031
response = client.stemming.dictionaries[dictionary_id].retrieve
31-
expect(response["id"]).to eq(dictionary_id)
32-
expect(response["words"]).to eq(dictionary)
32+
expect(response['id']).to eq(dictionary_id)
33+
expect(response['words']).to eq(dictionary)
3334
end
3435

35-
it "can retrieve all dictionaries" do
36+
it 'can retrieve all dictionaries' do
3637
response = client.stemming.dictionaries.retrieve
37-
expect(response["dictionaries"].length).to eq(1)
38-
expect(response["dictionaries"][0]).to eq(dictionary_id)
38+
expect(response['dictionaries'].length).to eq(1)
39+
expect(response['dictionaries'][0]).to eq(dictionary_id)
3940
end
4041
end

0 commit comments

Comments
 (0)