served 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/served/http_client.rb +5 -4
- data/lib/served/resource/base.rb +6 -1
- data/lib/served/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 441c7ca5f9f68f1df1cae462d85d60a50b50cdc8
|
4
|
+
data.tar.gz: 74b53138ad506df5fb5ad69f95f8218d7aeb1202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 666239cf535c226548af6e029f5c2883da475c4131291167b7ee9482953ef197362fe36489a9f62dd34b17918b42a0f91a1c6bf08434687f845a4e3746d3ce7a
|
7
|
+
data.tar.gz: 472b45163683b788ddd9b023a18cd04daf8fe9897d2d31e41c972000d2fd3b1e1e955bd6ed2914f22d8208a0cfc68db309724e2f7178f59da05e7c6af19d5eb4
|
data/lib/served/http_client.rb
CHANGED
@@ -5,15 +5,16 @@ module Served
|
|
5
5
|
HEADERS = { 'Content-type' => 'application/json', 'Accept' => 'application/json' }
|
6
6
|
DEFAULT_TEMPLATE = '{/resource*}{/id}.json{?query*}'
|
7
7
|
|
8
|
-
def initialize(host)
|
8
|
+
def initialize(host, timeout)
|
9
9
|
host += DEFAULT_TEMPLATE unless host =~ /{.+}/
|
10
10
|
@template = Addressable::Template.new(host)
|
11
|
+
@timeout = timeout
|
11
12
|
end
|
12
13
|
|
13
14
|
def get(endpoint, id, params={})
|
14
15
|
HTTParty.get(@template.expand(id: id, query: params, resource: endpoint).to_s,
|
15
16
|
headers: HEADERS,
|
16
|
-
timeout:
|
17
|
+
timeout: @timeout
|
17
18
|
)
|
18
19
|
end
|
19
20
|
|
@@ -21,7 +22,7 @@ module Served
|
|
21
22
|
HTTParty.put(@template.expand(id: id, query: params, resource: endpoint).to_s,
|
22
23
|
body: body,
|
23
24
|
headers: HEADERS,
|
24
|
-
timeout:
|
25
|
+
timeout: @timeout
|
25
26
|
)
|
26
27
|
end
|
27
28
|
|
@@ -29,7 +30,7 @@ module Served
|
|
29
30
|
HTTParty.post(@template.expand(query: params, resource: endpoint).to_s,
|
30
31
|
body: body,
|
31
32
|
headers: HEADERS,
|
32
|
-
timeout:
|
33
|
+
timeout: @timeout
|
33
34
|
)
|
34
35
|
end
|
35
36
|
end
|
data/lib/served/resource/base.rb
CHANGED
@@ -53,10 +53,15 @@ module Served
|
|
53
53
|
Served.config[:hosts][parent.name.underscore.split('/')[-1]]
|
54
54
|
end
|
55
55
|
|
56
|
+
# @return [Integer] allowed timeout in seconds
|
57
|
+
def timeout
|
58
|
+
Served.config.timeout
|
59
|
+
end
|
60
|
+
|
56
61
|
# @return [Served::HTTPClient] The connection instance to the service host. Note this is not an active
|
57
62
|
# connection but a passive one.
|
58
63
|
def client
|
59
|
-
@connection ||= Served::HTTPClient.new(host_config)
|
64
|
+
@connection ||= Served::HTTPClient.new(host_config, timeout)
|
60
65
|
end
|
61
66
|
|
62
67
|
private
|
data/lib/served/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: served
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarod Reid
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.4.
|
143
|
+
rubygems_version: 2.4.8
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Served provides an easy to use model layer for communicating with disributed
|