grade_runner 0.0.3.pre.4.pls.work.3.6.8 → 0.0.3

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: 4a74c9e8eb89ede43ec090ef6f42d8960fc9a9a63045c73c0a49db52a6c92508
4
- data.tar.gz: 6839e3ddeda46014178c358f9e6d20075ad2f4d6140f642b467d1b4c8e0c182a
3
+ metadata.gz: bca6a9499dd2c470ddca0987086391fec5f6b279949dfbbd8467375ddbe83024
4
+ data.tar.gz: f22699e5ba8d8245b4668d8d9e618b0502da9e7f06b87d852b22c17659ceb8b3
5
5
  SHA512:
6
- metadata.gz: 180e880d52a878d6b30bd47d27f6a451689d951cb50b8d0f1bb366943b5d9528181d58b111e696772a901414831a203d4cb66d9309f78898aba5a1bb919abd6e
7
- data.tar.gz: '08a7ef86f28ffcab9e74e10f3ffb6d646a2db40bccc421dc18030ee65359b2e36bbe8a9834f7c49772ecedfabd591b6284802af417ba4f5c62baf81231d54033'
6
+ metadata.gz: deeb0a73556460275d08bb98418e3d9d466515aa4f617cad9e70d4eddd8d497cf8f6f4400f8443e50c019bb399f3650ec7340404891096513410344b76a635ce
7
+ data.tar.gz: c5ffbb984fb6202b03e7122a5d48fbc1cc22a3d3ab7e794ef352f9f40ec5b560c1ebb78c8412c61bf85eef3200e7055506425dafc91888983afc9f5f37e74e75
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GEM
12
12
  descendants_tracker (0.0.4)
13
13
  thread_safe (~> 0.3, >= 0.3.1)
14
14
  diff-lcs (1.3)
15
- docile (1.3.2)
15
+ docile (1.3.1)
16
16
  faraday (0.15.4)
17
17
  multipart-post (>= 1.2, < 3)
18
18
  git (1.5.0)
@@ -36,12 +36,12 @@ GEM
36
36
  rake
37
37
  rdoc
38
38
  semver
39
- jwt (2.2.1)
39
+ jwt (2.1.0)
40
40
  method_source (0.9.2)
41
41
  mini_portile2 (2.4.0)
42
42
  multi_json (1.13.1)
43
43
  multi_xml (0.6.0)
44
- multipart-post (2.1.1)
44
+ multipart-post (2.0.0)
45
45
  nokogiri (1.10.3)
46
46
  mini_portile2 (~> 2.4.0)
47
47
  oauth2 (1.4.1)
@@ -68,7 +68,7 @@ GEM
68
68
  pry-stack_explorer (0.4.9.3)
69
69
  binding_of_caller (>= 0.7)
70
70
  pry (>= 0.9.11)
71
- public_suffix (3.1.0)
71
+ public_suffix (3.0.3)
72
72
  rack (2.0.7)
73
73
  rake (12.3.2)
74
74
  rdoc (3.12.2)
data/Rakefile CHANGED
@@ -40,7 +40,7 @@ task :default => :spec
40
40
 
41
41
  require 'rdoc/task'
42
42
  Rake::RDocTask.new do |rdoc|
