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 +4 -4
- data/lib/stretcher/server.rb +10 -6
- data/lib/stretcher/version.rb +1 -1
- data/spec/lib/stretcher_server_spec.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 687ea05d11e4a6f9e96deaf8127a85105b170819
|
4
|
+
data.tar.gz: 467daf1b89a43624ea66de6e0fcb4f0575f96d4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeec19b3c20a5664f6b4be9b42fa01929b40315bb8baf3c75de8d5ca4b6a6655c8f1f1399e37ddb0aaedd73adbba062f4be095af9d10cac1c4782348127f4480
|
7
|
+
data.tar.gz: cacffffb224c51feaec032292e63df52b7ae3017ff72e50692bd0b03992d2953eaf3bd4e7dd331882434d3e53622bf5654631f36f1e307be7cbdb5aad27124c4
|
data/lib/stretcher/server.rb
CHANGED
@@ -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(
|
8
|
-
http = Faraday.new(:url =>
|
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
|
-
@
|
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
|
data/lib/stretcher/version.rb
CHANGED
@@ -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
|