tbgit 1.0.4 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c48220747b8b8469cb020d5157afeed832a3871
4
- data.tar.gz: 22048d8dd2d68fa0359e1866d8f586cb89bbcb4e
3
+ metadata.gz: bc190fce7c3defc7df4c29ebc7f0ed09c76365de
4
+ data.tar.gz: 6c5ec3f084df04208c75c30c77655e4a2506a0db
5
5
  SHA512:
6
- metadata.gz: 416be789a42ff7ebc57619d0569b76dcd2545d0c8c2d0cc24e32192b1f391665e04c7866ad05f30be1a4c180ce6e8ef46c3519c95ccac3b31c890abd6bdd0964
7
- data.tar.gz: 4f2b8b9c7f76a8c5bbf57c7624a33b6b8b259a72ec897c6c36e3c0c06d1c2db1ca720cb8a677dd0168589548e92b9cbecef853b9f5da3d2dbd02388cab1ce51a
6
+ metadata.gz: 236c2f3c28a0a54c77a1688380689ea77730095a9c6e3fe308d440fdaeaa3585c20f7a690aeb8166d713d9920f0e6fb7ccc3fd3cd9b948f603c27262e3350722
7
+ data.tar.gz: e0d93db6c08c334a27bcd118c240d914b87bc09cecf5172a1bce711cecba58af240dbb674ee900d1efa93f404e3b2c8f320cf01582399bfc1a6464e8cb01cb4c
data/bin/tbgit CHANGED
@@ -8,7 +8,7 @@ helptext = HelpText.new
8
8
 
9
9
  case ARGV[0]
10
10
  when "setup"
11
- tbgit.gather
11
+ tbgit.gather(ARGV[1],ARGV[2],ARGV[3])
12
12
 
13
13
  tbgit.add_remotes
14
14
  tbgit.spacer
@@ -26,24 +26,26 @@ when "setup"
26
26
  tbgit.git_branch
27
27
  tbgit.spacer
28
28
  when "pull"
29
- tbgit.update_repos(ARGV[0])
29
+ tbgit.update_repos(ARGV[0],ARGV[1])
30
30
  when "push"
31
- tbgit.update_repos(ARGV[0])
31
+ tbgit.update_repos(ARGV[0],ARGV[1])
32
+ when "push-origin"
33
+ tbgit.push_origin(ARGV[1])
32
34
  when "merge"
33
- tbgit.merge_and_commit
35
+ tbgit.merge_and_commit(ARGV[1],ARGV[2],ARGV[3])
34
36
  when "status"
35
37
  tbgit.git_status
36
38
  when "each"
37
39
  tbgit.on_each_gather
38
40
  when "spec"
39
- tbgit.spec
41
+ tbgit.spec(ARGV[1],ARGV[2],ARGV[3],ARGV[4],ARGV[5])
40
42
  when "add-remotes"
41
- tbgit.gather
43
+ tbgit.gather(ARGV[1],ARGV[2],ARGV[3])
42
44
  tbgit.spacer
43
45
 
44
46
  tbgit.add_remotes
45
47
  when "create-locals"
46
- tbgit.gather
48
+ tbgit.gather(ARGV[1],ARGV[2],ARGV[3])
47
49
  tbgit.spacer
48
50
 
49
51
  tbgit.create_local_tracking_remotes
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+
4
+ class Parser
5
+
6
+ def json_parse(string)
7
+ JSON.parse(string)
8
+ end
9
+
10
+ def score_parse(masterfolder) #main parsing method
11
+ # Open master scoresheet file for writing
12
+ ss = File.new(masterfolder + "/scoresheet.txt", "w")
13
+
14
+ # Open each .rb file in directory and add username and failure count to scoresheet
15
+ Dir.glob(masterfolder + '/*') do |student_result|
16
+ if File.basename(student_result) != "scoresheet.txt"
17
+ # Parse file into JSON and extract failure count
18
+ file = File.open(student_result, "r")
19
+ contents = file.read
20
+ json = json_parse(contents)
21
+ failure_count = json['summary']['failure_count']
22
+
23
+ # Set filename to just username of student
24
+ filename = File.basename(student_result)
25
+ filename.chomp(File.extname(filename))
26
+
27
+ # Write username and failure count to score sheet
28
+ ss << filename
29
+ ss << ' '
30
+ ss << failure_count
31
+ ss << "\n"
32
+ file.close
33
+ end
34
+ end
35
+
36
+ ss.close
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ 2 0
2
+ 1 0
3
+ 3 0
data/lib/tbgit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tbgit
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
data/lib/tbgit.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "tbgit/version"
2
2
  require "tempfile"
