swiftype-app-search 0.1.2 → 0.1.3
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd624bd0145b983734fdd65725ad222fb07752b5
|
4
|
+
data.tar.gz: d02e4f1e25f9e6a8d06eb83f33bc38b5aa132ec5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5afb7ec9fc723e2fceaaa629d3dc948857ad3f4546db3ea67b659870f4aac7115d1185a7927194d2e18d4697e2026f026697b061c8c5a13f7bd94ca4a49577ea
|
7
|
+
data.tar.gz: 7d88608afa49080ad259930b299d2d78774a3188a26aadeb6ea9db58af94d45c8581df8329e9d54314918107578247554ed6dbd1f6f88f863b376f8f1ed5b2d8
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Ruby client for the Swiftype App Search API
|
2
2
|
|
3
|
-
**Note: Swiftype App Search is currently in beta**
|
4
|
-
|
5
3
|
## Installation
|
6
4
|
|
7
5
|
To install the gem, execute:
|
@@ -10,7 +8,7 @@ To install the gem, execute:
|
|
10
8
|
gem install swiftype-app-search
|
11
9
|
```
|
12
10
|
|
13
|
-
Or place `gem 'swiftype-app-search', '~> 0.1.
|
11
|
+
Or place `gem 'swiftype-app-search', '~> 0.1.3` in your `Gemfile` and run `bundle install`.
|
14
12
|
|
15
13
|
## Usage
|
16
14
|
|
@@ -17,9 +17,9 @@ module SwiftypeAppSearch
|
|
17
17
|
class RequestEntityTooLarge < ClientException; end
|
18
18
|
|
19
19
|
class UnexpectedHTTPException < ClientException
|
20
|
-
def initialize(
|
21
|
-
|
22
|
-
super(
|
20
|
+
def initialize(response, response_json)
|
21
|
+
errors = (response_json['errors'] || [response.message]).map { |e| "(#{response.code}) #{e}" }
|
22
|
+
super({ 'errors' => errors })
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -70,7 +70,7 @@ module SwiftypeAppSearch
|
|
70
70
|
when Net::HTTPRequestEntityTooLarge
|
71
71
|
raise SwiftypeAppSearch::RequestEntityTooLarge, response_json
|
72
72
|
else
|
73
|
-
raise SwiftypeAppSearch::UnexpectedHTTPException,
|
73
|
+
raise SwiftypeAppSearch::UnexpectedHTTPException.new(response, response_json)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -32,12 +32,12 @@ describe SwiftypeAppSearch::Client do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'when a document has processing errors' do
|
35
|
-
let(:document) { { '
|
35
|
+
let(:document) { { 'id' => 'too long' * 100 } }
|
36
36
|
|
37
37
|
it 'should raise an error when the API returns errors in the response' do
|
38
38
|
expect do
|
39
39
|
subject
|
40
|
-
end.to raise_error(SwiftypeAppSearch::InvalidDocument, /Invalid field
|
40
|
+
end.to raise_error(SwiftypeAppSearch::InvalidDocument, /Invalid field/)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -56,12 +56,12 @@ describe SwiftypeAppSearch::Client do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'when one of the documents has processing errors' do
|
59
|
-
let(:second_document) { { '
|
59
|
+
let(:second_document) { { 'id' => 'too long' * 100 } }
|
60
60
|
|
61
61
|
it 'should return respective errors in an array of document processing hashes' do
|
62
62
|
expect(subject).to match([
|
63
63
|
{ 'id' => anything, 'errors' => [] },
|
64
|
-
{ 'id' => anything, 'errors' => ['Invalid field
|
64
|
+
{ 'id' => anything, 'errors' => ['Invalid field type: id must be less than 800 characters'] },
|
65
65
|
])
|
66
66
|
end
|
67
67
|
end
|
@@ -97,15 +97,20 @@ describe SwiftypeAppSearch::Client do
|
|
97
97
|
|
98
98
|
context '#list_engines' do
|
99
99
|
it 'should return an array with a list of engines' do
|
100
|
-
expect(client.list_engines).to be_an(Array)
|
100
|
+
expect(client.list_engines['results']).to be_an(Array)
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should include the engine name in listed objects' do
|
104
|
-
# Create an engine
|
105
104
|
client.create_engine(engine_name)
|
106
105
|
|
107
|
-
|
108
|
-
engines
|
106
|
+
engines = client.list_engines['results']
|
107
|
+
expect(engines.find { |e| e['name'] == engine_name }).to_not be_nil
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should include the engine name in listed objects with pagination' do
|
111
|
+
client.create_engine(engine_name)
|
112
|
+
|
113
|
+
engines = client.list_engines(:current => 1, :size => 20)['results']
|
109
114
|
expect(engines.find { |e| e['name'] == engine_name }).to_not be_nil
|
110
115
|
end
|
111
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiftype-app-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Quin Hoxie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.5
|
117
|
+
rubygems_version: 2.4.5
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Official gem for accessing the Swiftype App Search API
|