swiftype 1.3.1 → 1.4.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: 609560031bf1a36701d32f22fbc01c0ed04db4df4543f500bc792d25a2d07f42
4
- data.tar.gz: 84faa09349226885040f1dada03ae7d9908e1ff7e116dff07d7a7db9dc1975f1
3
+ metadata.gz: f63edc94df155455010fd47771121ec305c74be186603f962e59757d55cde739
4
+ data.tar.gz: 4e2a84363c431549d456c61ab289a6f6432b802a29e28776a22da65836c2021b
5
5
  SHA512:
6
- metadata.gz: 0d1ae4174700c37367c252bcbbadc19e145c5b93490a21f43af8cb1c44be2f93709c034e8ca84ace786155c202809e5d1ed1e84352e1a8f9f282306f9c2c5cbc
7
- data.tar.gz: 77f6252035f93a12806153bc17ace03f5fad21a048e67c9e84cce760b8126d075c5ac99004b1f594f4cafa70a2035a6e5a6b0f2d612ddf5aa4a5f92005a68e0f
6
+ metadata.gz: 87b788844121f6292ed1a30a0a3c0daef5bf557412f63d7be20d99ad89c7296e9e6c85c7aeb6a38661e9160aa3e6618fd76872df906e7a6a551a26b5a6a0317e
7
+ data.tar.gz: da6a6ac73e6539c5453121157b31f8767bb57a3a10a02c0c37f0e657662b4b0cd5f4ffa8f861ebf553c69d7434caa073aea200af96be0406fc99359941716526
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  script: rspec
3
3
  rvm:
4
- - 1.9
5
4
  - 2.0
6
5
  - 2.1
7
6
  - 2.2
@@ -10,6 +9,5 @@ jdk:
10
9
  - oraclejdk8
11
10
 
12
11
  before_install:
13
- - gem update --system
14
12
  - gem --version
15
13
  - gem update bundler
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Elastic Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,32 +1,56 @@
1
- # Ruby Client for Swiftype Site Search API
2
1
 
