grade_runner 0.0.7 → 0.0.9

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
  SHA256:
3
- metadata.gz: a8287f06bead27eb7200e42fd3e95c5b59a3d6b20a2ec243ec0208a3833fa5b2
4
- data.tar.gz: c37414bdcf6726a2c0cc4303d8a03de1b6d96f5d9fb6c8cc114f5d5dd1ddd8b6
3
+ metadata.gz: 126dec678889c8e49764337f85a40e87a389e960ad813a4cb04e297446bbf74e
4
+ data.tar.gz: f4f36124eca6fecf133c6f2fe42ab1d3fa03cf8e1e26f3cf5f94bd6d88ca737f
5
5
  SHA512:
6
- metadata.gz: 2249bf710cf8ee1dd932784084dd95f9468a0b5bc878a8bc097424c4ecfdfbda7857212941b7ffc4644b3abd889890bec073f3a73ed7e952a91f43043e417108
7
- data.tar.gz: 6ab0d79a82276c71709f6903207d12cddf3130eedc96ea5816efbeeefda54f21a9c7440333a3c5494d84e66da00cde91b30d407e6c74615c007c17141c48e881
6
+ metadata.gz: 6c3eb6813b2d0babbb39974430b7b7ba36e658f4970cc77a102f2ee0522feab2de89b2f7c42ecbed63acdfaed6c98544f64a4d8a9572c4e3fe462e574fc1fcfc
7
+ data.tar.gz: 28d9326401af07677e5f6358b708695aa717571056ba0c0842cd71126b9f90594b12764cdca0790ab530c94e7fda818a67b2d9faef04bfab082a241a3069a6ef
data/Gemfile CHANGED
@@ -10,7 +10,7 @@ gem "rake", "~> 13"
10
10
  # Include everything needed to run rake, tests, features, etc.
11
11
  group :development do
12
12
  gem "rspec", "~> 3.5.0"
13
- gem "rdoc", "~> 3.12"
13
+ gem "rdoc", "~> 6.1"
14
14
  gem "bundler", "~> 2.1.4"
15
15
  gem "juwelier", "~> 2.1.0"
16
16
  gem "simplecov", ">= 0"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (7.0.4.3)
4
+ activesupport (7.0.7.1)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.2)
6
6
  i18n (>= 1.6, < 2)
7
7
  minitest (>= 5.1)
@@ -53,10 +53,9 @@ GEM
53
53
  oauth2 (~> 1.0)
54
54
  hashie (3.6.0)
55
55
  highline (2.1.0)
56
- i18n (1.12.0)
56
+ i18n (1.14.1)
57
57
  concurrent-ruby (~> 1.0)
58
58
  interception (0.5)
59
- json (1.8.6)
60
59
  juwelier (2.1.3)
61
60
  builder
62
61
  bundler (>= 1.13)
@@ -70,7 +69,7 @@ GEM
70
69
  jwt (2.7.0)
71
70
  method_source (1.0.0)
72
71
  mini_portile2 (2.8.1)
73
- minitest (5.18.0)
72
+ minitest (5.19.0)
74
73
  multi_json (1.15.0)
75
74
  multi_xml (0.6.0)
76
75
  multipart-post (2.3.0)
@@ -105,13 +104,15 @@ GEM
105
104
  pry-stack_explorer (0.6.1)
106
105
  binding_of_caller (~> 1.0)
107
106
  pry (~> 0.13)
107
+ psych (5.1.1.1)
108
+ stringio
108
109
  public_suffix (5.0.1)
109
110
  racc (1.6.2)
110
111
  rack (3.0.7)
111
112
  rake (13.0.6)
112
113
  rchardet (1.8.0)
113
- rdoc (3.12.2)
114
- json (~> 1.4)
114
+ rdoc (6.6.0)
115
+ psych (>= 4.0.0)
115
116
  rspec (3.5.0)
116
117
  rspec-core (~> 3.5.0)
117
118
  rspec-expectations (~> 3.5.0)
@@ -137,6 +138,7 @@ GEM
137
138
  simplecov-html (0.12.3)
138
139
  simplecov_json_formatter (0.1.4)
139
140
  slop (3.6.0)
141
+ stringio (3.0.9)
140
142
  thread_safe (0.3.6)
141
143
  tzinfo (2.0.6)
142
144
  concurrent-ruby (~> 1.0)
@@ -161,7 +163,7 @@ DEPENDENCIES
161
163
  pry-rescue (~> 1)
162
164
  pry-stack_explorer (~> 0)
163
165
  rake (~> 13)
164
- rdoc (~> 3.12)
166
+ rdoc (~> 6.1)
165
167
  rspec (~> 3.5.0)
166
168
  simplecov