43
- version = File.file?('VERSION') ? File.read('VERSION') : ""
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.3.pre.4.pls.work.3.6.8
1
+ 0.0.3
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.3.pre.3 ruby lib
5
+ # stub: grade_runner 0.0.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "grade_runner".freeze
9
- s.version = "0.0.3.pre.3"
9
+ s.version = "0.0.3"
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1".freeze) if s.respond_to? :required_rubygems_version=
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]
14
- s.date = "2019-06-26"
14
+ s.date = "2019-06-19"
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
17
17
  s.extra_rdoc_files = [
@@ -1,11 +1,11 @@
1
- # require 'rails'
1
+ require 'rails'
2
2
 
3
3
  module GradeRunner
4
- # class Railtie < ::Rails::Railtie
4
+ class Railtie < ::Rails::Railtie
5
5
 
6
- # rake_tasks do
7
- # load "tasks/grade_runner.rake"
8
- # load "tasks/grade.rake"
9
- # end
10
- # end
6
+ rake_tasks do
7
+ load "tasks/grade_runner.rake"
8
+ load "tasks/grade.rake"
9
+ end
10
+ end
11
11
  end
data/lib/tasks/grade.rake CHANGED
@@ -1,28 +1,23 @@
1
- require 'yaml'
2
- require 'net/http'
3
- require "json"
4
- require_relative "../grade_runner/runner"
5
-
6
1
  desc "Alias for \"grade:next\"."
7
2
  task grade: "grade:all" do
8
3
  end
9
4
 
10
5
  namespace :grade do
11
6
  desc "Run all tests and submit a build report."
12
- task :all do
7
+ task all: :environment do
13
8
  ARGV.each { |a| task a.to_sym do ; end }
14
9
  input_token = ARGV[1]
15
10
  file_token = nil
16
11
 
17
- config_file_name = File.join(project_root, "grades.yml")
12
+ config_file_name = Rails.root.join("grades.yml")
18
13
  student_config = {}
19
14
  student_config["submission_url"] = "https://grades.firstdraft.com"
20
15
 
21
- if File.file?(config_file_name)
16
+ if File.exist?(config_file_name)
22
17
  begin
23
18
  config = YAML.load_file(config_file_name)
24
19
  rescue
25
- abort "It looks like there's something wrong with your token in `/grades.yml`. Please delete that file and try `rake grade:all` again, and be sure to provide the access token for THIS project.".red
20
+ 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
26
21
  end
27
22
  submission_url = config["submission_url"]
28
23
  file_token = config["personal_access_token"]
@@ -31,24 +26,11 @@ namespace :grade do
31
26
  submission_url = "https://grades.firstdraft.com"
32
27
  end
33
28
 
34
- if input_token != false &&
35
- input_token != "" &&
36
- input_token != " " &&
37
- !input_token.nil? &&
38
- input_token != [] &&
39
- input_token != {}
40
-
29
+ if input_token.present?
41
30
  token = input_token
42
31
  student_config["personal_access_token"] = input_token
43
32
  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
-
33
+ elsif input_token.nil? && file_token.present?
52
34
  token = file_token
53
35
  elsif input_token.nil? && file_token.nil?
54
36
  puts "Enter your access token for this project"
@@ -59,9 +41,6 @@ namespace :grade do
59
41
  new_personal_access_token = $stdin.gets.chomp.strip
60
42
 
61
43
  if new_personal_access_token!= "" && is_valid_token?(submission_url, new_personal_access_token) == false
62
- p "You entered: #{new_personal_access_token}"
63
- p submission_url
64
- p "---"
65
44
  puts "Please enter valid token"
66
45
  new_personal_access_token = ""
67
46
  end
@@ -74,25 +53,15 @@ namespace :grade do
74
53
  end
75
54
  end
76
55
 
77
- if token != false &&
78
- token != "" &&
79
- token != " " &&
80
- !token.nil? &&
81
- token != [] &&
82
- token != {}
56
+ if token.present?
83
57
  if is_valid_token?(submission_url, token) == false
84
58
  student_config["personal_access_token"] = nil
85
59
  update_config_file(config_file_name, student_config)
86
- puts "Your access token looked invalid, so we've reset it to be blank. Please re-run rake grade and, when asked, copy-paste your token carefully from the assignment page."
60
+ 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."
87
61
  else
88
- path = File.join(project_root, "/tmp/output/#{Time.now.to_i}.json")
89
- p path
90
- # `bin/rails db:migrate RAILS_ENV=test`
91
- if Dir.exist?("bin")
92
- `bin/rake db:migrate`
93
- end
94
- # `RAILS_ENV=test bundle exec rspec --order default --format JsonOutputFormatter --out #{path}`
95
- `bundle exec rspec -I spec/support -f JsonOutputFormatter --out #{path}`
62
+ path = Rails.root.join("/tmp/output/#{Time.now.to_i}.json")
63
+ `bin/rails db:migrate RAILS_ENV=test`
64
+ `RAILS_ENV=test bundle exec rspec --order default --format JsonOutputFormatter --out #{path}`
96
65
  rspec_output_json = JSON.parse(File.read(path))
97
66
  username = ""
98
67
  reponame = ""
@@ -101,21 +70,19 @@ namespace :grade do
101
70
  GradeRunner::Runner.new(submission_url, token, rspec_output_json, username, reponame, sha, "manual").process
102
71
  end
103
72
  else
104
- 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 rake grade ... command shown there."
73
+ 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."
105
74
  end
106
75
  end
107
76
 
108
77
  desc "Run only the next failing test."
109
- task :next do
110
- path = File.join(__dir__, "examples.txt")
111
- if File.file?(path)
112
- # `bin/rails db:migrate RAILS_ENV=test`
113
- # puts `RAILS_ENV=test bundle exec rspec --next-failure --format HintFormatter`
114
- puts `bundle exec rspec --next-failure --format HintFormatter`
78
+ task next: :environment do
79
+ path = Rails.root.join("examples.txt")
80
+ if File.exist?(path)
81
+ `bin/rails db:migrate RAILS_ENV=test`
82
+ puts `RAILS_ENV=test bundle exec rspec --next-failure --format HintFormatter`
115
83
  else
116
- # puts `RAILS_ENV=test bundle exec rspec`
117
- puts `bundle exec rspec`
118
- puts "Please rerun rake grade:next to run the first failing spec"
84
+ puts `RAILS_ENV=test bundle exec rspec`
85
+ puts "Please rerun rails grade:next to run the first failing spec"
119
86
  end
120
87
  end
121
88
 
@@ -126,44 +93,15 @@ def update_config_file(config_file_name, config)
126
93
  end
127
94
 
128
95
  def is_valid_token?(root_url, token)
129
- return false unless token.is_a?(String) && !(token =~ /^[1-9A-Za-z][^OIl]{23}$/).nil?
130
- p "remove me later"
131
- p token.is_a?(String) && !(token =~ /^[1-9A-Za-z][^OIl]{23}$/).nil?
132
- p root_url
96
+ return false unless token.is_a?(String) && token =~ /^[1-9A-Za-z][^OIl]{23}$/
133
97
  url = "#{root_url}/submissions/validate_token?token=#{token}"
134
- p url
135
- p "url: #{url}"
136
98
  uri = URI.parse(url)
137
- p "uri: #{uri.to_s}"
138
- p uri.hostname
139
- p uri.port
140
99
  req = Net::HTTP::Get.new(uri, 'Content-Type' => 'application/json')
141
- p req
142
100
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
143
- p "net"
144
- p http
145
- p req
146
101
  http.request(req)
147
102
  end
148
- p "done with request "
149
103
  result = JSON.parse(res.body)
150
- p "Result: "
151
- p result
152
104
  result["success"]
153
105
  rescue => e
154
- p "error!"
155
- p e
156
106
  return false
157
107
  end
158
-
159
- def project_root
160
- if defined?(Rails)
161
- return Rails.root
162
- end
163
-
164
- if defined?(Bundler)
165
- return Bundler.root
166
- end
167
-
168
- Dir.pwd
169
- end
@@ -1,16 +1,14 @@
1
- require 'yaml'
2
-
3
1
  namespace :grade_runner do
4
2
  desc "Grade project"
5
- task :runner do
3
+ task runner: :environment do
6
4
  default_submission_url = "https://grades.firstdraft.com"
7
5
  config = {}
8
- path = File.join(__dir__,"grades.yml")
9
- if File.file?(path)
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 `rake grade:all` again, and be sure to provide the access token for THIS project.".red
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 != false &&
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 rake grade ... command shown there."
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,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.3.pre.4.pls.work.3.6.8
4
+ version: 0.0.3
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-06-27 00:00:00.000000000 Z
11
+ date: 2019-06-19 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