algolia 2.0.0.pre.beta.2 → 2.0.0.pre.beta.3
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 +4 -4
- data/lib/algolia/config/base_config.rb +9 -7
- data/lib/algolia/helpers.rb +5 -2
- data/lib/algolia/search_index.rb +1 -1
- data/lib/algolia/version.rb +1 -1
- data/test/algolia/unit/helpers_test.rb +29 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47d18253040f91e77f82a815e90b4064c88aac2ddbacbe4c26b1dea81304d847
|
4
|
+
data.tar.gz: 530b601d76e6de0b4f252dc13bcce01f7446428f839cd22fb4b286a1b5a17f73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04c63a1fb49fcd66817e0b43f66c16b3cbe8bd044ca513409047f8709ab8cc757deb30cedaeafcddf831f98179efa9c21fdcbf4bb09a1641b9b5b7aa96d6fc8c
|
7
|
+
data.tar.gz: e552093cc4ab5827c8ab87e448856bfdbd68f113b8e321e928e66ceb03f8ecf96531aad902d256a6372336c9efeedd166e85165d63a0c83f0795de942a0b4eb7
|
@@ -3,7 +3,7 @@ require 'faraday'
|
|
3
3
|
module Algolia
|
4
4
|
class BaseConfig
|
5
5
|
attr_accessor :app_id, :api_key, :headers, :batch_size, :read_timeout, :write_timeout, :connect_timeout, :compression_type,
|
6
|
-
:symbolize_keys
|
6
|
+
:symbolize_keys, :use_latest_settings
|
7
7
|
|
8
8
|
#
|
9
9
|
# @option options [String] :application_id
|
@@ -28,12 +28,14 @@ module Algolia
|
|
28
28
|
'User-Agent' => UserAgent.value
|
29
29
|
}
|
30
30
|
|
31
|
-
@batch_size
|
32
|
-
@read_timeout
|
33
|
-
@write_timeout
|
34
|
-
@connect_timeout
|
35
|
-
@compression_type
|
36
|
-
@symbolize_keys
|
31
|
+
@batch_size = opts[:batch_size] || Defaults::BATCH_SIZE
|
32
|
+
@read_timeout = opts[:read_timeout] || Defaults::READ_TIMEOUT
|
33
|
+
@write_timeout = opts[:write_timeout] || Defaults::WRITE_TIMEOUT
|
34
|
+
@connect_timeout = opts[:connect_timeout] || Defaults::CONNECT_TIMEOUT
|
35
|
+
@compression_type = opts[:compression_type] || Defaults::NONE_ENCODING
|
36
|
+
@symbolize_keys = opts.has_key?(:symbolize_keys) ? opts[:symbolize_keys] : true
|
37
|
+
# used to avoid BC break on Rails integration, should not be documented
|
38
|
+
@use_latest_settings = opts.has_key?(:use_latest_settings) ? opts[:use_latest_settings] : true
|
37
39
|
end
|
38
40
|
|
39
41
|
def set_extra_header(key, value)
|
data/lib/algolia/helpers.rb
CHANGED
@@ -52,7 +52,9 @@ module Helpers
|
|
52
52
|
|
53
53
|
# Support to convert old settings to their new names
|
54
54
|
#
|
55
|
-
def deserialize_settings(data)
|
55
|
+
def deserialize_settings(data, use_latest_settings, symbolize_keys)
|
56
|
+
return data unless use_latest_settings
|
57
|
+
|
56
58
|
settings = symbolize_hash(data)
|
57
59
|
keys = {
|
58
60
|
attributesToIndex: 'searchableAttributes',
|
@@ -62,7 +64,8 @@ module Helpers
|
|
62
64
|
|
63
65
|
keys.each do |deprecated_key, current_key|
|
64
66
|
if settings.has_key?(deprecated_key)
|
65
|
-
|
67
|
+
key = symbolize_keys ? current_key.to_sym : current_key.to_s
|
68
|
+
settings[key] = settings.delete(deprecated_key)
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
data/lib/algolia/search_index.rb
CHANGED
@@ -976,7 +976,7 @@ module Algolia
|
|
976
976
|
def get_settings(opts = {})
|
977
977
|
response = @transporter.read(:GET, path_encode('/1/indexes/%s/settings', @name) + handle_params({ getVersion: 2 }), {}, opts)
|
978
978
|
|
979
|
-
deserialize_settings(response)
|
979
|
+
deserialize_settings(response, @config.use_latest_settings, @config.symbolize_keys)
|
980
980
|
end
|
981
981
|
|
982
982
|
# Update some index settings. Only specified settings are overridden
|
data/lib/algolia/version.rb
CHANGED
@@ -18,7 +18,35 @@ class HelpersTest
|
|
18
18
|
replicas: %w(index1 index2)
|
19
19
|
}
|
20
20
|
|
21
|
-
deserialized_settings = deserialize_settings(old_settings)
|
21
|
+
deserialized_settings = deserialize_settings(old_settings, true, true)
|
22
|
+
assert_equal new_settings, deserialized_settings
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_deserialize_settings_with_old_settings
|
26
|
+
old_settings = {
|
27
|
+
attributesToIndex: %w(attr1 attr2),
|
28
|
+
numericAttributesToIndex: %w(attr1 attr2),
|
29
|
+
slaves: %w(index1 index2)
|
30
|
+
}
|
31
|
+
|
32
|
+
deserialized_settings = deserialize_settings(old_settings, false, true)
|
33
|
+
assert_equal old_settings, deserialized_settings
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_deserialize_settings_with_string
|
37
|
+
old_settings = {
|
38
|
+
'attributesToIndex' => %w(attr1 attr2),
|
39
|
+
'numericAttributesToIndex' => %w(attr1 attr2),
|
40
|
+
'slaves' => %w(index1 index2)
|
41
|
+
}
|
42
|
+
|
43
|
+
new_settings = {
|
44
|
+
'searchableAttributes' => %w(attr1 attr2),
|
45
|
+
'numericAttributesForFiltering' => %w(attr1 attr2),
|
46
|
+
'replicas' => %w(index1 index2)
|
47
|
+
}
|
48
|
+
|
49
|
+
deserialized_settings = deserialize_settings(old_settings, true, false)
|
22
50
|
assert_equal new_settings, deserialized_settings
|
23
51
|
end
|
24
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algolia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.pre.beta.
|
4
|
+
version: 2.0.0.pre.beta.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|