swiftype 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +11 -12
- data/lib/swiftype/exceptions.rb +6 -0
- data/lib/swiftype/request.rb +18 -10
- data/lib/swiftype/version.rb +1 -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: bda5ec1efcbe1ef87452f3ce621c37bd4ad31d999344f4ca9ab440e2380bf7e4
|
4
|
+
data.tar.gz: 7c7c534e537c64f58c8f2902555601ea29c6943e8c6d6d6a9d9c2ad9851e26aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15ffab1349deebca7d5e98fc60722a7f7344f05a663956e5ac1ad739006974625b4a0bf29407e789c803535921dee2e342c06e00b55a772bccd85e938678045b
|
7
|
+
data.tar.gz: 89970d924cdab95da38ef2ab0f79aa7f5c0795769bdc50b7ef9f97b139adba65f93f726d842fdb84d0b23aae9e454ee003dfccf28f488d2b23aa9f65c58f2934
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
<p align="center"><img src="https://github.com/swiftype/swiftype-rb/blob/master/logo-site-search.png?raw=true" alt="Elastic Site Search Logo"></p>
|
3
2
|
|
4
3
|
<p align="center"><a href="https://travis-ci.org/swiftype/swiftype-rb"><img src="https://travis-ci.org/swiftype/swiftype-rb.png" alt="Travis build"></a>
|
@@ -8,15 +7,15 @@
|
|
8
7
|
|
9
8
|
## Contents
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
- [Getting started](#getting-started-)
|
11
|
+
- [Usage](#usage)
|
12
|
+
- [Migrating from pervious versions](#migrating-from-previous-versions)
|
13
|
+
- [Development](#development)
|
14
|
+
- [FAQ](#faq-)
|
15
|
+
- [Contribute](#contribute-)
|
16
|
+
- [License](#license-)
|
18
17
|
|
19
|
-
|
18
|
+
---
|
20
19
|
|
21
20
|
## Getting started 🐣
|
22
21
|
|
@@ -48,7 +47,7 @@ To install the gem, execute:
|
|
48
47
|
|
49
48
|
gem install swiftype
|
50
49
|
|
51
|
-
Or place `gem 'swiftype', '~> 1.
|
50
|
+
Or place `gem 'swiftype', '~> 1.5.0` in your `Gemfile` and run `bundle install`.
|
52
51
|
|
53
52
|
> **Note:** This client has been developed for the [Swiftype Site Search](https://www.swiftype.com/site-search) API endpoints only.
|
54
53
|
|
@@ -459,8 +458,8 @@ You can checkout the [Elastic Site Search community discuss forums](https://disc
|
|
459
458
|
|
460
459
|
We welcome contributors to the project. Before you begin, a couple notes...
|
461
460
|
|
462
|
-
|
463
|
-
|
461
|
+
- Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/swiftype/swiftype-rb/issues).
|
462
|
+
- Please write simple code and concise documentation, when appropriate.
|
464
463
|
|
465
464
|
## License 📗
|
466
465
|
|
data/lib/swiftype/exceptions.rb
CHANGED
@@ -6,4 +6,10 @@ module Swiftype
|
|
6
6
|
class BadRequest < ClientException; end
|
7
7
|
class Forbidden < ClientException; end
|
8
8
|
class UnexpectedHTTPException < ClientException; end
|
9
|
+
|
10
|
+
class ServerException < StandardError; end
|
11
|
+
class InternalServerError < ServerException; end
|
12
|
+
class BadGateway < ServerException; end
|
13
|
+
class ServiceUnavailable < ServerException; end
|
14
|
+
class GatewayTimeout < ServerException; end
|
9
15
|
end
|
data/lib/swiftype/request.rb
CHANGED
@@ -89,21 +89,29 @@ module Swiftype
|
|
89
89
|
case response
|
90
90
|
when Net::HTTPSuccess
|
91
91
|
response
|
92
|
-
when Net::HTTPUnauthorized
|
93
|
-
raise Swiftype::InvalidCredentials, error_message_from_response(response)
|
94
|
-
when Net::HTTPNotFound
|
95
|
-
raise Swiftype::NonExistentRecord, error_message_from_response(response)
|
96
|
-
when Net::HTTPConflict
|
97
|
-
raise Swiftype::RecordAlreadyExists, error_message_from_response(response)
|
98
|
-
when Net::HTTPBadRequest
|
99
|
-
raise Swiftype::BadRequest, error_message_from_response(response)
|
100
|
-
when Net::HTTPForbidden
|
101
|
-
raise Swiftype::Forbidden, error_message_from_response(response)
|
102
92
|
else
|
93
|
+
EXCEPTION_MAP.each do |response_class, exception_class|
|
94
|
+
if response.is_a?(response_class)
|
95
|
+
raise exception_class, error_message_from_response(response)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
103
99
|
raise Swiftype::UnexpectedHTTPException, "#{response.code} #{response.body}"
|
104
100
|
end
|
105
101
|
end
|
106
102
|
|
103
|
+
EXCEPTION_MAP = {
|
104
|
+
Net::HTTPUnauthorized => Swiftype::InvalidCredentials,
|
105
|
+
Net::HTTPNotFound => Swiftype::NonExistentRecord,
|
106
|
+
Net::HTTPConflict => Swiftype::RecordAlreadyExists,
|
107
|
+
Net::HTTPBadRequest => Swiftype::BadRequest,
|
108
|
+
Net::HTTPForbidden => Swiftype::Forbidden,
|
109
|
+
Net::HTTPInternalServerError => Swiftype::InternalServerError,
|
110
|
+
Net::HTTPBadGateway => Swiftype::BadGateway,
|
111
|
+
Net::HTTPServiceUnavailable => Swiftype::ServiceUnavailable,
|
112
|
+
Net::HTTPGatewayTimeOut => Swiftype::GatewayTimeout
|
113
|
+
}.freeze
|
114
|
+
|
107
115
|
def error_message_from_response(response)
|
108
116
|
body = response.body
|
109
117
|
json = JSON.parse(body) if body && body.strip != ''
|
data/lib/swiftype/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiftype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Quin Hoxie
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|