gettc 2.0 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dist/config.yml +1 -1
- data/dist/template/bin/runner.rb +1 -1
- data/lib/gettc.rb +2 -2
- data/lib/gettc/download.rb +22 -32
- data/lib/version.rb +1 -1
- metadata +3 -7
- data/dist/include/python/topcoder/__pycache__/__init__.cpython-34.pyc +0 -0
- data/dist/include/python/topcoder/__pycache__/errors.cpython-34.pyc +0 -0
- data/dist/include/python/topcoder/__pycache__/reader.cpython-34.pyc +0 -0
- data/dist/include/python/topcoder/__pycache__/writer.cpython-34.pyc +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d458f0d3f5aa87fc10f1c8eaf91c20fb1fd73df1
|
4
|
+
data.tar.gz: 98d431c8dea677018c501bdcab0e68168de6e551
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2a49b45d3b4fd24115cd657a657349f53876b0ee7937788bc5771977aed0720dea6a2493fb5f73e59e9aa13274469d92cf2528983a55744767c8313b2564142
|
7
|
+
data.tar.gz: c35885d68e1e83dd3b62f13e51ac6d48ecdac20aa91a8da87ec5e4daea87459b89cfd3289b84b2cf79cf0e3ae928e33f46d6f62816b48726327d6bec34b3f6da
|
data/dist/config.yml
CHANGED
data/dist/template/bin/runner.rb
CHANGED
data/lib/gettc.rb
CHANGED
data/lib/gettc/download.rb
CHANGED
@@ -17,12 +17,8 @@ module Gettc
|
|
17
17
|
@request = request
|
18
18
|
@response = response
|
19
19
|
|
20
|
-
filename = "gettc_http_response-#{Time.now.to_i}.html"
|
21
|
-
File.write(filename, @response.body)
|
22
|
-
|
23
20
|
super [ message, "Request: #{get_url(@request)}", http_to_s(@request), @request.body,
|
24
|
-
"Response: #{@response.class.to_s}", http_to_s(@response),
|
25
|
-
"Response body written to #{filename}" ].join("\n")
|
21
|
+
"Response: #{@response.class.to_s}", http_to_s(@response), @response.body ].join("\n")
|
26
22
|
end
|
27
23
|
|
28
24
|
private
|
@@ -151,6 +147,27 @@ module Gettc
|
|
151
147
|
nil
|
152
148
|
end
|
153
149
|
|
150
|
+
def get_cookie
|
151
|
+
jwt_token_response = JSON(post_json("http://api.topcoder.com/v2/auth", {
|
152
|
+
username: @account.username,
|
153
|
+
password: @account.password
|
154
|
+
}).body)
|
155
|
+
jwt_token = jwt_token_response["token"]
|
156
|
+
raise AuthTokenError.new(@account, jwt_token_response, "Failed to acquire a JWT token") unless jwt_token
|
157
|
+
|
158
|
+
response = post_json("https://api.topcoder.com/v3/authorizations", {
|
159
|
+
param: {
|
160
|
+
externalToken: jwt_token
|
161
|
+
}
|
162
|
+
})
|
163
|
+
raw_cookie = response["set-cookie"]
|
164
|
+
|
165
|
+
unless raw_cookie.include?("tcsso=")
|
166
|
+
raise CookieError.new(raw_cookie, "Server refused to send a tcsso cookie")
|
167
|
+
end
|
168
|
+
raw_cookie
|
169
|
+
end
|
170
|
+
|
154
171
|
def connect(uri)
|
155
172
|
uri = URI.parse(uri) unless uri.is_a?(URI)
|
156
173
|
options = { use_ssl: uri.scheme == 'https' }
|
@@ -180,32 +197,5 @@ module Gettc
|
|
180
197
|
http.request(request)
|
181
198
|
end
|
182
199
|
end
|
183
|
-
|
184
|
-
def get_cookie
|
185
|
-
jwt_token_response = JSON(post_json("http://api.topcoder.com/v2/auth", {
|
186
|
-
username: @account.username,
|
187
|
-
password: @account.password
|
188
|
-
}).body)
|
189
|
-
jwt_token = jwt_token_response["token"]
|
190
|
-
raise AuthTokenError.new(@account, jwt_token_response, "Failed to acquire a JWT token") unless jwt_token
|
191
|
-
|
192
|
-
refresh_token_response = JSON(post_json("http://api.topcoder.com/v2/reauth", {
|
193
|
-
token: jwt_token
|
194
|
-
}).body)
|
195
|
-
refresh_token = refresh_token_response["token"]
|
196
|
-
raise AuthTokenError.new(@account, refresh_token_response, "Failed to acquire a Refresh token") unless refresh_token
|
197
|
-
|
198
|
-
response = post_json("https://api.topcoder.com/v3/authorizations", {
|
199
|
-
param: {
|
200
|
-
externalToken: refresh_token
|
201
|
-
}
|
202
|
-
})
|
203
|
-
raw_cookie = response["set-cookie"]
|
204
|
-
|
205
|
-
unless CGI::Cookie.parse(raw_cookie).has_key?("tcsso")
|
206
|
-
raise DownloadError.new(raw_cookie, "Server refused to send a tcsso cookie")
|
207
|
-
end
|
208
|
-
raw_cookie
|
209
|
-
end
|
210
200
|
end
|
211
201
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gettc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hpricot
|
@@ -70,10 +70,6 @@ files:
|
|
70
70
|
- dist/include/python/engine.rb
|
71
71
|
- dist/include/python/topcoder/__init__.py
|
72
72
|
- dist/include/python/topcoder/__init__.pyc
|
73
|
-
- dist/include/python/topcoder/__pycache__/__init__.cpython-34.pyc
|
74
|
-
- dist/include/python/topcoder/__pycache__/errors.cpython-34.pyc
|
75
|
-
- dist/include/python/topcoder/__pycache__/reader.cpython-34.pyc
|
76
|
-
- dist/include/python/topcoder/__pycache__/writer.cpython-34.pyc
|
77
73
|
- dist/include/python/topcoder/errors.py
|
78
74
|
- dist/include/python/topcoder/errors.pyc
|
79
75
|
- dist/include/python/topcoder/reader.py
|
@@ -151,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
147
|
version: '0'
|
152
148
|
requirements: []
|
153
149
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.6.10
|
155
151
|
signing_key:
|
156
152
|
specification_version: 4
|
157
153
|
summary: TopCoder offline arena supporting multiple languages
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|