3
+ require "score_parser"
3
4
 
4
5
  module Main
5
6
 
@@ -10,14 +11,16 @@ module Main
10
11
  end
11
12
 
12
13
  #confirms a given message
13
- def confirm(message)
14
- print message + " (y/n) "
15
- response = $stdin.gets.chomp
16
- if response == 'y'
17
- #do nothing
18
- else
19
- exit
20
- end
14
+ def confirm(flag,message)
15
+ if flag != '-y'
16
+ print message + " (y/n) "
17
+ response = $stdin.gets.chomp
18
+ if response == 'y'
19
+ #do nothing
20
+ else
21
+ exit
22
+ end
23
+ end
21
24
  end
22
25
 
23
26
  #three simple git methods
@@ -35,24 +38,36 @@ module Main
35
38
  end
36
39
 
37
40
  #gather necessary information
38
- def gather
39
- puts 'Students file |../students|:'
40
- @students_file = $stdin.gets.chomp
41
- if @students_file == ""
42
- @students_file = "../students"
43
- end
44
-
45
- puts 'Organization name |yale-stc-developer-curriculum|:'
46
- @organization = $stdin.gets.chomp
47
- if @organization == ""
48
- @organization = "yale-stc-developer-curriculum"
49
- end
50
-
51
- puts 'Student Repo Name |TechBootcampHomework|:'
52
- @reponame = $stdin.gets.chomp
53
- if @reponame == ""
54
- @reponame = "TechBootcampHomework"
55
- end
41
+ def gather(students_file, organization, reponame)
42
+ if students_file == ""
43
+ puts 'Students file |../students|:'
44
+ @students_file = $stdin.gets.chomp
45
+ if @students_file == ""
46
+ @students_file = "../students"
47
+ end
48
+ else
49
+ @students_file = students_file
50
+ end
51
+
52
+ if organization == ""
53
+ puts 'Organization name |yale-stc-developer-curriculum|:'
54
+ @organization = $stdin.gets.chomp
55
+ if @organization == ""
56
+ @organization = "yale-stc-developer-curriculum"
57
+ end
58
+ else
59
+ @organization = organization
60
+ end
61
+
62
+ if reponame == ""
63
+ puts 'Student Repo Name |TechBootcampHomework|:'
64
+ @reponame = $stdin.gets.chomp
65
+ if @reponame == ""
66
+ @reponame = "TechBootcampHomework"
67
+ end
68
+ else
69
+ @reponame = reponame
70
+ end
56
71
  end
57
72
 
58
73
  #update remotes
@@ -63,7 +78,6 @@ module Main
63
78
 
64
79
  #add each student repository as a remote
65
80
  def add_remotes
66
- confirm("Each student repository will be added as a remote. Continue?")
67
81
  students = IO.readlines(@students_file)
68
82
  students.each do |username|
69
83
  username.delete!("\n")
@@ -77,7 +91,6 @@ module Main
77
91
 
78
92
  #create local branches to track remote student repositories
79
93
  def create_local_tracking_remotes
80
- confirm("Local branches will be created to track remote student repositories. Continue?")
81
94
  students = IO.readlines(@students_file)
82
95
  students.each do |username|
83
96
  username.delete!("\n")
@@ -102,25 +115,35 @@ module Main
102
115
  end
103
116
 
104
117
  #used for push / pull
105
- def update_repos(pushpull)
118
+ def update_repos(pushpull,flag)
106
119
  if pushpull == "push"
107
- confirm("Each local student branch will be pushed to their remote master branch. Continue?")
120
+ confirm(flag,"Each local student branch will be pushed to their remote master branch. Continue?")
108
121
  on_each_exec(["git push <branch> <branch>:master"])
109
122
  else
110
- confirm("Each remote student master branch will be pulled to the local branch. Continue?")
123
+ confirm(flag,"Each remote student master branch will be pulled to the local branch. Continue?")
111
124
  on_each_exec(["git pull <branch> master"])
112
125
  end
113
126
  end
114
127
 
128
+ def push_origin(flag) #push all student branches to our origin
129
+ confirm(flag,"Each local student branch will be pushed to the the origin remote. Continue?")
130
+ on_each_exec(["git push origin <branch>"])
131
+ end
132
+
115
133
  #merges from master (or another branch) to each student branch and commits the changes
