stf-client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stf/client.rb +22 -7
- data/lib/stf/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: 0b55ff5a67a849151ac73d524d6086e11468ccf8
|
4
|
+
data.tar.gz: 890d3966ce8dbaa65842dc8f14b5b434358d3d28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e895e08348b578ae4e3182aed554a02237c9a84e2c2a290146df0b8e4ed594077ee5759c7358d9802b74466662c73e110974cb20d504a3d01f3a61bb3ed41c8
|
7
|
+
data.tar.gz: 3eb12ca9218b4da7aedf6c6f7d8058b993e717a45375e29aa904792777e29aa84e07fbf5c5d052247db1a153940e76bbc047bfe120298ec6c3c1f08a5fc31f29
|
data/lib/stf/client.rb
CHANGED
@@ -58,18 +58,33 @@ module Stf
|
|
58
58
|
private
|
59
59
|
|
60
60
|
def execute(relative_url, type, body='')
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
return execute_absolute @base_url + relative_url, type, body
|
62
|
+
end
|
63
|
+
|
64
|
+
def execute_absolute(url, type, body='', limit = 10)
|
65
|
+
raise ArgumentError, 'too many HTTP redirects' if limit == 0
|
66
|
+
|
67
|
+
uri = URI.parse(url)
|
68
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
69
|
+
http.use_ssl = true if uri.scheme == 'https'
|
70
|
+
request = type.new(uri, 'Authorization' => "Bearer #{@token}", 'Content-Type' => 'application/json')
|
64
71
|
request.body = body
|
65
72
|
response = http.request(request)
|
66
73
|
|
74
|
+
case response
|
75
|
+
when Net::HTTPSuccess then
|
76
|
+
json = JSON.parse(response.body, object_class: OpenStruct)
|
67
77
|
|
68
|
-
|
69
|
-
|
70
|
-
|
78
|
+
logger.debug "API returned #{json}"
|
79
|
+
when Net::HTTPRedirection then
|
80
|
+
location = response['location']
|
81
|
+
logger.debug "redirected to #{location}"
|
82
|
+
return execute_absolute(location, type, body, limit - 1)
|
83
|
+
else
|
84
|
+
logger.error "API returned #{response.value}"
|
85
|
+
end
|
71
86
|
|
72
87
|
return json
|
73
88
|
end
|
74
89
|
end
|
75
|
-
end
|
90
|
+
end
|
data/lib/stf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stf-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Malinskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.6.12
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Request devices from Smartphone Test Farm for adb connection
|