gettc 2.0 → 2.1

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: 1b7ea56d04d293fac9836322b3bd90bb3c0e19b3
4
- data.tar.gz: 2e2b323f24c59f0976c1f73b9a822ccbd7e82a9e
3
+ metadata.gz: d458f0d3f5aa87fc10f1c8eaf91c20fb1fd73df1
4
+ data.tar.gz: 98d431c8dea677018c501bdcab0e68168de6e551
5
5
  SHA512:
6
- metadata.gz: ce0bf1a1b452710291a014d2b52fa10af2170c2a6cff2e9d2602ce8affa75df61b08b198377be00102cc5f2c032ca50537e0aa330e92e8263594ef491f22061f
7
- data.tar.gz: 18c9c44a6b39463d2d797e055614740dc72715ad4556436fee2062aa3588cd56aa10476375c2ed79b3da01c722b7f9c9c63d6c2609115712ed338656310fb56a
6
+ metadata.gz: c2a49b45d3b4fd24115cd657a657349f53876b0ee7937788bc5771977aed0720dea6a2493fb5f73e59e9aa13274469d92cf2528983a55744767c8313b2564142
7
+ data.tar.gz: c35885d68e1e83dd3b62f13e51ac6d48ecdac20aa91a8da87ec5e4daea87459b89cfd3289b84b2cf79cf0e3ae928e33f46d6f62816b48726327d6bec34b3f6da
data/dist/config.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  username: gettc
2
2
  password: algorithm
3
- version: 2.0
3
+ version: 2.1
@@ -167,7 +167,7 @@ class GettcRunner
167
167
  n.times do |i|
168
168
  case_id = @failures[i]
169
169
  puts "Case #{case_id}:"
170
- print_case j
170
+ print_case(case_id)
171
171
  end
172
172
  end
173
173
 
data/lib/gettc.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require "version"
2
- require "gettc/download"
3
- require "gettc/parse"
2
+ require "gettc/download"
3
+ require "gettc/parse"
4
4
  require "gettc/generate"
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Gettc
2
- VERSION = "2.0"
2
+ VERSION = "2.1"
3
3
  end
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.0'
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: 2016-01-30 00:00:00.000000000 Z
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.4.8
150
+ rubygems_version: 2.6.10
155
151
  signing_key:
156
152
  specification_version: 4
157
153
  summary: TopCoder offline arena supporting multiple languages