116
- def merge_and_commit
134
+ def merge_and_commit(flag,merge_branch,message)
117
135
 
118
- confirm("A merge and commit will be performed on each local student branch (from the branch you specify). Continue?")
119
- puts "Merge from branch: "
120
- merge_branch = $stdin.gets.chomp
136
+ confirm(flag,"A merge and commit will be performed on each local student branch (from the branch you specify). Continue?")
137
+
138
+ if merge_branch != ""
139
+ puts "Merge from branch: "
140
+ merge_branch = $stdin.gets.chomp
141
+ end
121
142
 
122
- puts "Commit Message: "
123
- message = $stdin.gets.chomp
143
+ if message != ""
144
+ puts "Commit Message: "
145
+ message = $stdin.gets.chomp
146
+ end
124
147
 
125
148
  commands = ["git merge --no-commit " + merge_branch.to_s,
126
149
  "git add --all",
@@ -177,25 +200,34 @@ module Main
177
200
  on_each_exec(["git status <branch>"])
178
201
  end
179
202
 
180
- def spec
181
- puts "Please specify the relative path from your pwd to the rspec file you would like to spec, eg. 'hw1/spec/spec.rb'"
182
- specfile = $stdin.gets.chomp
203
+ def spec(flag,specfile,studentcopy,mastercopy,commit_message)
204
+
205
+ if specfile==""
206
+ puts "Please specify the relative path from your pwd to the rspec file you would like to spec, eg. 'hw1/spec/spec.rb'"
207
+ specfile = $stdin.gets.chomp
208
+ end
183
209
 
184
- puts "Where would you like to save each student's individual results?"
185
- puts "**Must be inside the student's repo directory, eg. 'hw1/spec/results.txt'**"
186
- studentcopy = $stdin.gets.chomp
210
+ if studentcopy==""
211
+ puts "Where would you like to save each student's individual results?"
212
+ puts "**Must be inside the student's repo directory, eg. 'hw1/spec/results.txt'**"
213
+ studentcopy = $stdin.gets.chomp
214
+ end
187
215
 
188
- puts "In which folder would you like to save a copy of all results?"
189
- puts "**Must be outside the student's repo directory, eg. '../results'**"
190
- mastercopy = $stdin.gets.chomp
216
+ if mastercopy==""
217
+ puts "In which folder would you like to save a copy of all results?"
218
+ puts "**Must be outside the student's repo directory, eg. '../results'**"
219
+ mastercopy = $stdin.gets.chomp
220
+ end
191
221
 
192
222
  puts "mkdir " + mastercopy
193
223
  system "mkdir " + mastercopy
194
224
 
195
- puts "Commit message (commiting each student's results to their repo):"
196
- commit_message = $stdin.gets.chomp
225
+ if commit_message==""
226
+ puts "Commit message (commiting each student's results to their repo):"
227
+ commit_message = $stdin.gets.chomp
228
+ end
197
229
 
198
- confirm("'rspec " + specfile + "' will be executed on each student's local branch. \
230
+ confirm(flag,"'rspec " + specfile + "' will be executed on each student's local branch. \
199
231
  Individual results will be saved to " + studentcopy + " and master results to " + mastercopy + ". Continue?")
200
232
 
201
233
  on_each_exec(["rspec " +specfile + " > " + studentcopy, #overwrite
@@ -204,6 +236,9 @@ module Main
204
236
  "git commit -am '" + commit_message + "'",
205
237
  "git push <branch> <branch>:master"])
206
238
 
239
+ my_parser = Parser.new
240
+ my_parser.score_parse(mastercopy)
241
+
207
242
  end
208
243
 
209
244
  end #class
data/tbgit.gemspec CHANGED
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.6"
23
23
  spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "json"
25
+ spec.add_development_dependency "rubygems"
24
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tbgit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Proctor
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubygems
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  description: ''
42
70
  email:
43
71
  - charlie@charlieproctor.com
@@ -53,6 +81,8 @@ files:
53
81
  - Rakefile
54
82
  - bin/tbgit
55
83
  - lib/helptext.rb
84
+ - lib/score_parser.rb
85
+ - lib/scoresheet.txt
56
86
  - lib/tbgit.rb
57
87
  - lib/tbgit/version.rb
58
88
  - tbgit.gemspec