stretcher 1.18.0 → 1.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aab209cb636509b1ea78274d43c5865b7e97f469
4
- data.tar.gz: 3db9ef4414c2d1cef9890a1fecc3c4f45a1789d4
3
+ metadata.gz: 687ea05d11e4a6f9e96deaf8127a85105b170819
4
+ data.tar.gz: 467daf1b89a43624ea66de6e0fcb4f0575f96d4c
5
5
  SHA512:
6
- metadata.gz: fa737ad3d822e0411bcd66352f360865299e9eb616833ef1dd2cc9528cc91470f932fca9d39deb2d906b54643ef88fb0e947423b0d8903496e94b914596bf36d
7
- data.tar.gz: 6be736d5a2dd82d0aeb10aca7997d2ac57aa86f52c5a549ed3d95ac8707d4e1ed2b77f918e140df46b912ef75372f70933852b9419a168d884bb12a08cbff6f1
6
+ metadata.gz: aeec19b3c20a5664f6b4be9b42fa01929b40315bb8baf3c75de8d5ca4b6a6655c8f1f1399e37ddb0aaedd73adbba062f4be095af9d10cac1c4782348127f4480
7
+ data.tar.gz: cacffffb224c51feaec032292e63df52b7ae3017ff72e50692bd0b03992d2953eaf3bd4e7dd331882434d3e53622bf5654631f36f1e307be7cbdb5aad27124c4
@@ -4,8 +4,8 @@ module Stretcher
4
4
 
5
5
  # Internal use only.
6
6
  # Returns a properly configured HTTP client when initializing an instance
7
- def self.build_client(uri, options={})
8
- http = Faraday.new(:url => uri) do |builder|
7
+ def self.build_client(uri_components, options={})
8
+ http = Faraday.new(:url => uri_components) do |builder|
9
9
  builder.response :mashify
10
10
  builder.response :multi_json, :content_type => /\bjson$/
11
11
 
@@ -26,7 +26,6 @@ module Stretcher
26
26
  "Content-Type" => "application/json"
27
27
  }
28
28
 
29
- uri_components = URI.parse(uri)
30
29
  if uri_components.user || uri_components.password
31
30
  http.basic_auth(uri_components.user, uri_components.password)
32
31
  end
@@ -73,10 +72,15 @@ module Stretcher
73
72
  # For instance:
74
73
  # configurator = proc {|builder| builder.adapter :typhoeus
75
74
  # Stretcher::Server.new('http://localhost:9200', :faraday_configurator => configurator)
75
+ #
76
+ # You may want to set one or both of :read_timeout and :open_timeout, for Faraday's HTTP
77
+ # settings. The default is read_timeout: 30, open_timeout: 2, which can be quite long
78
+ # in many situations
76
79
  def initialize(uri='http://localhost:9200', options={})
77
80
  @request_mtx = Mutex.new
78
- @uri = uri
79
- @http = self.class.build_client(@uri, options)
81
+ @uri = uri.to_s
82
+ @uri_components = URI.parse(@uri)
83
+ @http = self.class.build_client(@uri_components, options)
80
84
  @logger = self.class.build_logger(options)
81
85
  end
82
86
 
@@ -196,7 +200,7 @@ module Stretcher
196
200
 
197
201
  # Full path to the server root dir
198
202
  def path_uri(path=nil)
199
- URI.join(@uri.to_s, path.to_s).to_s
203
+ URI.join(@uri.to_s, "#{@uri_components.path}/#{path.to_s}").to_s
200
204
  end
201
205
 
202
206
  # Handy way to query the server, returning *only* the body
@@ -1,3 +1,3 @@
1
1
  module Stretcher
2
- VERSION = "1.18.0"
2
+ VERSION = "1.18.1"
3
3
  end
@@ -102,6 +102,11 @@ describe Stretcher::Server do
102
102
  subject { Stretcher::Server.new("http://example.com").path_uri("/foo") }
103
103
  it { should eq ("http://example.com/foo") }
104
104
  end
105
+
106
+ context "server lives in a subdirectory" do
107
+ subject { Stretcher::Server.new("http://example.com/mysubdir/").path_uri("/foo") }
108
+ it { should eq ("http://example.com/mysubdir/foo") }
109
+ end
105
110
  end
106
111
 
107
112
  describe "#get_alias" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stretcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Cholakian