grade_runner 0.0.4 → 0.0.5

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 +22 -47
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78a54cd4e7ced9a406a055e1ad20b9fc78d295d3cf08bed661610a7f086b5467
4
- data.tar.gz: 2792f96fbb55fc9ea3e913b484705332852c1c1e0a59fcc000f05c88c4dd24c1
3
+ metadata.gz: f83e35368d549636de5841a719e1c81f211fedf13572bdd27a819b24b04ebbeb
4
+ data.tar.gz: 5f237a123364f57d1cb83ed9c98134391600fa57b020d7e2d05346a8676c4cc8
5
5
  SHA512:
6
- metadata.gz: 280ffec77f82bef4e684790982b2b522ab3411b225c29dbf974e04dac9ee89b7cd36927856742667fd9c3d7d2c757ac665e89e2626053a09693e3e2e0fb6bc4c
7
- data.tar.gz: 11c6c01972f6b645a7fcc3f5315713140faa7da10e929af9d4d55c4bfb28e717cfe54f77b7f932983f3bc10f1009a3dcec06d25146bdeca7df05300a972a3c22
6
+ metadata.gz: 343919cd54317ce463d9fccbc4a3eca37d0faafe36c31fa294ed911e96aecdec637b6a4e728dde8f7fab3a945a86054bc02717ddc659e56f75bcfcea9661b280
7
+ data.tar.gz: 5f13ed69664ba6a817247be6933306aa610267b37f04f1bb259036fc64a4798006b74fad7ec42b250ddc6e9f2242e6a715738034aafddd7d2cab9c797d459c81
data/Gemfile.lock CHANGED
@@ -113,4 +113,4 @@ DEPENDENCIES
113
113
  simplecov
114
114
 
115
115
  BUNDLED WITH
116
- 1.16.6
116
+ 1.17.2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/lib/tasks/grade.rake CHANGED
@@ -3,13 +3,12 @@ require 'net/http'
3
3
  require "json"
4
4
  require_relative "../grade_runner/runner"
5
5
 
6
- desc "Alias for \"grade:next\"."
7
- task grade: "grade:all" do
8
- end
6
+ # desc "Alias for \"grade:next\"."
7
+ # task grade: "grade:all" do
8
+ # end
9
9
 
10
- namespace :grade do
11
10
  desc "Run all tests and submit a build report."
12
- task :all do
11
+ task :grade do
13
12
  ARGV.each { |a| task a.to_sym do ; end }
14
13
  input_token = ARGV[1]
15
14
  file_token = nil
@@ -31,29 +30,15 @@ namespace :grade do
31
30
  submission_url = "https://grades.firstdraft.com"
32
31
  end
33
32
 
34
- if input_token != false &&
35
- input_token != "" &&
36
- input_token != " " &&
37
- !input_token.nil? &&
38
- input_token != [] &&
39
- input_token != {}
40
-
33
+ if !input_token.nil? && input_token != "" && input_token != " "
41
34
  token = input_token
42
35
  student_config["personal_access_token"] = input_token
43
36
  update_config_file(config_file_name, student_config)
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
-
37
+ elsif input_token.nil? && !file_token.nil?
52
38
  token = file_token
53
39
  elsif input_token.nil? && file_token.nil?
54
40
  puts "Enter your access token for this project"
55
41
  new_personal_access_token = ""
56
-
57
42
  while new_personal_access_token == "" do
58
43
  print "> "
59
44
  new_personal_access_token = $stdin.gets.chomp.strip
@@ -71,12 +56,7 @@ namespace :grade do
71
56
  end
72
57
  end
73
58
 
74
- if token != false &&
75
- token != "" &&
76
- token != " " &&
77
- !token.nil? &&
78
- token != [] &&
79
- token != {}
59
+ if !token.nil? && token != "" && token != " "
80
60
  if is_valid_token?(submission_url, token) == false
81
61
  student_config["personal_access_token"] = nil
82
62
  update_config_file(config_file_name, student_config)
@@ -101,38 +81,33 @@ namespace :grade do
101
81
  end
102
82
  end
103
83
 
104
- desc "Run only the next failing test."
105
- task :next do
106
- path = File.join(__dir__, "examples.txt")
107
- if File.file?(path)
108
- # `bin/rails db:migrate RAILS_ENV=test`
109
- # puts `RAILS_ENV=test bundle exec rspec --next-failure --format HintFormatter`
110
- puts `bundle exec rspec --next-failure --format HintFormatter`
111
- else
112
- # puts `RAILS_ENV=test bundle exec rspec`
113
- puts `bundle exec rspec`
114
- puts "Please rerun rake grade:next to run the first failing spec"
115
- end
116
- end
84
+ # desc "Run only the next failing test."
85
+ # task :next do
86
+ # path = File.join(__dir__, "examples.txt")
87
+ # if File.file?(path)
88
+ # # `bin/rails db:migrate RAILS_ENV=test`
89
+ # # puts `RAILS_ENV=test bundle exec rspec --next-failure --format HintFormatter`
90
+ # puts `bundle exec rspec --next-failure --format HintFormatter`
91
+ # else
92
+ # # puts `RAILS_ENV=test bundle exec rspec`
93
+ # puts `bundle exec rspec`
94
+ # puts "Please rerun rake grade:next to run the first failing spec"
95
+ # end
96
+ # end
117
97
 
118
- end
119
98
 
120
99
  def update_config_file(config_file_name, config)
121
100
  File.write(config_file_name, YAML.dump(config))
122
101
  end
123
102
 
124
103
  def is_valid_token?(root_url, token)
125
- return false unless token.is_a?(String) && !(token =~ /^[1-9A-Za-z][^OIl]{23}$/).nil?
126
-
104
+ return false unless token.is_a?(String) && token =~ /^[1-9A-Za-z][^OIl]{23}$/
127
105
  url = "#{root_url}/submissions/validate_token?token=#{token}"
128
106
  uri = URI.parse(url)
129
-
130
107
  req = Net::HTTP::Get.new(uri, 'Content-Type' => 'application/json')
131
-
132
108
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
133
109
  http.request(req)
134
110
  end
135
-
136
111
  result = JSON.parse(res.body)
137
112
  result["success"]
138
113
  rescue => e
@@ -147,6 +122,6 @@ def project_root
147
122
  if defined?(Bundler)
148
123
  return Bundler.root
149
124
  end
150
-
125
+ p "project root" #REMOVE
151
126
  Dir.pwd
152
127
  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
4
+ version: 0.0.5
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-03 00:00:00.000000000 Z
11
+ date: 2019-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec