grade_runner 0.0.4.pre.12 → 0.0.4.pre.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/tasks/grade.rake +5 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c14ad48e3941fb2f67a4cdc3a9a40873f33dae886041c12cd53e207db97c204b
|
4
|
+
data.tar.gz: 8ea949a5f26b06abeeec984bcc9dcbb49075fedc07557259b6c4111faa727e5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f07ec5bf001e927d41abf788c81def9cc61156d8a7af88ee9d332f23cef826ed3fa6095cc46bfa9790a0fd20d1096e623d7b1ca5cf71d290f5f2fbc8dbe1bea
|
7
|
+
data.tar.gz: 4fd170f15efe7c178dd99e48cc1ae51c76444e45a9a264709c37a10de465f9e0e4e4f53440d2a4edfcd06ad9347dc8a3f3f7ce9bc3ebc3ab08782b80a5477102
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.4.pre.
|
1
|
+
0.0.4.pre.13
|
data/lib/tasks/grade.rake
CHANGED
@@ -31,12 +31,12 @@ namespace :grade do
|
|
31
31
|
submission_url = "https://grades.firstdraft.com"
|
32
32
|
end
|
33
33
|
|
34
|
-
if
|
34
|
+
if input_token != false && input_token != "" && input_token != " " && !input_token.nil?
|
35
35
|
|
36
36
|
token = input_token
|
37
37
|
student_config["personal_access_token"] = input_token
|
38
38
|
update_config_file(config_file_name, student_config)
|
39
|
-
elsif input_token.nil? && file_token != false && file_token != "" && file_token != " " && !file_token.nil?
|
39
|
+
elsif input_token.nil? && file_token != false && file_token != "" && file_token != " " && !file_token.nil?
|
40
40
|
|
41
41
|
token = file_token
|
42
42
|
elsif input_token.nil? && file_token.nil?
|
@@ -47,7 +47,7 @@ namespace :grade do
|
|
47
47
|
print "> "
|
48
48
|
new_personal_access_token = $stdin.gets.chomp.strip
|
49
49
|
|
50
|
-
if
|
50
|
+
if new_personal_access_token!= "" && is_valid_token?(submission_url, new_personal_access_token == false
|
51
51
|
puts "Please enter valid token"
|
52
52
|
new_personal_access_token = ""
|
53
53
|
end
|
@@ -60,7 +60,7 @@ namespace :grade do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
if
|
63
|
+
if token != false && token != "" && token != " " && !token.nil?
|
64
64
|
if is_valid_token?(submission_url, token) == false
|
65
65
|
student_config["personal_access_token"] = nil
|
66
66
|
update_config_file(config_file_name, student_config)
|
@@ -106,17 +106,13 @@ def update_config_file(config_file_name, config)
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def is_valid_token?(root_url, token)
|
109
|
-
return false unless token.is_a?(String) &&
|
110
|
-
|
109
|
+
return false unless token.is_a?(String) && token =~ /^[1-9A-Za-z][^OIl]{23}$/
|
111
110
|
url = "#{root_url}/submissions/validate_token?token=#{token}"
|
112
111
|
uri = URI.parse(url)
|
113
|
-
|
114
112
|
req = Net::HTTP::Get.new(uri, 'Content-Type' => 'application/json')
|
115
|
-
|
116
113
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
117
114
|
http.request(req)
|
118
115
|
end
|
119
|
-
|
120
116
|
result = JSON.parse(res.body)
|
121
117
|
result["success"]
|
122
118
|
rescue => e
|