grade_runner 0.0.5.1 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -3
- data/Gemfile.lock +97 -44
- data/README.markdown +39 -3
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/grade_runner.gemspec +31 -33
- data/lib/grade_runner/railtie.rb +7 -7
- data/lib/grade_runner/runner.rb +4 -2
- data/lib/grade_runner.rb +1 -2
- data/lib/tasks/grade.rake +141 -42
- data/lib/tasks/grade_runner.rake +5 -12
- metadata +79 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c031fd9ea407f2ec344b80fd85ddbbce5a298e27e136694c68ae0e3f63ced2c5
|
4
|
+
data.tar.gz: 3e144eee25f1ddc7d09bf65f190a58933369a4904eec18d3ea8c3056d4ff8601
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b1063120735c91a8c128b63c4fdc0e6505575fd1130e32dc38b6b98e711f0168fbcbf94c840036e05b6db458219f73a748120181f0b247501815400c1bbe186
|
7
|
+
data.tar.gz: 384e3fe3cd6bee52cf009b5d7bac62d01dfeebb53b7f17f89aea33efeb089f8acd988472fbb5f2b34796e0c6b47c033ee50940055dfb68557991975917ff23fa
|
data/Gemfile
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
|
-
|
5
|
-
|
4
|
+
gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "oj", "~> 3.13.12"
|
6
|
+
gem "octokit", "~> 5.0"
|
7
|
+
gem "faraday-retry", "~> 1.0.3"
|
8
|
+
gem "rake", "~> 13"
|
6
9
|
# Add dependencies to develop your gem here.
|
7
10
|
# Include everything needed to run rake, tests, features, etc.
|
8
11
|
group :development do
|
9
12
|
gem "rspec", "~> 3.5.0"
|
10
13
|
gem "rdoc", "~> 3.12"
|
11
|
-
gem "bundler", "~> 1.
|
14
|
+
gem "bundler", "~> 2.1.4"
|
12
15
|
gem "juwelier", "~> 2.1.0"
|
13
16
|
gem "simplecov", ">= 0"
|
14
17
|
gem "pry", "~> 0"
|
data/Gemfile.lock
CHANGED
@@ -1,29 +1,60 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
activesupport (7.0.4.3)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (>= 1.6, < 2)
|
7
|
+
minitest (>= 5.1)
|
8
|
+
tzinfo (~> 2.0)
|
9
|
+
addressable (2.8.4)
|
10
|
+
public_suffix (>= 2.0.2, < 6.0)
|
11
|
+
binding_of_caller (1.0.0)
|
7
12
|
debug_inspector (>= 0.0.1)
|
8
|
-
builder (3.2.
|
9
|
-
byebug (11.
|
10
|
-
coderay (1.1.
|
11
|
-
|
13
|
+
builder (3.2.4)
|
14
|
+
byebug (11.1.3)
|
15
|
+
coderay (1.1.3)
|
16
|
+
concurrent-ruby (1.2.2)
|
17
|
+
debug_inspector (1.1.0)
|
12
18
|
descendants_tracker (0.0.4)
|
13
19
|
thread_safe (~> 0.3, >= 0.3.1)
|
14
|
-
diff-lcs (1.
|
15
|
-
docile (1.
|
16
|
-
faraday (
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
diff-lcs (1.5.0)
|
21
|
+
docile (1.4.0)
|
22
|
+
faraday (1.10.3)
|
23
|
+
faraday-em_http (~> 1.0)
|
24
|
+
faraday-em_synchrony (~> 1.0)
|
25
|
+
faraday-excon (~> 1.1)
|
26
|
+
faraday-httpclient (~> 1.0)
|
27
|
+
faraday-multipart (~> 1.0)
|
28
|
+
faraday-net_http (~> 1.0)
|
29
|
+
faraday-net_http_persistent (~> 1.0)
|
30
|
+
faraday-patron (~> 1.0)
|
31
|
+
faraday-rack (~> 1.0)
|
32
|
+
faraday-retry (~> 1.0)
|
33
|
+
ruby2_keywords (>= 0.0.4)
|
34
|
+
faraday-em_http (1.0.0)
|
35
|
+
faraday-em_synchrony (1.0.0)
|
36
|
+
faraday-excon (1.1.0)
|
37
|
+
faraday-httpclient (1.0.1)
|
38
|
+
faraday-multipart (1.0.4)
|
39
|
+
multipart-post (~> 2)
|
40
|
+
faraday-net_http (1.0.1)
|
41
|
+
faraday-net_http_persistent (1.2.0)
|
42
|
+
faraday-patron (1.0.0)
|
43
|
+
faraday-rack (1.0.0)
|
44
|
+
faraday-retry (1.0.3)
|
45
|
+
git (1.18.0)
|
46
|
+
addressable (~> 2.8)
|
47
|
+
rchardet (~> 1.8)
|
48
|
+
github_api (0.19.0)
|
20
49
|
addressable (~> 2.4)
|
21
50
|
descendants_tracker (~> 0.0.4)
|
22
|
-
faraday (
|
51
|
+
faraday (>= 0.8, < 2)
|
23
52
|
hashie (~> 3.5, >= 3.5.2)
|
24
53
|
oauth2 (~> 1.0)
|
25
54
|
hashie (3.6.0)
|
26
|
-
highline (2.0
|
55
|
+
highline (2.1.0)
|
56
|
+
i18n (1.12.0)
|
57
|
+
concurrent-ruby (~> 1.0)
|
27
58
|
interception (0.5)
|
28
59
|
json (1.8.6)
|
29
60
|
juwelier (2.1.3)
|
@@ -36,41 +67,49 @@ GEM
|
|
36
67
|
rake
|
37
68
|
rdoc
|
38
69
|
semver
|
39
|
-
jwt (2.
|
40
|
-
method_source (0.
|
41
|
-
mini_portile2 (2.
|
42
|
-
|
70
|
+
jwt (2.7.0)
|
71
|
+
method_source (1.0.0)
|
72
|
+
mini_portile2 (2.8.1)
|
73
|
+
minitest (5.18.0)
|
74
|
+
multi_json (1.15.0)
|
43
75
|
multi_xml (0.6.0)
|
44
|
-
multipart-post (2.
|
45
|
-
nokogiri (1.
|
46
|
-
mini_portile2 (~> 2.
|
47
|
-
|
48
|
-
|
76
|
+
multipart-post (2.3.0)
|
77
|
+
nokogiri (1.14.3)
|
78
|
+
mini_portile2 (~> 2.8.0)
|
79
|
+
racc (~> 1.4)
|
80
|
+
oauth2 (1.4.11)
|
81
|
+
faraday (>= 0.17.3, < 3.0)
|
49
82
|
jwt (>= 1.0, < 3.0)
|
50
83
|
multi_json (~> 1.3)
|
51
84
|
multi_xml (~> 0.5)
|
52
|
-
rack (>= 1.2, <
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
85
|
+
rack (>= 1.2, < 4)
|
86
|
+
octokit (5.6.1)
|
87
|
+
faraday (>= 1, < 3)
|
88
|
+
sawyer (~> 0.9)
|
89
|
+
oj (3.13.23)
|
90
|
+
pry (0.14.1)
|
91
|
+
coderay (~> 1.1)
|
92
|
+
method_source (~> 1.0)
|
93
|
+
pry-byebug (3.10.1)
|
57
94
|
byebug (~> 11.0)
|
58
|
-
pry (
|
95
|
+
pry (>= 0.13, < 0.15)
|
59
96
|
pry-doc (0.13.5)
|
60
97
|
pry (~> 0.11)
|
61
98
|
yard (~> 0.9.11)
|
62
99
|
pry-remote (0.1.8)
|
63
100
|
pry (~> 0.9)
|
64
101
|
slop (~> 3.0)
|
65
|
-
pry-rescue (1.5.
|
102
|
+
pry-rescue (1.5.2)
|
66
103
|
interception (>= 0.5)
|
67
104
|
pry (>= 0.12.0)
|
68
|
-
pry-stack_explorer (0.
|
69
|
-
binding_of_caller (
|
70
|
-
pry (
|
71
|
-
public_suffix (
|
72
|
-
|
73
|
-
|
105
|
+
pry-stack_explorer (0.6.1)
|
106
|
+
binding_of_caller (~> 1.0)
|
107
|
+
pry (~> 0.13)
|
108
|
+
public_suffix (5.0.1)
|
109
|
+
racc (1.6.2)
|
110
|
+
rack (3.0.7)
|
111
|
+
rake (13.0.6)
|
112
|
+
rchardet (1.8.0)
|
74
113
|
rdoc (3.12.2)
|
75
114
|
json (~> 1.4)
|
76
115
|
rspec (3.5.0)
|
@@ -86,31 +125,45 @@ GEM
|
|
86
125
|
diff-lcs (>= 1.2.0, < 2.0)
|
87
126
|
rspec-support (~> 3.5.0)
|
88
127
|
rspec-support (3.5.0)
|
128
|
+
ruby2_keywords (0.0.5)
|
129
|
+
sawyer (0.9.2)
|
130
|
+
addressable (>= 2.3.5)
|
131
|
+
faraday (>= 0.17.3, < 3)
|
89
132
|
semver (1.0.1)
|
90
|
-
simplecov (0.
|
133
|
+
simplecov (0.21.2)
|
91
134
|
docile (~> 1.1)
|
92
|
-
|
93
|
-
|
94
|
-
simplecov-html (0.
|
135
|
+
simplecov-html (~> 0.11)
|
136
|
+
simplecov_json_formatter (~> 0.1)
|
137
|
+
simplecov-html (0.12.3)
|
138
|
+
simplecov_json_formatter (0.1.4)
|
95
139
|
slop (3.6.0)
|
96
140
|
thread_safe (0.3.6)
|
97
|
-
|
141
|
+
tzinfo (2.0.6)
|
142
|
+
concurrent-ruby (~> 1.0)
|
143
|
+
webrick (1.7.0)
|
144
|
+
yard (0.9.28)
|
145
|
+
webrick (~> 1.7.0)
|
98
146
|
|
99
147
|
PLATFORMS
|
100
148
|
ruby
|
101
149
|
|
102
150
|
DEPENDENCIES
|
103
|
-
|
151
|
+
activesupport (>= 2.3.5)
|
152
|
+
bundler (~> 2.1.4)
|
153
|
+
faraday-retry (~> 1.0.3)
|
104
154
|
juwelier (~> 2.1.0)
|
155
|
+
octokit (~> 5.0)
|
156
|
+
oj (~> 3.13.12)
|
105
157
|
pry (~> 0)
|
106
158
|
pry-byebug (~> 3)
|
107
159
|
pry-doc (~> 0)
|
108
160
|
pry-remote (~> 0)
|
109
161
|
pry-rescue (~> 1)
|
110
162
|
pry-stack_explorer (~> 0)
|
163
|
+
rake (~> 13)
|
111
164
|
rdoc (~> 3.12)
|
112
165
|
rspec (~> 3.5.0)
|
113
166
|
simplecov
|
114
167
|
|
115
168
|
BUNDLED WITH
|
116
|
-
1.
|
169
|
+
2.1.4
|
data/README.markdown
CHANGED
@@ -8,7 +8,7 @@ A Ruby client for [firstdraft Grades](https://grades.firstdraft.com)
|
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem "grade_runner",
|
11
|
+
gem "grade_runner", github: "firstdraft/grade_runner"
|
12
12
|
```
|
13
13
|
|
14
14
|
And then execute:
|
@@ -16,8 +16,44 @@ And then execute:
|
|
16
16
|
$ bundle
|
17
17
|
```
|
18
18
|
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### Rails
|
22
|
+
|
23
|
+
After installed, run `rails grade` to run specs.
|
24
|
+
|
25
|
+
### Ruby
|
26
|
+
|
27
|
+
In order to load and run the Rake task, you need to load it.
|
28
|
+
|
29
|
+
This is usually done by making a runnable file[^1], typically called `bin/rails`, with contents that look like this:
|
30
|
+
|
31
|
+
```rb
|
32
|
+
#!/usr/bin/env ruby
|
33
|
+
require "rubygems"
|
34
|
+
require "bundler/setup"
|
35
|
+
require "rake"
|
36
|
+
|
37
|
+
dir = Gem::Specification.find_by_name("grade_runner").gem_dir
|
38
|
+
|
39
|
+
load "#{dir}/lib/tasks/grade.rake"
|
40
|
+
task_name = ARGV[0]
|
41
|
+
|
42
|
+
Rake::Task[task_name].invoke
|
43
|
+
```
|
44
|
+
|
45
|
+
Then you can run `bin/rails grade` like before. You can even add this file to the `PATH` so you can run `rails grade` like with Rails apps.
|
46
|
+
|
47
|
+
```bash
|
48
|
+
echo 'export PATH="$PATH:/path/to/project/bin/rails"' >> ~/.bashrc
|
49
|
+
source ~/.bashrc
|
50
|
+
```
|
51
|
+
|
52
|
+
---
|
53
|
+
|
54
|
+
[^1]: If you get file permissions errors when running `bin/rails grade` try updating the permissions with `chmod 755 bin/rails` first.
|
55
|
+
|
19
56
|
Copyright
|
20
57
|
---------
|
21
58
|
|
22
|
-
Copyright (c) 2018 Raghu Betina. See
|
23
|
-
LICENSE.txt for further details.
|
59
|
+
Copyright (c) 2018 Raghu Betina. See [LICENSE.txt](LICENSE.txt) for further details.
|
data/Rakefile
CHANGED
@@ -18,8 +18,8 @@ Juwelier::Tasks.new do |gem|
|
|
18
18
|
gem.license = "MIT"
|
19
19
|
gem.summary = %Q{A Ruby client for [firstdraft Grades](https://grades.firstdraft.com)}
|
20
20
|
gem.description = %Q{This gem runs your RSpec test suite and posts the JSON output to grades.firstdraft.com.}
|
21
|
-
gem.email = "raghu@firstdraft.com"
|
22
|
-
gem.authors = ["Raghu Betina"]
|
21
|
+
gem.email = ["raghu@firstdraft.com", "jelani@firstdraft.com"]
|
22
|
+
gem.authors = ["Raghu Betina", "Jelani Woods"]
|
23
23
|
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
@@ -40,7 +40,7 @@ task :default => :spec
|
|
40
40
|
|
41
41
|
require 'rdoc/task'
|
42
42
|
Rake::RDocTask.new do |rdoc|
|
43
|
-
version = File.
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
44
|
|
45
45
|
rdoc.rdoc_dir = 'rdoc'
|
46
46
|
rdoc.title = "grade_runner #{version}"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/grade_runner.gemspec
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: grade_runner 0.0.
|
5
|
+
# stub: grade_runner 0.0.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "grade_runner".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.8"
|
10
10
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
|
-
s.authors = ["Raghu Betina".freeze]
|
14
|
-
s.date = "
|
13
|
+
s.authors = ["Raghu Betina".freeze, "Jelani Woods".freeze]
|
14
|
+
s.date = "2023-05-30"
|
15
15
|
s.description = "This gem runs your RSpec test suite and posts the JSON output to grades.firstdraft.com.".freeze
|
16
|
-
s.email = "raghu@firstdraft.com".freeze
|
16
|
+
s.email = ["raghu@firstdraft.com".freeze, "jelani@firstdraft.com".freeze]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE.txt",
|
19
19
|
"README.markdown"
|
@@ -37,41 +37,39 @@ Gem::Specification.new do |s|
|
|
37
37
|
]
|
38
38
|
s.homepage = "http://github.com/firstdraft/grade_runner".freeze
|
39
39
|
s.licenses = ["MIT".freeze]
|
40
|
-
s.rubygems_version = "
|
40
|
+
s.rubygems_version = "3.1.6".freeze
|
41
41
|
s.summary = "A Ruby client for [firstdraft Grades](https://grades.firstdraft.com)".freeze
|
42
42
|
|
43
43
|
if s.respond_to? :specification_version then
|
44
44
|
s.specification_version = 4
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
64
|
-
s.add_dependency(%q<pry>.freeze, ["~> 0"])
|
65
|
-
s.add_dependency(%q<pry-byebug>.freeze, ["~> 3"])
|
66
|
-
s.add_dependency(%q<pry-doc>.freeze, ["~> 0"])
|
67
|
-
s.add_dependency(%q<pry-remote>.freeze, ["~> 0"])
|
68
|
-
s.add_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
69
|
-
s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
70
|
-
end
|
47
|
+
if s.respond_to? :add_runtime_dependency then
|
48
|
+
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 2.3.5"])
|
49
|
+
s.add_runtime_dependency(%q<oj>.freeze, ["~> 3.13.12"])
|
50
|
+
s.add_runtime_dependency(%q<octokit>.freeze, ["~> 5.0"])
|
51
|
+
s.add_runtime_dependency(%q<faraday-retry>.freeze, ["~> 1.0.3"])
|
52
|
+
s.add_runtime_dependency(%q<rake>.freeze, ["~> 13"])
|
53
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
54
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
55
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 2.1.4"])
|
56
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
57
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<pry>.freeze, ["~> 0"])
|
59
|
+
s.add_development_dependency(%q<pry-byebug>.freeze, ["~> 3"])
|
60
|
+
s.add_development_dependency(%q<pry-doc>.freeze, ["~> 0"])
|
61
|
+
s.add_development_dependency(%q<pry-remote>.freeze, ["~> 0"])
|
62
|
+
s.add_development_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
63
|
+
s.add_development_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
71
64
|
else
|
65
|
+
s.add_dependency(%q<activesupport>.freeze, [">= 2.3.5"])
|
66
|
+
s.add_dependency(%q<oj>.freeze, ["~> 3.13.12"])
|
67
|
+
s.add_dependency(%q<octokit>.freeze, ["~> 5.0"])
|
68
|
+
s.add_dependency(%q<faraday-retry>.freeze, ["~> 1.0.3"])
|
69
|
+
s.add_dependency(%q<rake>.freeze, ["~> 13"])
|
72
70
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
73
71
|
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
74
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.
|
72
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 2.1.4"])
|
75
73
|
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
76
74
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
77
75
|
s.add_dependency(%q<pry>.freeze, ["~> 0"])
|
data/lib/grade_runner/railtie.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
1
|
+
require 'rails'
|
2
2
|
|
3
3
|
module GradeRunner
|
4
|
-
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
rake_tasks do
|
7
|
+
load "tasks/grade_runner.rake"
|
8
|
+
load "tasks/grade.rake"
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
data/lib/grade_runner/runner.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require "net/http"
|
2
|
+
require "oj"
|
3
|
+
|
2
4
|
module GradeRunner
|
3
5
|
class Runner
|
4
6
|
|
@@ -20,14 +22,14 @@ module GradeRunner
|
|
20
22
|
private
|
21
23
|
|
22
24
|
def post_to_grades
|
23
|
-
puts "- Posting to URL: " + "#{@submission_url}"
|
24
25
|
uri = URI.parse(@submission_url)
|
25
26
|
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
26
27
|
req.body = data.to_json
|
27
28
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
28
29
|
http.request(req)
|
29
30
|
end
|
30
|
-
|
31
|
+
|
32
|
+
results_url = Oj.load(res.body)["url"]
|
31
33
|
puts "- Done! Results URL: " + "#{results_url}"
|
32
34
|
end
|
33
35
|
|
data/lib/grade_runner.rb
CHANGED
data/lib/tasks/grade.rake
CHANGED
@@ -1,27 +1,29 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require "
|
4
|
-
|
1
|
+
require "active_support/core_ext/object/blank"
|
2
|
+
require "grade_runner/runner"
|
3
|
+
require "octokit"
|
4
|
+
require "yaml"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
desc "Alias for \"grade:next\"."
|
7
|
+
task grade: "grade:all" do
|
8
|
+
end
|
9
9
|
|
10
|
+
namespace :grade do
|
10
11
|
desc "Run all tests and submit a build report."
|
11
|
-
task :
|
12
|
+
task :all do
|
12
13
|
ARGV.each { |a| task a.to_sym do ; end }
|
13
14
|
input_token = ARGV[1]
|
14
15
|
file_token = nil
|
15
16
|
|
16
|
-
|
17
|
+
config_dir_name = find_or_create_config_dif
|
18
|
+
config_file_name = "#{config_dir_name}/.ltici_apitoken.yml"
|
17
19
|
student_config = {}
|
18
20
|
student_config["submission_url"] = "https://grades.firstdraft.com"
|
19
21
|
|
20
|
-
if File.
|
22
|
+
if File.exist?(config_file_name)
|
21
23
|
begin
|
22
24
|
config = YAML.load_file(config_file_name)
|
23
25
|
rescue
|
24
|
-
abort "It looks like there's something wrong with your token in
|
26
|
+
abort "It looks like there's something wrong with your token in `#{config_dir_name}/.ltici_apitoken.yml`. Please delete that file and try `rails grade` again, and be sure to provide the access token for THIS project.".red
|
25
27
|
end
|
26
28
|
submission_url = config["submission_url"]
|
27
29
|
file_token = config["personal_access_token"]
|
@@ -29,16 +31,19 @@ require_relative "../grade_runner/runner"
|
|
29
31
|
else
|
30
32
|
submission_url = "https://grades.firstdraft.com"
|
31
33
|
end
|
32
|
-
|
33
|
-
|
34
|
+
if file_token.nil? && ENV.has_key?("LTICI_GITPOD_APITOKEN")
|
35
|
+
input_token = ENV.fetch("LTICI_GITPOD_APITOKEN")
|
36
|
+
end
|
37
|
+
if input_token.present?
|
34
38
|
token = input_token
|
35
39
|
student_config["personal_access_token"] = input_token
|
36
40
|
update_config_file(config_file_name, student_config)
|
37
|
-
elsif input_token.nil? &&
|
41
|
+
elsif input_token.nil? && file_token.present?
|
38
42
|
token = file_token
|
39
43
|
elsif input_token.nil? && file_token.nil?
|
40
44
|
puts "Enter your access token for this project"
|
41
45
|
new_personal_access_token = ""
|
46
|
+
|
42
47
|
while new_personal_access_token == "" do
|
43
48
|
print "> "
|
44
49
|
new_personal_access_token = $stdin.gets.chomp.strip
|
@@ -56,50 +61,121 @@ require_relative "../grade_runner/runner"
|
|
56
61
|
end
|
57
62
|
end
|
58
63
|
|
59
|
-
if
|
64
|
+
if token.present?
|
65
|
+
|
60
66
|
if is_valid_token?(submission_url, token) == false
|
61
67
|
student_config["personal_access_token"] = nil
|
62
68
|
update_config_file(config_file_name, student_config)
|
63
|
-
puts "Your access token looked invalid, so we've reset it to be blank. Please re-run
|
69
|
+
puts "Your access token looked invalid, so we've reset it to be blank. Please re-run rails grade and, when asked, copy-paste your token carefully from the assignment page."
|
64
70
|
else
|
71
|
+
full_reponame = upstream_repo(submission_url, token)
|
72
|
+
set_upstream_remote(full_reponame)
|
73
|
+
sync_specs_with_source(full_reponame)
|
74
|
+
|
65
75
|
path = File.join(project_root, "/tmp/output/#{Time.now.to_i}.json")
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
username = ""
|
74
|
-
reponame = ""
|
75
|
-
sha = ""
|
76
|
+
`bin/rails db:migrate RAILS_ENV=test` if defined?(Rails)
|
77
|
+
`RAILS_ENV=test bundle exec rspec --order default --format JsonOutputFormatter --out #{path}`
|
78
|
+
rspec_output_json = Oj.load(File.read(path))
|
79
|
+
github_email = `git config user.email`.chomp
|
80
|
+
username = github_username(github_email)
|
81
|
+
reponame = project_root.to_s.split("/").last
|
82
|
+
sha = `git rev-parse HEAD`.slice(0..7)
|
76
83
|
|
77
84
|
GradeRunner::Runner.new(submission_url, token, rspec_output_json, username, reponame, sha, "manual").process
|
78
85
|
end
|
79
86
|
else
|
80
|
-
puts "We couldn't find your access token, so we couldn't record your grade. Please click on the assignment link again and run the
|
87
|
+
puts "We couldn't find your access token, so we couldn't record your grade. Please click on the assignment link again and run the rails grade ... command shown there."
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
desc "Run only the next failing test."
|
92
|
+
task :next do
|
93
|
+
path = File.join(project_root, "examples.txt")
|
94
|
+
if File.exist?(path)
|
95
|
+
`bin/rails db:migrate RAILS_ENV=test` if defined?(Rails)
|
96
|
+
puts `RAILS_ENV=test bundle exec rspec --next-failure --format HintFormatter`
|
97
|
+
else
|
98
|
+
puts `RAILS_ENV=test bundle exec rspec`
|
99
|
+
puts "Please rerun rails grade:next to run the first failing spec"
|
81
100
|
end
|
82
101
|
end
|
83
102
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
103
|
+
desc "Reset access token saved in YAML file."
|
104
|
+
task :reset_token do
|
105
|
+
config_dir_name = find_or_create_config_dif
|
106
|
+
config_file_name = "#{config_dir_name}/.ltici_apitoken.yml"
|
107
|
+
submission_url = "https://grades.firstdraft.com"
|
108
|
+
|
109
|
+
student_config = {}
|
110
|
+
student_config["submission_url"] = submission_url
|
111
|
+
puts "Enter your access token for this project"
|
112
|
+
new_personal_access_token = ""
|
113
|
+
|
114
|
+
while new_personal_access_token == "" do
|
115
|
+
print "> "
|
116
|
+
new_personal_access_token = $stdin.gets.chomp.strip
|
117
|
+
token_valid = is_valid_token?(submission_url, new_personal_access_token)
|
118
|
+
unless token_valid && !new_personal_access_token.empty?
|
119
|
+
puts "Please enter valid token"
|
120
|
+
new_personal_access_token = ""
|
121
|
+
end
|
122
|
+
|
123
|
+
unless new_personal_access_token.empty?
|
124
|
+
student_config["personal_access_token"] = new_personal_access_token
|
125
|
+
update_config_file(config_file_name, student_config)
|
126
|
+
token = new_personal_access_token
|
127
|
+
end
|
128
|
+
end
|
129
|
+
puts "Grade token has been reset successfully."
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
def sync_specs_with_source(full_reponame)
|
135
|
+
if Octokit.repository?(full_reponame)
|
136
|
+
repo_contents = Octokit.contents(full_reponame)
|
137
|
+
remote_spec_folder = repo_contents.find { |git_object| git_object[:name] == 'spec' }
|
138
|
+
if remote_spec_folder.blank?
|
139
|
+
abort("The project #{full_reponame} does not have specs.")
|
140
|
+
end
|
141
|
+
remote_sha = remote_spec_folder[:sha]
|
142
|
+
# Discard unstaged changes in spec folder
|
143
|
+
`git checkout spec -q`
|
144
|
+
`git clean spec -f -q`
|
145
|
+
local_sha = `git ls-tree HEAD #{project_root.join('spec')}`.chomp.split[2]
|
146
|
+
|
147
|
+
unless remote_sha == local_sha
|
148
|
+
`git fetch upstream -q`
|
149
|
+
# Remove local contents of spec folder
|
150
|
+
`rm -rf spec/*`
|
151
|
+
default_branch = `git remote show upstream | grep 'HEAD branch' | cut -d' ' -f5`.chomp
|
152
|
+
# Overwrite local contents of spec folder with contents from upstream branch
|
153
|
+
`git checkout upstream/#{default_branch} spec/ -q`
|
154
|
+
end
|
155
|
+
else
|
156
|
+
abort("The project #{full_reponame} does not exist.")
|
157
|
+
end
|
158
|
+
end
|
97
159
|
|
160
|
+
def set_upstream_remote(repo_slug)
|
161
|
+
upstream = `git remote -v | grep -w upstream`.chomp
|
162
|
+
if upstream.blank?
|
163
|
+
`git remote add upstream https://github.com/#{repo_slug}`
|
164
|
+
else
|
165
|
+
`git remote set-url upstream https://github.com/#{repo_slug}`
|
166
|
+
end
|
167
|
+
end
|
98
168
|
|
99
169
|
def update_config_file(config_file_name, config)
|
100
170
|
File.write(config_file_name, YAML.dump(config))
|
101
171
|
end
|
102
172
|
|
173
|
+
def find_or_create_config_dif
|
174
|
+
config_dir_name = File.join(project_root, ".vscode")
|
175
|
+
Dir.mkdir(config_dir_name) unless Dir.exist?(config_dir_name)
|
176
|
+
config_dir_name
|
177
|
+
end
|
178
|
+
|
103
179
|
def is_valid_token?(root_url, token)
|
104
180
|
return false unless token.is_a?(String) && token =~ /^[1-9A-Za-z][^OIl]{23}$/
|
105
181
|
url = "#{root_url}/submissions/validate_token?token=#{token}"
|
@@ -108,12 +184,35 @@ def is_valid_token?(root_url, token)
|
|
108
184
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
109
185
|
http.request(req)
|
110
186
|
end
|
111
|
-
result =
|
187
|
+
result = Oj.load(res.body)
|
112
188
|
result["success"]
|
113
189
|
rescue => e
|
114
190
|
return false
|
115
191
|
end
|
116
192
|
|
193
|
+
def upstream_repo(root_url, token)
|
194
|
+
return false unless token.is_a?(String) && token =~ /^[1-9A-Za-z][^OIl]{23}$/
|
195
|
+
url = "#{root_url}/submissions/resource?token=#{token}"
|
196
|
+
uri = URI.parse(url)
|
197
|
+
req = Net::HTTP::Get.new(uri, 'Content-Type' => 'application/json')
|
198
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
199
|
+
http.request(req)
|
200
|
+
end
|
201
|
+
result = Oj.load(res.body)
|
202
|
+
result["repo_slug"]
|
203
|
+
rescue => e
|
204
|
+
return false
|
205
|
+
end
|
206
|
+
|
207
|
+
def github_username(primary_email)
|
208
|
+
username = `git config user.name`.chomp
|
209
|
+
search_results = Octokit.search_users("#{primary_email} in:email").fetch(:items)
|
210
|
+
if search_results.present?
|
211
|
+
username = search_results.first.fetch(:login, username)
|
212
|
+
end
|
213
|
+
username
|
214
|
+
end
|
215
|
+
|
117
216
|
def project_root
|
118
217
|
if defined?(Rails)
|
119
218
|
return Rails.root
|
@@ -123,4 +222,4 @@ def project_root
|
|
123
222
|
return Bundler.root
|
124
223
|
end
|
125
224
|
Dir.pwd
|
126
|
-
end
|
225
|
+
end
|
data/lib/tasks/grade_runner.rake
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
1
|
namespace :grade_runner do
|
4
2
|
desc "Grade project"
|
5
3
|
task :runner do
|
6
4
|
default_submission_url = "https://grades.firstdraft.com"
|
7
5
|
config = {}
|
8
|
-
path =
|
9
|
-
if File.
|
6
|
+
path = Rails.root.join("grades.yml")
|
7
|
+
if File.exist?(path)
|
10
8
|
begin
|
11
9
|
config = YAML.load_file(path)
|
12
10
|
rescue
|
13
|
-
abort "It looks like there's something wrong with your token in `/grades.yml`. Please delete that file and try `
|
11
|
+
abort "It looks like there's something wrong with your token in `/grades.yml`. Please delete that file and try `rails grade:all` again, and be sure to provide the access token for THIS project.".red
|
14
12
|
end
|
15
13
|
end
|
16
14
|
rspec_output_json = JSON.parse(File.read("#{ENV['CIRCLE_ARTIFACTS']}/output/rspec_output.json"))
|
@@ -18,15 +16,10 @@ namespace :grade_runner do
|
|
18
16
|
reponame = ENV["CIRCLE_PROJECT_REPONAME"]
|
19
17
|
sha = ENV["CIRCLE_SHA1"]
|
20
18
|
token = ENV['GRADES_PERSONAL_ACCESS_TOKEN']
|
21
|
-
if token
|
22
|
-
token != "" &&
|
23
|
-
token != " " &&
|
24
|
-
!token.nil? &&
|
25
|
-
token != [] &&
|
26
|
-
token != {}
|
19
|
+
if token.present?
|
27
20
|
GradeRunner::Runner.new('', config['submission_url'] || default_submission_url, token, rspec_output_json, username, reponame, sha, 'circle_ci').process
|
28
21
|
else
|
29
|
-
puts "We couldn't find your access token, so we couldn't record your grade. Please click on the assignment link again and run the
|
22
|
+
puts "We couldn't find your access token, so we couldn't record your grade. Please click on the assignment link again and run the rails grade ... command shown there."
|
30
23
|
end
|
31
24
|
end
|
32
25
|
end
|
metadata
CHANGED
@@ -1,15 +1,86 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grade_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raghu Betina
|
8
|
+
- Jelani Woods
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2023-05-30 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.3.5
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.3.5
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: oj
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 3.13.12
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.13.12
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: octokit
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '5.0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '5.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: faraday-retry
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.0.3
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.3
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '13'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '13'
|
13
84
|
- !ruby/object:Gem::Dependency
|
14
85
|
name: rspec
|
15
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +115,14 @@ dependencies:
|
|
44
115
|
requirements:
|
45
116
|
- - "~>"
|
46
117
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
118
|
+
version: 2.1.4
|
48
119
|
type: :development
|
49
120
|
prerelease: false
|
50
121
|
version_requirements: !ruby/object:Gem::Requirement
|
51
122
|
requirements:
|
52
123
|
- - "~>"
|
53
124
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
125
|
+
version: 2.1.4
|
55
126
|
- !ruby/object:Gem::Dependency
|
56
127
|
name: juwelier
|
57
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,7 +236,9 @@ dependencies:
|
|
165
236
|
- !ruby/object:Gem::Version
|
166
237
|
version: '0'
|
167
238
|
description: This gem runs your RSpec test suite and posts the JSON output to grades.firstdraft.com.
|
168
|
-
email:
|
239
|
+
email:
|
240
|
+
- raghu@firstdraft.com
|
241
|
+
- jelani@firstdraft.com
|
169
242
|
executables: []
|
170
243
|
extensions: []
|
171
244
|
extra_rdoc_files:
|
@@ -206,8 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
279
|
- !ruby/object:Gem::Version
|
207
280
|
version: '0'
|
208
281
|
requirements: []
|
209
|
-
|
210
|
-
rubygems_version: 2.7.8
|
282
|
+
rubygems_version: 3.1.6
|
211
283
|
signing_key:
|
212
284
|
specification_version: 4
|
213
285
|
summary: A Ruby client for [firstdraft Grades](https://grades.firstdraft.com)
|