3
- [![Build Status](https://travis-ci.org/swiftype/swiftype-rb.png)](https://travis-ci.org/swiftype/swiftype-rb)
2
+ <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>
4
3
 
5
- This is a simple client for the [Swiftype Site Search API](https://swiftype.com/documentation/site-search/overview) with no dependencies outside core Ruby (for 1.9 and 2.0; Ruby 1.8 requires the JSON gem).
4
+ <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>
5
+ <a href="https://github.com/swiftype/swiftype-rb/releases"><img src="https://img.shields.io/github/release/swiftype/swiftype-rb/all.svg?style=flat-square" alt="GitHub release" /></a></p>
6
6
 
7
- > **Note:** This client has been developed for the [Swiftype Site Search](https://www.swiftype.com/site-search) API endpoints only.
7
+ > A first-party Ruby client for the [Elastic Site Search API](https://swiftype.com/documentation/site-search/overview).
8
+
9
+ ## Contents
10
+
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-)
18
+
19
+ ***
20
+
21
+ ## Getting started 🐣
22
+
23
+ Before beginning with the Swiftype gem, you should be familar with the concepts behind the Swiftype API:
8
24
 
9
- ## Getting Started
25
+ 1. **Engines**
26
+ 2. **DocumentTypes**
27
+ 3. **Documents**
10
28
 
11
- Before beginning with the Swiftype gem, you should be familar with the concepts behind the Swiftype API: **Engines**, **DocumentTypes**, and **Documents**.
29
+ An **Engine** is a search engine.
12
30
 
13
- An **Engine** is a search engine. It can contain one or more **DocumentTypes** which are collections of **Documents**. A **Document** is a collection of fields that can be queried using the Swiftype API. Documents have a special **external_id** field that ties a Document in Swiftype to a record in your system. The layout of fields of the Documents belonging to a DocumentType is called a **schema**. Fields may be strings, integers, geographic locations, and so forth.
31
+ It can contain one or more **DocumentTypes** which are collections of **Documents**.
32
+
33
+ A **Document** is a collection of fields that can be queried using the Swiftype API.
34
+
35
+ Documents have a special **external_id** field that ties a Document in Swiftype to a record in your system. The layout of fields of the Documents belonging to a DocumentType is called a **schema**. Fields may be strings, integers, geographic locations, and so forth.
14
36
 
15
37
  The Documents in your Engine can be searched two ways: **full-text** (`search`) or **autocomplete** (`suggest`). The difference is that autocomplete queries work on prefixes (for example, "gla" will match "glass"). This is less accurate in general, but is useful for implementing type-ahead search drop downs.
16
38
 
17
- You can think of an Engine as a database, DocumentTypes as tables, and Documents as rows. Using the API, you can search an engine for all Documents containing a word. You can also search an individual DocumentType, or any subset of DocumentTypes.
39
+ You can think of an Engine as a database, DocumentTypes as tables, and Documents as rows. Using the API, you can search an Engine for all Documents containing a word. You can also search an individual DocumentType, or any subset of DocumentTypes.
18
40
 
19
41
  The examples in this documentation use the schema defined in the [swiftype-api-example](https://github.com/swiftype/swiftype-api-example) project, which is based on YouTube. It has two DocumentTypes, **videos** and **channels**. Using the script found in the swiftype-api-example project, you can create your own search engine that matches the examples and try the queries for yourself.
20
42
 
21
43
  To learn more about the Swiftype API, read the [API overview](https://swiftype.com/documentation/overview) and our [schema design tutorial](https://swiftype.com/documentation/tutorials/schema_design).
22
44
 
23
- ## Installation
45
+ Depends on Ruby.
24
46
 
25
47
  To install the gem, execute:
26
48
 
27
49
  gem install swiftype
28
50
 
29
- Or place `gem 'swiftype', '~> 1.3.1` in your `Gemfile` and run `bundle install`.
51
+ Or place `gem 'swiftype', '~> 1.4.0` in your `Gemfile` and run `bundle install`.
52
+
53
+ > **Note:** This client has been developed for the [Swiftype Site Search](https://www.swiftype.com/site-search) API endpoints only.
30
54
 
31
55
  ## Usage
32
56
 
@@ -413,6 +437,33 @@ or simply `Swiftype.api_key = 'your_api_key'`.
413
437
 
414
438
  ## Development
415
439
 
416
- You can run tests with `rspec`. All HTTP interactions are stubbed out using VCR.
440
+ You can run tests with `rspec`.
441
+
442
+ All HTTP interactions are stubbed out using VCR.
443
+
444
+ ## FAQ 🔮
445
+
446
+ ### Where do I report issues with the client?
447
+
448
+ If something is not working as expected, please open an [issue](https://github.com/swiftype/swiftype-rb/issues/new).
449
+
450
+ ### Where can I learn more about Site Search?
451
+
452
+ Your best bet is to read the [documentation](https://swiftype.com/documentation/site-search).
453
+
454
+ ### Where else can I go to get help?
455
+
456
+ You can checkout the [Elastic Site Search community discuss forums](https://discuss.elastic.co/c/site-search).
457
+
458
+ ## Contribute 🚀
459
+
460
+ We welcome contributors to the project. Before you begin, a couple notes...
461
+
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.
464
+
465
+ ## License 📗
466
+
467
+ [MIT](https://github.com/swiftype/swiftype-rb/blob/master/LICENSE) © [Elastic](https://github.com/elastic)
417
468
 
418
- To contribute code to this gem, please fork the repository and submit a pull request.
469
+ Thank you to all the [contributors](https://github.com/swiftype/swiftype-rb/graphs/contributors)!
@@ -90,20 +90,29 @@ module Swiftype
90
90
  when Net::HTTPSuccess
91
91
  response
92
92
  when Net::HTTPUnauthorized
93
- raise Swiftype::InvalidCredentials
93
+ raise Swiftype::InvalidCredentials, error_message_from_response(response)
94
94
  when Net::HTTPNotFound
95
- raise Swiftype::NonExistentRecord
95
+ raise Swiftype::NonExistentRecord, error_message_from_response(response)
96
96
  when Net::HTTPConflict
97
- raise Swiftype::RecordAlreadyExists
97
+ raise Swiftype::RecordAlreadyExists, error_message_from_response(response)
98
98
  when Net::HTTPBadRequest
99
- raise Swiftype::BadRequest
99
+ raise Swiftype::BadRequest, error_message_from_response(response)
100
100
  when Net::HTTPForbidden
101
- raise Swiftype::Forbidden
101
+ raise Swiftype::Forbidden, error_message_from_response(response)
102
102
  else
103
103
  raise Swiftype::UnexpectedHTTPException, "#{response.code} #{response.body}"
104
104
  end
105
105
  end
106
106
 
107
+ def error_message_from_response(response)
108
+ body = response.body
109
+ json = JSON.parse(body) if body && body.strip != ''
110
+ return json['error'] if json && json.key?('error')
111
+ body
112
+ rescue JSON::ParserError
113
+ body
114
+ end
115
+
107
116
  def build_request(method, uri, params)
108
117
  klass = case method
109
118
  when :get
@@ -1,3 +1,3 @@
1
1
  module Swiftype
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
Binary file
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.3.1
4
+ version: 1.4.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: 2018-10-18 00:00:00.000000000 Z
12
+ date: 2019-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -78,7 +78,7 @@ files:
78
78
  - ".gitignore"
79
79
  - ".travis.yml"
80
80
  - Gemfile
81
- - LICENSE.txt
81
+ - LICENSE
82
82
  - README.md
83
83
  - Rakefile
84
84
  - lib/data/ca-bundle.crt
@@ -91,6 +91,7 @@ files:
91
91
  - lib/swiftype/result_set.rb
92
92
  - lib/swiftype/sso.rb
93
93
  - lib/swiftype/version.rb
94
+ - logo-site-search.png
94
95
  - spec/client_spec.rb
95
96
  - spec/configuration_spec.rb
96
97
  - spec/deprecated_spec.rb
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- Copyright 2012 Swiftype, Inc.
2
- http://swiftype.com/
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.