submit-homework 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/submit_hw +140 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df9844246bde167b6b974946dfc1a0af0bffa712
|
4
|
+
data.tar.gz: 8b8c79963e8051489a258aba0266cc7438541ab8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4687540c68b63a46533b48d2db91baa1f028cf69cc9e7cd3fe0ef82428b1e5b78cd35aeb3ce4efcbde0a0743855c748c58037f7eb4f273d4bce5fb4c4a65f158
|
7
|
+
data.tar.gz: 0081f1c9e1da755026581aa8c05e79837ed4d5a987f4ca51a01f86970c17133013347d7a25f6ceb92504b3098ba8ed42e8daa51dd3444be3dea8fe35a3ef3374
|
data/bin/submit_hw
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'json'
|
3
|
+
require 'yaml'
|
4
|
+
require 'colorize'
|
5
|
+
require 'io/console'
|
6
|
+
require 'octokit'
|
7
|
+
|
8
|
+
require 'pry'
|
9
|
+
|
10
|
+
# TODO (phlco) remove Hub dependency and use github gem/api directly
|
11
|
+
|
12
|
+
# TODO (phlco) we could move this to installfest too
|
13
|
+
unless ENV['HUMAN_NAME']
|
14
|
+
puts "Please enter your full name (first and last)" # we could say lowercase here.
|
15
|
+
human_name = gets.chomp.strip.downcase.gsub(' ', '_')
|
16
|
+
system("export HUMAN_NAME=#{human_name}")
|
17
|
+
system("echo '\nexport HUMAN_NAME=#{human_name}\n' >> ~/.bash_profile")
|
18
|
+
end
|
19
|
+
|
20
|
+
unless File.exists? File.expand_path(".config/hub","~")
|
21
|
+
puts "You haven't used the GitHub API with Hub before."
|
22
|
+
puts "We need your credentials (one time)."
|
23
|
+
print "Please enter your GitHub username: "
|
24
|
+
username = gets.chomp
|
25
|
+
print "Please enter your GitHub password: "
|
26
|
+
password = $stdin.noecho(&:gets).chomp
|
27
|
+
puts
|
28
|
+
|
29
|
+
client = Octokit::Client.new \
|
30
|
+
:login => username,
|
31
|
+
:password => password
|
32
|
+
|
33
|
+
begin
|
34
|
+
client.user # check for bad auth and fail
|
35
|
+
rescue
|
36
|
+
puts "Authentication error. Check your username and password."
|
37
|
+
exit(false)
|
38
|
+
end
|
39
|
+
|
40
|
+
# add random nuber to token name to allow multiple tokens
|
41
|
+
random_number = (Random.rand * 10000).to_i
|
42
|
+
|
43
|
+
response = client.create_authorization \
|
44
|
+
:scopes => ["user","repo"],
|
45
|
+
:note => "hub token added by submit_hw [#{random_number}]"
|
46
|
+
|
47
|
+
hub_config = {
|
48
|
+
"github.com" => [
|
49
|
+
{
|
50
|
+
"oauth_token" => response[:token],
|
51
|
+
"user" => username
|
52
|
+
}
|
53
|
+
]
|
54
|
+
}.to_yaml
|
55
|
+
|
56
|
+
# ensure ~/.config exists
|
57
|
+
FileUtils.mkdir_p File.expand_path(".config","~")
|
58
|
+
|
59
|
+
File.write(File.expand_path(".config/hub","~"), hub_config)
|
60
|
+
end
|
61
|
+
|
62
|
+
def prompt_to_reload
|
63
|
+
puts "WARNING: this script changed your ~/.bash_profile file." + \
|
64
|
+
" When possible immediately run the following command:".yellow
|
65
|
+
puts " $ reload"
|
66
|
+
puts "or, if that fails:".yellow
|
67
|
+
puts " $ source ~/.bash_profile"
|
68
|
+
end
|
69
|
+
|
70
|
+
def exit_script
|
71
|
+
prompt_to_reload unless ENV['HUMAN_NAME']
|
72
|
+
exit(false)
|
73
|
+
end
|
74
|
+
|
75
|
+
data = {}
|
76
|
+
|
77
|
+
print "\nHow many parts of the homework did you finish? "
|
78
|
+
print "\nSteps can be found at the bottom of tonights markdown : "
|
79
|
+
data["completeness"] = gets
|
80
|
+
|
81
|
+
begin
|
82
|
+
data["completeness"] = Integer(data["completeness"])
|
83
|
+
raise ArgumentError if data["completeness"] < 0
|
84
|
+
rescue ArgumentError
|
85
|
+
puts "Invalid: not an integer (0 or greater)".red
|
86
|
+
exit_script
|
87
|
+
end
|
88
|
+
|
89
|
+
print "\nComfortability [1 - 3]? "
|
90
|
+
print "\n1 = My brain hurts, 2 = I need another pass, 3 = Crushed it : "
|
91
|
+
data["comfortability"] = gets.gsub(/\W+/, '').to_i
|
92
|
+
|
93
|
+
unless (1..5).member?(data["comfortability"])
|
94
|
+
puts "Invalid numbers (only 1 - 3)".red
|
95
|
+
exit_script
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
puts "What specifically would you like feedback on for this assignment?"
|
100
|
+
data["feedback"] = gets.chomp.downcase.to_s
|
101
|
+
|
102
|
+
# github_name = `git config --get user.name`.strip
|
103
|
+
github_name = ENV['HUMAN_NAME'] || human_name
|
104
|
+
|
105
|
+
puts "Pushing your work to your fork.\n".green
|
106
|
+
`git push origin master`
|
107
|
+
puts
|
108
|
+
|
109
|
+
begin
|
110
|
+
upstream = `git config --get remote.upstream.url`.strip.match(/:(.*)\.git/).captures.first
|
111
|
+
rescue NoMethodError
|
112
|
+
# Upstream has not been set
|
113
|
+
puts "You haven't configured a remote that points to the upstream repository!".red
|
114
|
+
puts "Run the following then try again:".red
|
115
|
+
puts " $ git remote add upstream CLASS_REPO_SSH_URL"
|
116
|
+
exit_script
|
117
|
+
end
|
118
|
+
|
119
|
+
reconstituted_name = github_name.split('_').map(&:capitalize).join(' ')
|
120
|
+
branch = "#{upstream}:#{github_name}"
|
121
|
+
submitted_at = Time.now.strftime("%H:%m")
|
122
|
+
submitted_on = Time.now.strftime('%Y-%m-%d')
|
123
|
+
message = "HW for #{reconstituted_name}: #{submitted_on} at #{submitted_at}\n\n#{data.to_json}"
|
124
|
+
|
125
|
+
submission = `hub pull-request -m '#{message}' -b '#{branch}' 2>&1` # print to STDOUT
|
126
|
+
|
127
|
+
# puts submission
|
128
|
+
|
129
|
+
if submission.include? "pull request already exists"
|
130
|
+
puts "You already have an outstanding pull request which the instructors have yet to merge! Have a great day.".yellow
|
131
|
+
elsif submission.include? "Error creating pull request: Internal Server Error (HTTP 500)"
|
132
|
+
puts "We may not have an upstream branch for you yet. Contact your Instructors!".yellow
|
133
|
+
elsif submission.include? "No commits between"
|
134
|
+
# NOTE: (phlco) we'll ignore this for now becuase we probably won't get this error.
|
135
|
+
puts "You haven't commited any changes.".red
|
136
|
+
else
|
137
|
+
puts "Thanks for submitting your homework.".green
|
138
|
+
end
|
139
|
+
|
140
|
+
prompt_to_reload unless ENV['HUMAN_NAME']
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: submit-homework
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeffrey Konowitch
|
8
|
+
- PJ Hughes
|
9
|
+
- Phillip Lamplugh
|
10
|
+
- Travis Vander Hoop
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: hub
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.12'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.12'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: octokit
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '3.0'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: colorize
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.7.3
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 0.7.3
|
58
|
+
description: ''
|
59
|
+
email: pj@ga.co
|
60
|
+
executables:
|
61
|
+
- submit_hw
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- "./bin/submit_hw"
|
66
|
+
- bin/submit_hw
|
67
|
+
homepage: https://github.com/ga-instructors/wdi-submit-hw
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.4.8
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Submitting homework for GA's WDI.
|
91
|
+
test_files: []
|