escobar 0.3.7 → 0.3.8

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
  SHA1:
3
- metadata.gz: 818af7f171a0a33c85bd92022a7a2cba7a432e21
4
- data.tar.gz: 06e29aae8f106042c8ef123494320b86f5344d4f
3
+ metadata.gz: 0bed76fa019336ccd8f401df62b43d859f103e89
4
+ data.tar.gz: 2cb3b526239b70ca434128d71eb1c566bffa10a8
5
5
  SHA512:
6
- metadata.gz: 0d61a8b5522ec3b50571813100941466e4d3afbcbb17c08f692cf9d8634980dcd1a23243a06d7c8b1774dfb82ab1134a8bb7a696355e1163839680dff3d2532d
7
- data.tar.gz: 4a2c823ffd0f878948ae3c0cec6d0d07852a93dad4d372925029049f7b5c469a93a8e1cd775c99f8057f4560d9dddb5181b23b854edbad34774fdcc1f6b965cd
6
+ metadata.gz: 731b0a552e481ad657f2dd53bd3b9f985fe419fa5aa3571fcf88bbc32c2fc53fdb1dcf2162f1347d1cbd484679ace5821510f3c987a9251c3011746f5fcf579b
7
+ data.tar.gz: a188f2251e311d1c34a9b67306321e57e45201eb62604646ef718b3e81d1317c13feb25b095875ec296fe1f4514f790440b4da72c1ef2aeab08b2a4a25a99284
@@ -92,6 +92,8 @@ module Escobar
92
92
  request.headers["Accept"] = accept_headers
93
93
  request.headers["Content-Type"] = "application/json"
94
94
  request.headers["Authorization"] = "token #{token}"
95
+ request.options.timeout = 5
96
+ request.options.open_timeout = 2
95
97
  end
96
98
  end
97
99
 
@@ -101,6 +103,8 @@ module Escobar
101
103
  request.headers["Accept"] = accept_headers
102
104
  request.headers["Content-Type"] = "application/json"
103
105
  request.headers["Authorization"] = "token #{token}"
106
+ request.options.timeout = 5
107
+ request.options.open_timeout = 2
104
108
  request.body = body.to_json
105
109
  end
106
110
 
@@ -15,13 +15,14 @@ module Escobar
15
15
  inspected
16
16
  end
17
17
 
18
+ def user_information
19
+ get("/account")
20
+ end
21
+
18
22
  def get(path, version = 3)
19
23
  response = client.get do |request|
20
24
  request.url path
21
- request.headers["Accept"] = heroku_accept_header(version)
22
- request.headers["Accept-Encoding"] = ""
23
- request.headers["Content-Type"] = "application/json"
24
- request.headers["Authorization"] = "Bearer #{token}"
25
+ request_defaults(request, version)
25
26
  end
26
27
 
27
28
  JSON.parse(response.body)
@@ -32,11 +33,8 @@ module Escobar
32
33
  def get_range(path, range, version = 3)
33
34
  response = client.get do |request|
34
35
  request.url path
35
- request.headers["Accept"] = heroku_accept_header(version)
36
- request.headers["Accept-Encoding"] = ""
37
- request.headers["Content-Type"] = "application/json"
38
- request.headers["Authorization"] = "Bearer #{token}"
39
- request.headers["Range"] = range
36
+ request_defaults(request, version)
37
+ request.headers["Range"] = range
40
38
  end
41
39
 
42
40
  JSON.parse(response.body)
@@ -47,12 +45,7 @@ module Escobar
47
45
  def post(path, body)
48
46
  response = client.post do |request|
49
47
  request.url path
50
- request.headers["Accept"] = heroku_accept_header(3)
51
- request.headers["Accept-Encoding"] = ""
52
- request.headers["Content-Type"] = "application/json"
53
- if token
54
- request.headers["Authorization"] = "Bearer #{token}"
55
- end
48
+ request_defaults(request)
56
49
  request.body = body.to_json
57
50
  end
58
51
 
@@ -64,10 +57,7 @@ module Escobar
64
57
  def put(path, second_factor = nil)
65
58
  response = client.put do |request|
66
59
  request.url path
67
- request.headers["Accept"] = heroku_accept_header(3)
68
- request.headers["Accept-Encoding"] = ""
69
- request.headers["Content-Type"] = "application/json"
70
- request.headers["Authorization"] = "Bearer #{token}"
60
+ request_defaults(request)
71
61
  if second_factor
72
62
  request.headers["Heroku-Two-Factor-Code"] = second_factor
73
63
  end
@@ -80,6 +70,17 @@ module Escobar
80
70
 
81
71
  private
82
72
 
73
+ def request_defaults(request, version = 3)
74
+ request.headers["Accept"] = heroku_accept_header(version)
75
+ request.headers["Accept-Encoding"] = ""
76
+ request.headers["Content-Type"] = "application/json"
77
+ if token
78
+ request.headers["Authorization"] = "Bearer #{token}"
79
+ end
80
+ request.options.timeout = 5
81
+ request.options.open_timeout = 2
82
+ end
83
+
83
84
  def heroku_accept_header(version)
84
85
  "application/vnd.heroku+json; version=#{version}"
85
86
  end
@@ -1,3 +1,3 @@
1
1
  module Escobar
2
- VERSION = "0.3.7".freeze
2
+ VERSION = "0.3.8".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escobar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Donohoe