167
169
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.9
data/grade_runner.gemspec CHANGED
@@ -2,16 +2,16 @@
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.7 ruby lib
5
+ # stub: grade_runner 0.0.9 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "grade_runner".freeze
9
- s.version = "0.0.7"
9
+ s.version = "0.0.9"
10
10
 
11
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
13
  s.authors = ["Raghu Betina".freeze, "Jelani Woods".freeze]
14
- s.date = "2023-04-19"
14
+ s.date = "2023-11-20"
15
15
  s.description = "This gem runs your RSpec test suite and posts the JSON output to grades.firstdraft.com.".freeze
16
16
  s.email = ["raghu@firstdraft.com".freeze, "jelani@firstdraft.com".freeze]
17
17
  s.extra_rdoc_files = [
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
51
51
  s.add_runtime_dependency(%q<faraday-retry>.freeze, ["~> 1.0.3"])
52
52
  s.add_runtime_dependency(%q<rake>.freeze, ["~> 13"])
53
53
  s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
54
- s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
54
+ s.add_development_dependency(%q<rdoc>.freeze, ["~> 6.1"])
55
55
  s.add_development_dependency(%q<bundler>.freeze, ["~> 2.1.4"])
56
56
  s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
57
57
  s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
@@ -68,7 +68,7 @@ Gem::Specification.new do |s|
68
68
  s.add_dependency(%q<faraday-retry>.freeze, ["~> 1.0.3"])
69
69
  s.add_dependency(%q<rake>.freeze, ["~> 13"])
70
70
  s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
71
- s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
71
+ s.add_dependency(%q<rdoc>.freeze, ["~> 6.1"])
72
72
  s.add_dependency(%q<bundler>.freeze, ["~> 2.1.4"])
73
73
  s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
74
74
  s.add_dependency(%q<simplecov>.freeze, [">= 0"])
data/lib/tasks/grade.rake CHANGED
@@ -14,8 +14,6 @@ namespace :grade do
14
14
  input_token = ARGV[1]
15
15
  file_token = nil
16
16
 
17
- sync_specs_with_source
18
-
19
17
  config_dir_name = find_or_create_config_dif
20
18
  config_file_name = "#{config_dir_name}/.ltici_apitoken.yml"
21
19
  student_config = {}
@@ -70,6 +68,10 @@ namespace :grade do
70
68
  update_config_file(config_file_name, student_config)
71
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."
72
70
  else
71
+ full_reponame = upstream_repo(submission_url, token)
72
+ set_upstream_remote(full_reponame)
73
+ sync_specs_with_source(full_reponame)
74
+
73
75
  path = File.join(project_root, "/tmp/output/#{Time.now.to_i}.json")
74
76
  `bin/rails db:migrate RAILS_ENV=test` if defined?(Rails)
75
77
  `RAILS_ENV=test bundle exec rspec --order default --format JsonOutputFormatter --out #{path}`
@@ -129,10 +131,7 @@ namespace :grade do
129
131
 
130
132
  end
131
133
 
132
- def sync_specs_with_source
133
- reponame = `basename -s .git \`git config --get remote.origin.url\``.chomp
134
- full_reponame = "appdev-projects/#{reponame}"
135
-
134
+ def sync_specs_with_source(full_reponame)
136
135
  if Octokit.repository?(full_reponame)
137
136
  repo_contents = Octokit.contents(full_reponame)
138
137
  remote_spec_folder = repo_contents.find { |git_object| git_object[:name] == 'spec' }
@@ -146,7 +145,7 @@ def sync_specs_with_source
146
145
  local_sha = `git ls-tree HEAD #{project_root.join('spec')}`.chomp.split[2]
147
146
 
148
147
  unless remote_sha == local_sha
149
- `git fetch upstream`
148
+ `git fetch upstream -q`
150
149
  # Remove local contents of spec folder
151
150
  `rm -rf spec/*`
152
151
  default_branch = `git remote show upstream | grep 'HEAD branch' | cut -d' ' -f5`.chomp
@@ -158,6 +157,15 @@ def sync_specs_with_source
158
157
  end
159
158
  end
160
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
168
+
161
169
  def update_config_file(config_file_name, config)
162
170
  File.write(config_file_name, YAML.dump(config))
163
171
  end
@@ -182,7 +190,22 @@ rescue => e
182
190
  return false
183
191
  end
184
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
+
185
207
  def github_username(primary_email)
208
+ return "" if primary_email.blank?
186
209
  username = `git config user.name`.chomp
187
210
  search_results = Octokit.search_users("#{primary_email} in:email").fetch(:items)
188
211
  if search_results.present?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grade_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raghu Betina
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-05-04 00:00:00.000000000 Z
12
+ date: 2023-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '3.12'
104
+ version: '6.1'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '3.12'
111
+ version: '6.1'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: bundler
114
114
  requirement: !ruby/object:Gem::Requirement