elastic-site-search 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +20 -9
- data/README.md +1 -1
- data/lib/elastic-site-search.rb +1 -0
- data/lib/elastic/site-search/exceptions.rb +6 -0
- data/lib/elastic/site-search/request.rb +18 -10
- data/lib/elastic/site-search/version.rb +1 -1
- metadata +5 -4
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 382515c8c38a1933e31fd980bc0951a3f366c66097553283d4de306f5b134cd4
|
4
|
+
data.tar.gz: 670a1f44b00fed5ee5ba3bfb9611ed2657a3f50ef7299bbd32c89efecb1c7206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 183d39ff3f62f43c3c695a96b74daeac3d99627b90e0ff18b355fdc45b9456cfbd7ecc5bfa3ac39e721e835b5d83e32c680bd8667729c855c09619eda187462c
|
7
|
+
data.tar.gz: d5f41d5165c203221a13123cff1621e6e7f62d7a3425926c9ab1095f34bb6654331bf357308e1a7160efda636cacccff6063c9d2db42378aba928035a67aaa8c
|
data/.circleci/config.yml
CHANGED
@@ -2,17 +2,20 @@
|
|
2
2
|
#
|
3
3
|
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
4
|
#
|
5
|
-
version: 2
|
5
|
+
version: 2.1
|
6
|
+
|
7
|
+
executors:
|
8
|
+
ruby-24: { docker: [{ image: "ruby:2.4" }] }
|
9
|
+
ruby-25: { docker: [{ image: "ruby:2.5" }] }
|
10
|
+
ruby-26: { docker: [{ image: "ruby:2.6" }] }
|
11
|
+
jruby-92: { docker: [{ image: "jruby:9.2.7-jdk" }] }
|
12
|
+
|
6
13
|
jobs:
|
7
14
|
build:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# Specify service dependencies here if necessary
|
13
|
-
# CircleCI maintains a library of pre-built images
|
14
|
-
# documented at https://circleci.com/docs/2.0/circleci-images/
|
15
|
-
# - image: circleci/postgres:9.4
|
15
|
+
parameters:
|
16
|
+
executor:
|
17
|
+
type: executor
|
18
|
+
executor: << parameters.executor >>
|
16
19
|
|
17
20
|
working_directory: ~/repo
|
18
21
|
|
@@ -56,3 +59,11 @@ jobs:
|
|
56
59
|
- store_artifacts:
|
57
60
|
path: /tmp/test-results
|
58
61
|
destination: test-results
|
62
|
+
|
63
|
+
workflows:
|
64
|
+
run-tests:
|
65
|
+
jobs:
|
66
|
+
- build: { name: run-tests-ruby-2.4, executor: ruby-24 }
|
67
|
+
- build: { name: run-tests-ruby-2.5, executor: ruby-25 }
|
68
|
+
- build: { name: run-tests-ruby-2.6, executor: ruby-26 }
|
69
|
+
- build: { name: run-tests-jruby-92, executor: jruby-92 }
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ To install the gem, execute:
|
|
46
46
|
|
47
47
|
gem install elastic-site-search
|
48
48
|
|
49
|
-
Or place `gem 'elastic-site-search', '~> 2.
|
49
|
+
Or place `gem 'elastic-site-search', '~> 2.1.0` in your `Gemfile` and run `bundle install`.
|
50
50
|
|
51
51
|
> **Note:** This client has been developed for the [Elastic Site Search](https://www.elastic.co/products/site-search/service) API endpoints only.
|
52
52
|
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'elastic/site-search'
|
@@ -7,5 +7,11 @@ module Elastic
|
|
7
7
|
class BadRequest < ClientException; end
|
8
8
|
class Forbidden < ClientException; end
|
9
9
|
class UnexpectedHTTPException < ClientException; end
|
10
|
+
|
11
|
+
class ServerException < StandardError; end
|
12
|
+
class InternalServerError < ServerException; end
|
13
|
+
class BadGateway < ServerException; end
|
14
|
+
class ServiceUnavailable < ServerException; end
|
15
|
+
class GatewayTimeout < ServerException; end
|
10
16
|
end
|
11
17
|
end
|
@@ -93,21 +93,29 @@ module Elastic
|
|
93
93
|
case response
|
94
94
|
when Net::HTTPSuccess
|
95
95
|
response
|
96
|
-
when Net::HTTPUnauthorized
|
97
|
-
raise Elastic::SiteSearch::InvalidCredentials, error_message_from_response(response)
|
98
|
-
when Net::HTTPNotFound
|
99
|
-
raise Elastic::SiteSearch::NonExistentRecord, error_message_from_response(response)
|
100
|
-
when Net::HTTPConflict
|
101
|
-
raise Elastic::SiteSearch::RecordAlreadyExists, error_message_from_response(response)
|
102
|
-
when Net::HTTPBadRequest
|
103
|
-
raise Elastic::SiteSearch::BadRequest, error_message_from_response(response)
|
104
|
-
when Net::HTTPForbidden
|
105
|
-
raise Elastic::SiteSearch::Forbidden, error_message_from_response(response)
|
106
96
|
else
|
97
|
+
EXCEPTION_MAP.each do |response_class, exception_class|
|
98
|
+
if response.is_a?(response_class)
|
99
|
+
raise exception_class, error_message_from_response(response)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
107
103
|
raise Elastic::SiteSearch::UnexpectedHTTPException, "#{response.code} #{response.body}"
|
108
104
|
end
|
109
105
|
end
|
110
106
|
|
107
|
+
EXCEPTION_MAP = {
|
108
|
+
Net::HTTPUnauthorized => Elastic::SiteSearch::InvalidCredentials,
|
109
|
+
Net::HTTPNotFound => Elastic::SiteSearch::NonExistentRecord,
|
110
|
+
Net::HTTPConflict => Elastic::SiteSearch::RecordAlreadyExists,
|
111
|
+
Net::HTTPBadRequest => Elastic::SiteSearch::BadRequest,
|
112
|
+
Net::HTTPForbidden => Elastic::SiteSearch::Forbidden,
|
113
|
+
Net::HTTPInternalServerError => Elastic::SiteSearch::InternalServerError,
|
114
|
+
Net::HTTPBadGateway => Elastic::SiteSearch::BadGateway,
|
115
|
+
Net::HTTPServiceUnavailable => Elastic::SiteSearch::ServiceUnavailable,
|
116
|
+
Net::HTTPGatewayTimeOut => Elastic::SiteSearch::GatewayTimeout
|
117
|
+
}.freeze
|
118
|
+
|
111
119
|
def error_message_from_response(response)
|
112
120
|
body = response.body
|
113
121
|
json = JSON.parse(body) if body && body.strip != ''
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic-site-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.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-09-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -77,7 +77,6 @@ extra_rdoc_files: []
|
|
77
77
|
files:
|
78
78
|
- ".circleci/config.yml"
|
79
79
|
- ".gitignore"
|
80
|
-
- ".travis.yml"
|
81
80
|
- Gemfile
|
82
81
|
- LICENSE.txt
|
83
82
|
- NOTICE.txt
|
@@ -85,6 +84,7 @@ files:
|
|
85
84
|
- Rakefile
|
86
85
|
- elastic-site-search.gemspec
|
87
86
|
- lib/data/ca-bundle.crt
|
87
|
+
- lib/elastic-site-search.rb
|
88
88
|
- lib/elastic/site-search.rb
|
89
89
|
- lib/elastic/site-search/client.rb
|
90
90
|
- lib/elastic/site-search/configuration.rb
|
@@ -193,7 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
|
-
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 2.7.6
|
197
198
|
signing_key:
|
198
199
|
specification_version: 4
|
199
200
|
summary: Official gem for accessing the Elastic Site Search API
|