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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f63edc94df155455010fd47771121ec305c74be186603f962e59757d55cde739
4
- data.tar.gz: 4e2a84363c431549d456c61ab289a6f6432b802a29e28776a22da65836c2021b
3
+ metadata.gz: bda5ec1efcbe1ef87452f3ce621c37bd4ad31d999344f4ca9ab440e2380bf7e4
4
+ data.tar.gz: 7c7c534e537c64f58c8f2902555601ea29c6943e8c6d6d6a9d9c2ad9851e26aa
5
5
  SHA512:
6
- metadata.gz: 87b788844121f6292ed1a30a0a3c0daef5bf557412f63d7be20d99ad89c7296e9e6c85c7aeb6a38661e9160aa3e6618fd76872df906e7a6a551a26b5a6a0317e
7
- data.tar.gz: da6a6ac73e6539c5453121157b31f8767bb57a3a10a02c0c37f0e657662b4b0cd5f4ffa8f861ebf553c69d7434caa073aea200af96be0406fc99359941716526
6
+ metadata.gz: 15ffab1349deebca7d5e98fc60722a7f7344f05a663956e5ac1ad739006974625b4a0bf29407e789c803535921dee2e342c06e00b55a772bccd85e938678045b
7
+ data.tar.gz: 89970d924cdab95da38ef2ab0f79aa7f5c0795769bdc50b7ef9f97b139adba65f93f726d842fdb84d0b23aae9e454ee003dfccf28f488d2b23aa9f65c58f2934
data/.travis.yml CHANGED
@@ -6,7 +6,7 @@ rvm:
6
6
  - 2.2
7
7
  - jruby
8
8
  jdk:
9
- - oraclejdk8
9
+ - openjdk8
10
10
 
11
11
  before_install:
12
12
  - gem --version
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
- + [Getting started](#getting-started-)
12
- + [Usage](#usage)
13
- + [Migrating from pervious versions](#migrating-from-previous-versions)
14
- + [Development](#development)
15
- + [FAQ](#faq-)
16
- + [Contribute](#contribute-)
17
- + [License](#license-)
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.4.0` in your `Gemfile` and run `bundle install`.
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
- + Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/swiftype/swiftype-rb/issues).
463
- + Please write simple code and concise documentation, when appropriate.
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
 
@@ -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
@@ -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 != ''
@@ -1,3 +1,3 @@
1
1
  module Swiftype
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
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.0
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-02-15 00:00:00.000000000 Z
12
+ date: 2019-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec