grade_runner 0.0.4.pre.21 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/VERSION +1 -1
  4. data/lib/tasks/grade.rake +35 -25
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e185687fb8ad217a292bd2053db730cadfadfc99d3a814b721476fe8f0043b0
4
- data.tar.gz: 3bb00fbca988c3b2e993c694b3c89e381b02f024851767274a60ad7f1c744388
3
+ metadata.gz: 78a54cd4e7ced9a406a055e1ad20b9fc78d295d3cf08bed661610a7f086b5467
4
+ data.tar.gz: 2792f96fbb55fc9ea3e913b484705332852c1c1e0a59fcc000f05c88c4dd24c1
5
5
  SHA512:
6
- metadata.gz: d570456f11df59e32f779a8dff8fddac1e9899117bfe3c64a0a17969dd95f69ee2a1e8f912ace9d3fd427fcba2461493eb377427ec9ec2532b133f0106008f42
7
- data.tar.gz: 359c672b0baca9084c878f8722553406e9bba5fc36a312e45cf7efc3f6f8c3e4904bd3ef4f2bb41659d3ce04d9de055fda647215cce20449b6260bcdde341116
6
+ metadata.gz: 280ffec77f82bef4e684790982b2b522ab3411b225c29dbf974e04dac9ee89b7cd36927856742667fd9c3d7d2c757ac665e89e2626053a09693e3e2e0fb6bc4c
7
+ data.tar.gz: 11c6c01972f6b645a7fcc3f5315713140faa7da10e929af9d4d55c4bfb28e717cfe54f77b7f932983f3bc10f1009a3dcec06d25146bdeca7df05300a972a3c22
data/Gemfile.lock CHANGED
@@ -113,4 +113,4 @@ DEPENDENCIES
113
113
  simplecov
114
114
 
115
115
  BUNDLED WITH
116
- 1.17.2
116
+ 1.16.6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4.pre.21
1
+ 0.0.4
data/lib/tasks/grade.rake CHANGED
@@ -11,8 +11,6 @@ namespace :grade do
11
11
  desc "Run all tests and submit a build report."
12
12
  task :all do
13
13
  ARGV.each { |a| task a.to_sym do ; end }
14
- p "START OF FILE" #REMOVE
15
- p ARGV.count
16
14
  input_token = ARGV[1]
17
15
  file_token = nil
18
16
 
@@ -33,21 +31,29 @@ namespace :grade do
33
31
  submission_url = "https://grades.firstdraft.com"
34
32
  end
35
33
 
36
- p "File found"#REMOVE
37
- if !input_token.nil?
38
- p "input token:"#REMOVE
39
- p input_token#REMOVE
34
+ if input_token != false &&
35
+ input_token != "" &&
36
+ input_token != " " &&
37
+ !input_token.nil? &&
38
+ input_token != [] &&
39
+ input_token != {}
40
+
40
41
  token = input_token
41
42
  student_config["personal_access_token"] = input_token
42
43
  update_config_file(config_file_name, student_config)
43
- elsif input_token.nil? && !file_token.nil?
44
- p "file token"
45
- p file_token
44
+ elsif input_token.nil? &&
45
+ file_token != false &&
46
+ file_token != "" &&
47
+ file_token != " " &&
48
+ !file_token.nil? &&
49
+ file_token != [] &&
50
+ file_token != {}
51
+
46
52
  token = file_token
47
53
  elsif input_token.nil? && file_token.nil?
48
54
  puts "Enter your access token for this project"
49
55
  new_personal_access_token = ""
50
- p "Entering new token" #REMOVE
56
+
51
57
  while new_personal_access_token == "" do
52
58
  print "> "
53
59
  new_personal_access_token = $stdin.gets.chomp.strip
@@ -62,12 +68,15 @@ namespace :grade do
62
68
  update_config_file(config_file_name, student_config)
63
69
  token = new_personal_access_token
64
70
  end
65
- p "end of loop" #REMOVE
66
71
  end
67
72
  end
68
73
 
69
- if !token.nil?
70
- p "token not nil" #REMOVE
74
+ if token != false &&
75
+ token != "" &&
76
+ token != " " &&
77
+ !token.nil? &&
78
+ token != [] &&
79
+ token != {}
71
80
  if is_valid_token?(submission_url, token) == false
72
81
  student_config["personal_access_token"] = nil
73
82
  update_config_file(config_file_name, student_config)
@@ -113,30 +122,31 @@ def update_config_file(config_file_name, config)
113
122
  end
114
123
 
115
124
  def is_valid_token?(root_url, token)
116
- p "is valid" #REMOVE
117
- return false unless token.is_a?(String) && token =~ /^[1-9A-Za-z][^OIl]{23}$/
125
+ return false unless token.is_a?(String) && !(token =~ /^[1-9A-Za-z][^OIl]{23}$/).nil?
126
+
118
127
  url = "#{root_url}/submissions/validate_token?token=#{token}"
119
128
  uri = URI.parse(url)
129
+
120
130
  req = Net::HTTP::Get.new(uri, 'Content-Type' => 'application/json')
131
+
121
132
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
122
133
  http.request(req)
123
134
  end
135
+
124
136
  result = JSON.parse(res.body)
125
137
  result["success"]
126
138
  rescue => e
127
- p "error" #REMOVE
128
- p e #REMOVE
129
139
  return false
130
140
  end
131
141
 
132
142
  def project_root
133
- # if defined?(Rails)
134
- # return Rails.root
135
- # end
136
-
137
- # if defined?(Bundler)
138
- # return Bundler.root
139
- # end
140
- p "project root" #REMOVE
143
+ if defined?(Rails)
144
+ return Rails.root
145
+ end
146
+
147
+ if defined?(Bundler)
148
+ return Bundler.root
149
+ end
150
+
141
151
  Dir.pwd
142
152
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grade_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre.21
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raghu Betina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -202,9 +202,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - ">"
205
+ - - ">="
206
206
  - !ruby/object:Gem::Version
207
- version: 1.3.1
207
+ version: '0'
208
208
  requirements: []
209
209
  rubyforge_project:
210
210
  rubygems_version: 2.7.8