swiftype 1.2.3 → 1.3.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: add2978c79c2494fc993252665bc65af92383ad5a00dc8e86eaae70114059aac
4
- data.tar.gz: 5b03ebc6b72eca5793c0264c03db5b18150cc6de88daeabebb6d95fbc352c463
3
+ metadata.gz: bd466837b8766de157a54c3b8524e148ffde51c647e09ad4094cee027af6e105
4
+ data.tar.gz: 21f8de0c94f70755db7534181bc653ecabb85f6f94a824176f2cc8887e87a271
5
5
  SHA512:
6
- metadata.gz: 4b5db4bfafb4975ed03ae34ebcdd86ce13aa8e5ccad65260608626dab59e4a61de4a56fda4731472289a758e0cf2d0a286f496ab90baa4a2841a9e1e9b04634f
7
- data.tar.gz: b6d111e80d985366e60ed382d37183bd1fa72dd5fed5e8661f04ef4ef6d9f255cc6ebe121f2e1a96c10fa2532e27126effc4f5969579d841f0fe2e90ef507867
6
+ metadata.gz: '049de7bc87c7421f72018cdca475f2e877d7a21c112430f27254944fdd1acda197dfe04f7209391e257313a290bbd9aa8f183ec45343f6ad8f55a70a3fc403a2'
7
+ data.tar.gz: 2f45c1a6fc68d64c0968ee3567b10d98cbebc6a326ba06c07f719886151226b1fa656daace9cb21837b8bd2eaa0c8c3f58c08a6b2024447e64f3d7bc69b85199
data/README.md CHANGED
@@ -52,6 +52,12 @@ You can also provide the API key when creating the client instance:
52
52
 
53
53
  If the API key is provided as an option to constructor, it will override the globally configured Swiftype API key (if any).
54
54
 
55
+ ### Specifying an HTTP Proxy
56
+
57
+ client = Swiftype::Client.new(:api_key => 'api_key', :proxy => 'http://localhost:8888')
58
+
59
+ This client will also support configuring a proxy via the environment variable `http_proxy`.
60
+
55
61
  ### Full-text search
56
62
 
57
63
  If you want to search for `cat` on your engine, you can use:
@@ -185,7 +191,7 @@ Update multiple Documents at once:
185
191
  ])
186
192
 
187
193
  All methods above will have a return in the following format:
188
-
194
+
189
195
  [
190
196
  {
191
197
  "id": "5473d6142ed96065a9000001",
@@ -410,4 +416,3 @@ or simply `Swiftype.api_key = 'your_api_key'`.
410
416
  You can run tests with `rspec`. All HTTP interactions are stubbed out using VCR.
411
417
 
412
418
  To contribute code to this gem, please fork the repository and submit a pull request.
413
-
@@ -21,6 +21,7 @@ module Swiftype
21
21
  # @option options [String] :platform_access_token a user's access token, will be used instead of API key for authenticating requests
22
22
  # @option options [Numeric] :overall_timeout overall timeout for requests in seconds (default: 15s)
23
23
  # @option options [Numeric] :open_timeout the number of seconds Net::HTTP (default: 15s)
24
+ # @option options [String] :proxy url of proxy to use, ex: "http://localhost:8888"
24
25
  # will wait while opening a connection before raising a Timeout::Error
25
26
 
26
27
  def initialize(options={})
@@ -35,6 +36,10 @@ module Swiftype
35
36
  @options[:platform_access_token]
36
37
  end
37
38
 
39
+ def proxy
40
+ @options[:proxy]
41
+ end
42
+
38
43
  def open_timeout
39
44
  @options[:open_timeout] || DEFAULT_TIMEOUT
40
45
  end
@@ -57,7 +57,14 @@ module Swiftype
57
57
  uri = URI.parse("#{Swiftype.endpoint}#{path}")
58
58
 
59
59
  request = build_request(method, uri, params)
60
- http = Net::HTTP.new(uri.host, uri.port)
60
+
61
+ if proxy
62
+ proxy_parts = URI.parse(proxy)
63
+ http = Net::HTTP.new(uri.host, uri.port, proxy_parts.host, proxy_parts.port)
64
+ else
65
+ http = Net::HTTP.new(uri.host, uri.port)
66
+ end
67
+
61
68
  http.open_timeout = open_timeout
62
69
  http.read_timeout = overall_timeout
63
70
 
@@ -1,3 +1,3 @@
1
1
  module Swiftype
2
- VERSION = "1.2.3"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -101,6 +101,23 @@ describe Swiftype::Client do
101
101
  end
102
102
  end
103
103
  end
104
+
105
+ context 'with proxy specified' do
106
+ let(:options) { { :proxy => 'http://localhost:8888' } }
107
+
108
+ it 'will set proxy' do
109
+ expect(options_client.proxy).to eq('http://localhost:8888')
110
+ end
111
+
112
+ # There doesn't seem to be an elgant way to test that a request actually uses a proxy, so the best
113
+ # we can do here is ensure that the behavior for methods operates normally
114
+ it 'will execute methods with proxy' do
115
+ VCR.use_cassette(:engine_search) do
116
+ results = options_client.search(engine_slug, 'cat')
117
+ expect(results.document_types.size).to eq(2)
118
+ end
119
+ end
120
+ end
104
121
  end
105
122
  end
106
123
 
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.2.3
4
+ version: 1.3.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-09-24 00:00:00.000000000 Z
12
+ date: 2018-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec