tbgit 1.0.6 → 1.1.1
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 +4 -4
- data/bin/tbgit +21 -11
- data/lib/helptext.rb +44 -40
- data/lib/tbgit/version.rb +1 -1
- data/lib/tbgit.rb +355 -227
- data/lib/tbspec.rb +130 -0
- data/tbgit.gemspec +1 -0
- metadata +17 -3
- data/lib/scoresheet.txt +0 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e8bba5a81f9d15e8ddf62a5588599be8d8dc20bd
         | 
| 4 | 
            +
              data.tar.gz: 06006d1182bf97073237ed11519cc68fe93ddb42
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b0cb40f51daa2c3e955c0dabf07691754190917ad975fa7c5a40d76dcafa4cbb385c68679b5da4548978b4737932627c09ae6c65345e3f3142f5b82f66e06b81
         | 
| 7 | 
            +
              data.tar.gz: 326413c17f9f36162955555aac79e810837e0454daba65b917c7954cecd1788e07659c53b94950bd838c1a519dc86f749f515e60e1c6a03ae3c7bf66c0e218cc
         | 
    
        data/bin/tbgit
    CHANGED
    
    | @@ -2,13 +2,19 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'tbgit'
         | 
| 4 4 | 
             
            require 'helptext'
         | 
| 5 | 
            +
            require 'tbspec'
         | 
| 5 6 |  | 
| 6 | 
            -
            tbgit =  | 
| 7 | 
            +
            tbgit = TBGit.new
         | 
| 7 8 | 
             
            helptext = HelpText.new
         | 
| 9 | 
            +
            tbspec = TBSpec.new
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            def version
         | 
| 12 | 
            +
            	puts "tbgit " + Gem.loaded_specs['tbgit'].version.to_s
         | 
| 13 | 
            +
            end
         | 
| 8 14 |  | 
| 9 15 | 
             
            case ARGV[0] 
         | 
| 10 16 | 
             
            when "setup"
         | 
| 11 | 
            -
            	tbgit.gather(ARGV[ | 
| 17 | 
            +
            	tbgit.gather(ARGV[0],ARGV.drop(1))
         | 
| 12 18 |  | 
| 13 19 | 
             
            	tbgit.add_remotes
         | 
| 14 20 | 
             
            	tbgit.spacer
         | 
| @@ -26,31 +32,35 @@ when "setup" | |
| 26 32 | 
             
            	tbgit.git_branch
         | 
| 27 33 | 
             
            	tbgit.spacer
         | 
| 28 34 | 
             
            when "pull"
         | 
| 29 | 
            -
            	tbgit.update_repos(ARGV[0],ARGV | 
| 35 | 
            +
            	tbgit.update_repos(ARGV[0],ARGV.drop(1))	
         | 
| 30 36 | 
             
            when "push"
         | 
| 31 | 
            -
            	tbgit.update_repos(ARGV[0],ARGV | 
| 37 | 
            +
            	tbgit.update_repos(ARGV[0],ARGV.drop(1))	
         | 
| 32 38 | 
             
            when "push-origin"
         | 
| 33 | 
            -
            	tbgit.push_origin(ARGV | 
| 39 | 
            +
            	tbgit.push_origin(ARGV.drop(1))
         | 
| 34 40 | 
             
            when "merge"
         | 
| 35 | 
            -
            	tbgit.merge_and_commit(ARGV | 
| 41 | 
            +
            	tbgit.merge_and_commit(ARGV.drop(1))
         | 
| 36 42 | 
             
            when "status"
         | 
| 37 43 | 
             
            	tbgit.git_status
         | 
| 38 44 | 
             
            when "each"
         | 
| 39 | 
            -
            	tbgit.on_each_gather
         | 
| 45 | 
            +
            	tbgit.on_each_gather(ARGV.drop(1))
         | 
| 40 46 | 
             
            when "spec"
         | 
| 41 | 
            -
            	 | 
| 47 | 
            +
            	tbspec.spec(ARGV.drop(1))
         | 
| 42 48 | 
             
            when "add-remotes"
         | 
| 43 | 
            -
            	tbgit.gather(ARGV[ | 
| 49 | 
            +
            	tbgit.gather(ARGV[0],ARGV.drop(1))
         | 
| 44 50 | 
             
            	tbgit.spacer
         | 
| 45 51 |  | 
| 46 52 | 
             
            	tbgit.add_remotes
         | 
| 47 53 | 
             
            when "create-locals"
         | 
| 48 | 
            -
            	tbgit.gather(ARGV[ | 
| 54 | 
            +
            	tbgit.gather(ARGV[0],ARGV.drop(1))
         | 
| 49 55 | 
             
            	tbgit.spacer
         | 
| 50 56 |  | 
| 51 57 | 
             
            	tbgit.create_local_tracking_remotes
         | 
| 52 58 | 
             
            when "add-webhooks"
         | 
| 53 | 
            -
            	tbgit.add_webhooks(ARGV | 
| 59 | 
            +
            	tbgit.add_webhooks(ARGV.drop(1))
         | 
| 60 | 
            +
            when "-v"
         | 
| 61 | 
            +
            	version
         | 
| 62 | 
            +
            when "--version"
         | 
| 63 | 
            +
            	version
         | 
| 54 64 | 
             
            else
         | 
| 55 65 | 
             
            	helptext.helpme
         | 
| 56 66 | 
             
            end
         | 
    
        data/lib/helptext.rb
    CHANGED
    
    | @@ -1,51 +1,55 @@ | |
| 1 1 | 
             
            class HelpText
         | 
| 2 2 | 
             
              	def helpme
         | 
| 3 3 | 
             
              		puts ""
         | 
| 4 | 
            -
              		puts " | 
| 5 | 
            -
              		puts " | 
| 6 | 
            -
              		puts " | 
| 4 | 
            +
              		puts "\tTBGit is a command-line utility to facilitate the management of multiple GitHub student repositories."
         | 
| 5 | 
            +
              		puts "\t\t\t~ created by the teaching staff at 2014 YEI Tech Bootcamp"
         | 
| 6 | 
            +
              		puts "\t\t\t\t~ partly based off of https://github.com/education/teachers_pet"
         | 
| 7 7 | 
             
              		puts "	Commands:"
         | 
| 8 | 
            -
              		puts " | 
| 9 | 
            -
              		puts " | 
| 10 | 
            -
              		puts " | 
| 11 | 
            -
              		puts " | 
| 12 | 
            -
              		puts " | 
| 13 | 
            -
              		puts " | 
| 14 | 
            -
              		puts " | 
| 8 | 
            +
              		puts "\t\t~ setup   	sets up a tbgit environment. See decription below"
         | 
| 9 | 
            +
              		puts "\t\t~ push  	pushes all local student branches to their remote master branches"
         | 
| 10 | 
            +
              		puts "\t\t~ pull   	pulls all remote master branches to local student branches"
         | 
| 11 | 
            +
              		puts "\t\t~ merge   	merges a specified branch with each student branch and then commits the changes"
         | 
| 12 | 
            +
              		puts "\t\t~ status 	runs `git status` on each students branch and displays the results"
         | 
| 13 | 
            +
              		puts "\t\t~ each 		executes a specified series of commands on each local student branch"
         | 
| 14 | 
            +
              		puts "\t\t~ spec 		runs rspec on specified files in a students repo"     
         | 
| 15 | 
            +
                  puts ""    
         | 
| 16 | 
            +
                  puts "\t\t~ add-webhooks    adds webhooks (on push events) to all student repositories"
         | 
| 17 | 
            +
                  puts ""
         | 
| 18 | 
            +
              		puts "\t\t~ add-remotes  	adds each student's repository as a remote"
         | 
| 19 | 
            +
              		puts "\t\t~ create-locals 	creates a local branch to track the students remote master branch"
         | 
| 20 | 
            +
              		puts "\t\t	^----> these are both part of the setup process"
         | 
| 15 21 | 
             
              		puts ""
         | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
              		puts " | 
| 22 | 
            +
                  puts "\t\t** Run `tbgit COMMAND --help` to view specific options for each command **"
         | 
| 23 | 
            +
                  puts "" 
         | 
| 24 | 
            +
              		puts "\tTBGit Environment"
         | 
| 25 | 
            +
              		puts "\t\t~ it's a regular git repository -- with lots of fancy features!"
         | 
| 26 | 
            +
              		puts "\t\t~ there is a master branch for teachers to work off of (create hw files, etc..)"
         | 
| 27 | 
            +
              		puts "\t\t\t--> teachers can obviously create and work off other branches if desired"
         | 
| 28 | 
            +
              		puts "\t\t~ each student's repository is a remote of the git repo"
         | 
| 29 | 
            +
              		puts "\t\t~ there is a local branch to track each student's remote master branches"
         | 
| 19 30 | 
             
              		puts ""
         | 
| 20 | 
            -
              		puts " | 
| 21 | 
            -
              		puts " | 
| 22 | 
            -
              		puts " | 
| 23 | 
            -
              		puts " | 
| 24 | 
            -
              		puts " | 
| 25 | 
            -
              		puts " | 
| 31 | 
            +
              		puts "\tSetup"
         | 
| 32 | 
            +
              		puts "\t\t1. Teachers create the student repositories (https://github.com/education/teachers_pet works perfectly well for this)"
         | 
| 33 | 
            +
              		puts "\t\t\t--> make sure the repos are all private, but that you have access to them!"
         | 
| 34 | 
            +
              		puts "\t\t\t--> initialize these repos with a README or push out a starter file."
         | 
| 35 | 
            +
              		puts "\t\t\t--> create a file with a list of the students github usernames (one on each line)" 
         | 
| 36 | 
            +
              		puts "\t\t\t\t--- you will need this during the setup process"
         | 
| 37 | 
            +
              		puts "\t\t2. Teachers create a repo for themselves. This will serve as the base for the tbgit environment."
         | 
| 38 | 
            +
              		puts "\t\t3. Change to that repo's directory, execute `tbgit setup`, and follow the instructions."
         | 
| 26 39 | 
             
              		puts ""
         | 
| 27 | 
            -
              		puts " | 
| 28 | 
            -
              		puts " | 
| 29 | 
            -
              		puts " | 
| 30 | 
            -
              		puts " | 
| 31 | 
            -
              		puts " | 
| 32 | 
            -
              		puts " | 
| 33 | 
            -
              		puts " | 
| 34 | 
            -
              		puts " | 
| 40 | 
            +
              		puts "\tA Typical Workflow"
         | 
| 41 | 
            +
              		puts "\t\t1. Teachers create the assignment (on the master branch) and make a final commit when they're ready to deploy it"
         | 
| 42 | 
            +
              		puts "\t\t2. Teachers pull all the students' repos to make sure they're up to date."
         | 
| 43 | 
            +
              		puts "\t\t\t--> `tbgit pull`"
         | 
| 44 | 
            +
              		puts "\t\t3. Teachers merge their master branch with each student's local branch"
         | 
| 45 | 
            +
              		puts "\t\t\t--> `tbgit merge`"
         | 
| 46 | 
            +
              		puts "\t\t4. At this point, teachers should check to make sure their were no merge conflicts. If there were, go in and fix them."
         | 
| 47 | 
            +
              		puts "\t\t\t--> feel free to `git checkout <username>` a few different branches"
         | 
| 48 | 
            +
              		puts "\t\t4. Teachers push each students local branch to the student's remote master branch"
         | 
| 49 | 
            +
              		puts "\t\t\t--> `tbgit push`"
         | 
| 50 | 
            +
              		puts "\t\t5. Make sure it worked.  Do a victory lap."
         | 
| 35 51 | 
             
              		puts ""
         | 
| 36 | 
            -
              		puts " | 
| 37 | 
            -
              		puts "		1. Teachers create the assignment (on the master branch) and make a final commit when they're ready to deploy it"
         | 
| 38 | 
            -
              		puts "		2. Teachers pull all the students' repos to make sure they're up to date."
         | 
| 39 | 
            -
              		puts "				--> `tbgit pull`"
         | 
| 40 | 
            -
              		puts "		3. Teachers merge their master branch with each student's local branch"
         | 
| 41 | 
            -
              		puts "				--> `tbgit merge`"
         | 
| 42 | 
            -
              		puts "		4. At this point, teachers should check to make sure their were no merge conflicts. If there were, go in and fix them."
         | 
| 43 | 
            -
              		puts "				--> feel free to `git checkout <username>` a few different branches"
         | 
| 44 | 
            -
              		puts "		4. Teachers push each students local branch to the student's remote master branch"
         | 
| 45 | 
            -
              		puts "				--> `tbgit push`"
         | 
| 46 | 
            -
              		puts "		5. Make sure it worked.  Do a victory lap."
         | 
| 47 | 
            -
              		puts ""
         | 
| 48 | 
            -
              		puts "		To view student solutions at any point, just `tbgit pull` and `git checkout <username>`"
         | 
| 52 | 
            +
              		puts "\t\tTo view student solutions at any point, just `tbgit pull` and `git checkout <username>`"
         | 
| 49 53 | 
             
              		puts ""
         | 
| 50 54 | 
             
              	end
         | 
| 51 55 | 
             
            end
         | 
    
        data/lib/tbgit/version.rb
    CHANGED
    
    
    
        data/lib/tbgit.rb
    CHANGED
    
    | @@ -1,281 +1,409 @@ | |
| 1 1 | 
             
            require "tbgit/version"
         | 
| 2 2 | 
             
            require "tempfile"
         | 
| 3 | 
            -
            require "score_parser"
         | 
| 4 3 | 
             
            require "add_webhooks"
         | 
| 5 4 | 
             
            require 'highline/import'
         | 
| 5 | 
            +
            require "optparse"
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 7 | 
            +
            class TBGit
         | 
| 8 8 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
              		puts "********************************************************************************"
         | 
| 13 | 
            -
              	end
         | 
| 9 | 
            +
            	def spacer
         | 
| 10 | 
            +
            		puts "********************************************************************************"
         | 
| 11 | 
            +
            	end
         | 
| 14 12 |  | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 13 | 
            +
            	#confirms a given message
         | 
| 14 | 
            +
            	def confirm(flag,message)
         | 
| 15 | 
            +
            		if !flag
         | 
| 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
         | 
| 24 | 
            +
            	end
         | 
| 27 25 |  | 
| 28 | 
            -
             | 
| 26 | 
            +
            	#three simple git methods
         | 
| 29 27 | 
             
            	def switch_to_master
         | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 28 | 
            +
            	puts "git checkout master"
         | 
| 29 | 
            +
            	system "git checkout master"
         | 
| 32 30 | 
             
            	end
         | 
| 33 31 | 
             
            	def git_remote
         | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 32 | 
            +
            	puts "git remote"
         | 
| 33 | 
            +
            	system "git remote"
         | 
| 36 34 | 
             
            	end
         | 
| 37 35 | 
             
            	def git_branch
         | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 36 | 
            +
            	puts "git branch"
         | 
| 37 | 
            +
            	system "git branch"
         | 
| 40 38 | 
             
            	end
         | 
| 41 39 |  | 
| 42 40 | 
             
            	#gather necessary information
         | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
            	     | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
            	     | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
            		 | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
            			 | 
| 90 | 
            -
             | 
| 41 | 
            +
            	def gather(command, args)
         | 
| 42 | 
            +
            	options = {}
         | 
| 43 | 
            +
            	opt_parser = OptionParser.new do |opts|
         | 
| 44 | 
            +
            		if command == "setup"
         | 
| 45 | 
            +
            	  		opts.banner = "Usage: tbgit setup [options]"
         | 
| 46 | 
            +
            	  	elsif command == "add-remotes"
         | 
| 47 | 
            +
            	  		opts.banner = "Usage: tbgit add-remotes [options]"
         | 
| 48 | 
            +
            	  	else
         | 
| 49 | 
            +
            	  		opts.banner = "Usage: tbgit create-locals [options]"
         | 
| 50 | 
            +
            	  	end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
             | 
| 53 | 
            +
            	  opts.on("-s", "--studentfile FILEPATH","Specify the file containing the list of students.") do |f|
         | 
| 54 | 
            +
            	    options[:studentfile] = f
         | 
| 55 | 
            +
            	  end
         | 
| 56 | 
            +
            	  
         | 
| 57 | 
            +
            	  opts.on("-o", "--organization NAME","Specify the name of the GitHub organization.") do |o|
         | 
| 58 | 
            +
            	    options[:organization] = o
         | 
| 59 | 
            +
            	  end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            	  opts.on("-r", "--repo NAME","Specify the name of the student repositories.") do |r|
         | 
| 62 | 
            +
            	    options[:repo] = r
         | 
| 63 | 
            +
            	  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            	  opts.on_tail("-h", "--help", "Show this message") do
         | 
| 66 | 
            +
            	    puts opts
         | 
| 67 | 
            +
            	    exit
         | 
| 68 | 
            +
            	  end
         | 
| 69 | 
            +
            	end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            	opt_parser.parse!(args)
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            	if options[:studentfile] == nil
         | 
| 74 | 
            +
            		puts 'Students file |../students|:'
         | 
| 75 | 
            +
            		@students_file = $stdin.gets.chomp
         | 
| 76 | 
            +
            		if @students_file == ""
         | 
| 77 | 
            +
            			@students_file = "../students"
         | 
| 78 | 
            +
            		end
         | 
| 79 | 
            +
            	else
         | 
| 80 | 
            +
            		@students_file = options[:studentfile]
         | 
| 81 | 
            +
            	end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            	if options[:organization] == nil
         | 
| 84 | 
            +
            		puts 'Organization name |yale-stc-developer-curriculum|:'
         | 
| 85 | 
            +
            		@organization = $stdin.gets.chomp
         | 
| 86 | 
            +
            		if @organization == ""
         | 
| 87 | 
            +
            			@organization = "yale-stc-developer-curriculum"
         | 
| 88 | 
            +
            		end
         | 
| 89 | 
            +
            	else
         | 
| 90 | 
            +
            		@organization = options[:organization]
         | 
| 91 | 
            +
            	end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            	if options[:repo] == nil
         | 
| 94 | 
            +
            		puts 'Student Repo Name |TechBootcampHomework|:'
         | 
| 95 | 
            +
            		@reponame = $stdin.gets.chomp
         | 
| 96 | 
            +
            		if @reponame == ""
         | 
| 97 | 
            +
            			@reponame = "TechBootcampHomework"
         | 
| 91 98 | 
             
            		end
         | 
| 99 | 
            +
            	else
         | 
| 100 | 
            +
            		@reponame = options[:repo]
         | 
| 101 | 
            +
            	end
         | 
| 102 | 
            +
            	end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            	#update remotes
         | 
| 105 | 
            +
            	def git_update
         | 
| 106 | 
            +
            	puts "git remote update"
         | 
| 107 | 
            +
            		system "git remote update"
         | 
| 108 | 
            +
            	end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            	#add each student repository as a remote
         | 
| 111 | 
            +
            	def add_remotes
         | 
| 112 | 
            +
            	students = IO.readlines(@students_file)
         | 
| 113 | 
            +
            	students.each do |username|
         | 
| 114 | 
            +
            		username.delete!("\n")
         | 
| 115 | 
            +
            		
         | 
| 116 | 
            +
            		puts "Adding Remote: " + username 
         | 
| 117 | 
            +
            		remote_command = "git remote add " + username + " https://github.com/"+@organization+"/" + username + "-"+@reponame+".git" 
         | 
| 118 | 
            +
            		puts remote_command
         | 
| 119 | 
            +
            		system 	remote_command
         | 
| 120 | 
            +
            	end
         | 
| 92 121 | 
             
            	end
         | 
| 93 122 |  | 
| 94 123 | 
             
            	#create local branches to track remote student repositories
         | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 124 | 
            +
            	def create_local_tracking_remotes
         | 
| 125 | 
            +
            	    students = IO.readlines(@students_file)
         | 
| 126 | 
            +
            		students.each do |username|
         | 
| 127 | 
            +
            		username.delete!("\n")
         | 
| 99 128 |  | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 129 | 
            +
            		puts "Creating Local Branch to Track Remote: " + username 
         | 
| 130 | 
            +
            		checkout_command = "git checkout --track -b " + username + " remotes/" + username + "/master"
         | 
| 131 | 
            +
            		puts checkout_command
         | 
| 132 | 
            +
            		system  checkout_command
         | 
| 104 133 |  | 
| 105 | 
            -
             | 
| 134 | 
            +
            	end
         | 
| 106 135 |  | 
| 107 136 | 
             
            	end
         | 
| 108 137 |  | 
| 109 138 | 
             
            	#returns a list of students
         | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 139 | 
            +
            	def all_remotes_list
         | 
| 140 | 
            +
            		remote_file = Tempfile.new("remotes")
         | 
| 141 | 
            +
            		system "git remote >> " + remote_file.path
         | 
| 113 142 |  | 
| 114 | 
            -
             | 
| 143 | 
            +
            		puts "git remote >> " + remote_file.path
         | 
| 115 144 |  | 
| 116 | 
            -
             | 
| 145 | 
            +
            		return IO.readlines(remote_file)
         | 
| 117 146 | 
             
            	end
         | 
| 118 147 |  | 
| 119 148 | 
             
            	#used for push / pull
         | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 149 | 
            +
            	def update_repos(pushpull,args)
         | 
| 150 | 
            +
             | 
| 151 | 
            +
            		options = {}
         | 
| 152 | 
            +
            	opt_parser = OptionParser.new do |opts|
         | 
| 153 | 
            +
            		if pushpull == "push"
         | 
| 154 | 
            +
            	  		opts.banner = "Usage: tbgit push [options]"
         | 
| 155 | 
            +
            	  	else
         | 
| 156 | 
            +
            	  		opts.banner = "Usage: tbgit pull [options]"
         | 
| 157 | 
            +
            	  	end
         | 
| 158 | 
            +
             | 
| 159 | 
            +
            	  opts.on("-y", "--yes","Proceed without asking for confirmation") do |y|
         | 
| 160 | 
            +
            	    options[:yes] = y
         | 
| 161 | 
            +
            	  end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            	  opts.on_tail("-h", "--help", "Show this message") do
         | 
| 164 | 
            +
            	    puts opts
         | 
| 165 | 
            +
            	    exit
         | 
| 166 | 
            +
            	  end
         | 
| 167 | 
            +
             | 
| 168 | 
            +
            	end
         | 
| 169 | 
            +
             | 
| 170 | 
            +
            	opt_parser.parse!(args)
         | 
| 171 | 
            +
             | 
| 172 | 
            +
             | 
| 173 | 
            +
            		if pushpull == "push"
         | 
| 174 | 
            +
            			confirm(options[:yes],"Each local student branch will be pushed to their remote master branch. Continue?")
         | 
| 123 175 | 
             
            			on_each_exec(["git push <branch> <branch>:master"])
         | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 176 | 
            +
            		else
         | 
| 177 | 
            +
            			confirm(options[:yes],"Each remote student master branch will be pulled to the local branch. Continue?")
         | 
| 126 178 | 
             
            			on_each_exec(["git pull <branch> master"])
         | 
| 179 | 
            +
            	end
         | 
| 180 | 
            +
            	end
         | 
| 181 | 
            +
             | 
| 182 | 
            +
            	def push_origin(args) #push all student branches to our origin
         | 
| 183 | 
            +
             | 
| 184 | 
            +
            		options = {}
         | 
| 185 | 
            +
            	opt_parser = OptionParser.new do |opts|
         | 
| 186 | 
            +
            	  	opts.banner = "Usage: tbgit push-origin [options]"
         | 
| 187 | 
            +
             | 
| 188 | 
            +
            	  opts.on("-y", "--yes","Proceed without asking for confirmation") do |y|
         | 
| 189 | 
            +
            	    options[:yes] = y
         | 
| 190 | 
            +
            	  end
         | 
| 191 | 
            +
             | 
| 192 | 
            +
            	  opts.on_tail("-h", "--help", "Show this message") do
         | 
| 193 | 
            +
            	    puts opts
         | 
| 194 | 
            +
            	    exit
         | 
| 195 | 
            +
            	  end
         | 
| 196 | 
            +
            	end
         | 
| 197 | 
            +
            	opt_parser.parse!(args)
         | 
| 198 | 
            +
             | 
| 199 | 
            +
            		confirm(options[:yes],"Each local student branch will be pushed to the the origin remote. Continue?")
         | 
| 200 | 
            +
            		on_each_exec(["git push origin <branch>"])
         | 
| 201 | 
            +
            	end
         | 
| 202 | 
            +
             | 
| 203 | 
            +
            	#merges from master (or another branch) to each student branch and commits the changes
         | 
| 204 | 
            +
            	def merge_and_commit(args)
         | 
| 205 | 
            +
             | 
| 206 | 
            +
            	options = {}
         | 
| 207 | 
            +
            	opt_parser = OptionParser.new do |opts|
         | 
| 208 | 
            +
            	  	opts.banner = "Usage: tbgit push-origin [options]"
         | 
| 209 | 
            +
             | 
| 210 | 
            +
            	  opts.on("-y", "--yes","Proceed without asking for confirmation") do |y|
         | 
| 211 | 
            +
            	    options[:yes] = y
         | 
| 212 | 
            +
            	  end
         | 
| 213 | 
            +
             | 
| 214 | 
            +
            	  opts.on("-b", "--branch BRANCH", "Specify the branch to merge from") do |b|
         | 
| 215 | 
            +
            	  	options[:branch] = b
         | 
| 216 | 
            +
            	  end
         | 
| 217 | 
            +
             | 
| 218 | 
            +
            	  opts.on("-m", "--message MESSAGE", "Specify the commit message for the merge.") do |m|
         | 
| 219 | 
            +
            	  	options[:message] = m 
         | 
| 220 | 
            +
            	  end
         | 
| 221 | 
            +
             | 
| 222 | 
            +
            	  opts.on_tail("-h", "--help", "Show this message") do
         | 
| 223 | 
            +
            	    puts opts
         | 
| 224 | 
            +
            	    exit
         | 
| 225 | 
            +
            	  end
         | 
| 226 | 
            +
            	end
         | 
| 227 | 
            +
            	opt_parser.parse!(args)
         | 
| 228 | 
            +
            		
         | 
| 229 | 
            +
            		if options[:branch] == nil
         | 
| 230 | 
            +
            			puts "Merge from branch: "
         | 
| 231 | 
            +
            			merge_branch = $stdin.gets.chomp
         | 
| 232 | 
            +
            		else
         | 
| 233 | 
            +
            			merge_branch = options[:branch]
         | 
| 127 234 | 
             
            		end
         | 
| 128 | 
            -
              	end
         | 
| 129 235 |  | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 236 | 
            +
            		if options[:message] == nil
         | 
| 237 | 
            +
            			puts "Commit Message: "
         | 
| 238 | 
            +
            			message = $stdin.gets.chomp
         | 
| 239 | 
            +
            		else
         | 
| 240 | 
            +
            			message = options[:message]
         | 
| 241 | 
            +
            		end
         | 
| 134 242 |  | 
| 135 | 
            -
             | 
| 136 | 
            -
              	def merge_and_commit(flag,merge_branch,message)
         | 
| 243 | 
            +
            		confirm(options[:yes],"A merge and commit will be performed on each local student branch (from the branch you specify). Continue?")
         | 
| 137 244 |  | 
| 138 | 
            -
             | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
            	  		merge_branch = $stdin.gets.chomp
         | 
| 143 | 
            -
            	  	end
         | 
| 245 | 
            +
            	commands = ["git merge --no-commit " + merge_branch.to_s,
         | 
| 246 | 
            +
            			  		"git add --all",
         | 
| 247 | 
            +
            					"git commit -am '" + message + "'"]
         | 
| 248 | 
            +
            		on_each_exec(commands)
         | 
| 144 249 |  | 
| 145 | 
            -
             | 
| 146 | 
            -
            	  		puts "Commit Message: "
         | 
| 147 | 
            -
            	  		message = $stdin.gets.chomp
         | 
| 148 | 
            -
            	  	end
         | 
| 250 | 
            +
            	end
         | 
| 149 251 |  | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
            	  				"git commit -am '" + message + "'"]
         | 
| 153 | 
            -
            	  	on_each_exec(commands)
         | 
| 154 | 
            -
             | 
| 155 | 
            -
              	end
         | 
| 156 | 
            -
             | 
| 157 | 
            -
              	#gathers the commands to be executed, and then calls on_each_exec(input)
         | 
| 158 | 
            -
              	def on_each_gather
         | 
| 159 | 
            -
              		puts "Enter the commands you would like to have executed on each branch, one on each line."
         | 
| 160 | 
            -
              		puts "'<branch>' will be replaced by the current checked-out branch. Enter a blank line to finish."
         | 
| 161 | 
            -
              		done = false
         | 
| 162 | 
            -
              		input = Array.new
         | 
| 163 | 
            -
              		while !done
         | 
| 164 | 
            -
              			text = $stdin.gets.chomp
         | 
| 165 | 
            -
              			if text == ""
         | 
| 166 | 
            -
              				done = true
         | 
| 167 | 
            -
              			else
         | 
| 168 | 
            -
              				input << text
         | 
| 169 | 
            -
              			end
         | 
| 170 | 
            -
              		end
         | 
| 171 | 
            -
             | 
| 172 | 
            -
              		on_each_exec(input)
         | 
| 173 | 
            -
             | 
| 174 | 
            -
              	end
         | 
| 175 | 
            -
             | 
| 176 | 
            -
              	#takes an array of commands, and executes a ruby command on each student branch
         | 
| 177 | 
            -
              	def on_each_ruby(input)   
         | 
| 178 | 
            -
              		all_remotes = all_remotes_list
         | 
| 179 | 
            -
              		all_remotes.each do |branch|
         | 
| 180 | 
            -
              			branch.delete!("\n")
         | 
| 181 | 
            -
             | 
| 182 | 
            -
              			if branch != "origin"
         | 
| 183 | 
            -
            		  		checkout_command = "git checkout " + branch 
         | 
| 184 | 
            -
             | 
| 185 | 
            -
            		  		puts checkout_command
         | 
| 186 | 
            -
            		  		system checkout_command
         | 
| 187 | 
            -
             | 
| 188 | 
            -
            	  			input.each do |command|
         | 
| 189 | 
            -
            	  				final_command = command.gsub("<branch>", branch)
         | 
| 190 | 
            -
             | 
| 191 | 
            -
            	  				puts final_command
         | 
| 192 | 
            -
            	  				eval(final_command)
         | 
| 193 | 
            -
            	  			end
         | 
| 194 | 
            -
              			end
         | 
| 195 | 
            -
             | 
| 196 | 
            -
              		end
         | 
| 197 | 
            -
              		switch_to_master
         | 
| 198 | 
            -
              	end
         | 
| 199 | 
            -
             | 
| 200 | 
            -
              	#takes an array of commands, and executes a system command on each student branch
         | 
| 201 | 
            -
              	def on_each_exec(input)
         | 
| 202 | 
            -
              		input.map! { |a| "system '" + a.gsub("'"){"\\'"} + "'"}
         | 
| 203 | 
            -
              		on_each_ruby(input)
         | 
| 204 | 
            -
              	end
         | 
| 205 | 
            -
             | 
| 206 | 
            -
              	def git_status
         | 
| 207 | 
            -
              		on_each_exec(["git status <branch>"])
         | 
| 208 | 
            -
              	end
         | 
| 209 | 
            -
              	
         | 
| 210 | 
            -
              	def spec(flag,specfile,studentcopy,mastercopy,commit_message)
         | 
| 211 | 
            -
             | 
| 212 | 
            -
              		if 	specfile==nil
         | 
| 213 | 
            -
            	  		puts "Please specify the relative path from your pwd to the rspec file you would like to spec, eg. 'hw1/spec/spec.rb'"
         | 
| 214 | 
            -
            	  		specfile = $stdin.gets.chomp
         | 
| 215 | 
            -
            	  	end
         | 
| 252 | 
            +
            	#gathers the commands to be executed, and then calls on_each_exec(input)
         | 
| 253 | 
            +
            	def on_each_gather(args)
         | 
| 216 254 |  | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
            	  		puts "**Must be inside the student's repo directory, eg. 'hw1/spec/results.txt'**"
         | 
| 220 | 
            -
            	  		studentcopy = $stdin.gets.chomp
         | 
| 221 | 
            -
            	  	end
         | 
| 255 | 
            +
            		options = {}
         | 
| 256 | 
            +
            		opt_parser = OptionParser.new do |opts|
         | 
| 222 257 |  | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
            	  		mastercopy = $stdin.gets.chomp
         | 
| 227 | 
            -
            	  	end
         | 
| 258 | 
            +
            		  opts.on("-f", "--file FILENAME", "Execute the commands specified in a certain file. One command per line. '<branch>' will be replaced by the name of the current student branch checked out.") do |f|
         | 
| 259 | 
            +
            		  	options[:file] = f
         | 
| 260 | 
            +
            		  end
         | 
| 228 261 |  | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 262 | 
            +
            		  opts.on("-y", "--yes","Proceed without asking for confirmation") do |y|
         | 
| 263 | 
            +
            		    options[:yes] = y
         | 
| 264 | 
            +
            		  end
         | 
| 231 265 |  | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 266 | 
            +
            		  opts.on_tail("-h", "--help", "Show this message") do
         | 
| 267 | 
            +
            		    puts opts
         | 
| 268 | 
            +
            		    exit
         | 
| 269 | 
            +
            		  end
         | 
| 270 | 
            +
             | 
| 271 | 
            +
            		end
         | 
| 272 | 
            +
             | 
| 273 | 
            +
            		opt_parser.parse!(args)
         | 
| 274 | 
            +
             | 
| 275 | 
            +
            		if options[:file] == nil
         | 
| 276 | 
            +
            			puts "Enter the commands you would like to have executed on each branch, one on each line."
         | 
| 277 | 
            +
            			puts "'<branch>' will be replaced by the current checked-out branch. Enter a blank line to finish."
         | 
| 278 | 
            +
            			done = false
         | 
| 279 | 
            +
            			input = Array.new
         | 
| 280 | 
            +
            			while !done
         | 
| 281 | 
            +
            				text = $stdin.gets.chomp
         | 
| 282 | 
            +
            				if text == ""
         | 
| 283 | 
            +
            					done = true
         | 
| 284 | 
            +
            				else
         | 
| 285 | 
            +
            					input << text
         | 
| 286 | 
            +
            				end
         | 
| 287 | 
            +
            			end
         | 
| 288 | 
            +
            		else
         | 
| 289 | 
            +
            			input = IO.readlines(options[:file])
         | 
| 290 | 
            +
            		end
         | 
| 236 291 |  | 
| 237 | 
            -
             | 
| 238 | 
            -
              			Individual results will be saved to " + studentcopy + " and master results to " + mastercopy + ". Continue?")
         | 
| 292 | 
            +
            		confirm(options[:yes], "The commands specified will be executed on each student branch. Continue?")
         | 
| 239 293 |  | 
| 240 | 
            -
             | 
| 241 | 
            -
              			"rspec --format json --out " + mastercopy + "/<branch> " + specfile,
         | 
| 242 | 
            -
              		 	"git add --all",
         | 
| 243 | 
            -
              		 	"git commit -am '" + commit_message + "'",
         | 
| 244 | 
            -
              		 	"git push <branch> <branch>:master"])
         | 
| 294 | 
            +
            		on_each_exec(input)
         | 
| 245 295 |  | 
| 246 | 
            -
             | 
| 247 | 
            -
             | 
| 296 | 
            +
            	end
         | 
| 297 | 
            +
             | 
| 298 | 
            +
            	#takes an array of commands, and executes a ruby command on each student branch
         | 
| 299 | 
            +
            	def on_each_ruby(input)   
         | 
| 300 | 
            +
            		all_remotes = all_remotes_list
         | 
| 301 | 
            +
            		all_remotes.each do |branch|
         | 
| 302 | 
            +
            			branch.delete!("\n")
         | 
| 248 303 |  | 
| 249 | 
            -
             | 
| 304 | 
            +
            			if branch != "origin"
         | 
| 305 | 
            +
            	  		checkout_command = "git checkout " + branch 
         | 
| 250 306 |  | 
| 251 | 
            -
             | 
| 252 | 
            -
             | 
| 253 | 
            -
              			puts "Organization Name:"
         | 
| 254 | 
            -
              			organization = $stdin.gets.chomp
         | 
| 255 | 
            -
              		end
         | 
| 307 | 
            +
            	  		puts checkout_command
         | 
| 308 | 
            +
            	  		system checkout_command
         | 
| 256 309 |  | 
| 257 | 
            -
             | 
| 258 | 
            -
             | 
| 259 | 
            -
              			reponame = $stdin.gets.chomp
         | 
| 260 | 
            -
              		end
         | 
| 310 | 
            +
            				input.each do |command|
         | 
| 311 | 
            +
            					final_command = command.gsub("<branch>", branch)
         | 
| 261 312 |  | 
| 262 | 
            -
             | 
| 263 | 
            -
             | 
| 264 | 
            -
             | 
| 265 | 
            -
             | 
| 313 | 
            +
            					puts final_command
         | 
| 314 | 
            +
            					eval(final_command)
         | 
| 315 | 
            +
            				end
         | 
| 316 | 
            +
            			end
         | 
| 266 317 |  | 
| 267 | 
            -
             | 
| 268 | 
            -
             | 
| 269 | 
            -
             | 
| 318 | 
            +
            		end
         | 
| 319 | 
            +
            		switch_to_master
         | 
| 320 | 
            +
            	end
         | 
| 270 321 |  | 
| 271 | 
            -
             | 
| 272 | 
            -
             | 
| 273 | 
            -
             | 
| 274 | 
            -
             | 
| 322 | 
            +
            	#takes an array of commands, and executes a system command on each student branch
         | 
| 323 | 
            +
            	def on_each_exec(input)
         | 
| 324 | 
            +
            		input.map! { |a| "system '" + a.gsub("'"){"\\'"} + "'"}
         | 
| 325 | 
            +
            		on_each_ruby(input)
         | 
| 326 | 
            +
            	end
         | 
| 275 327 |  | 
| 276 | 
            -
             | 
| 277 | 
            -
             | 
| 328 | 
            +
            	def git_status
         | 
| 329 | 
            +
            		on_each_exec(["git status <branch>"])
         | 
| 330 | 
            +
            	end
         | 
| 278 331 |  | 
| 279 | 
            -
             | 
| 280 | 
            -
             | 
| 281 | 
            -
             | 
| 332 | 
            +
            	def add_webhooks(args)
         | 
| 333 | 
            +
             | 
| 334 | 
            +
            		options = {}
         | 
| 335 | 
            +
            		opt_parser = OptionParser.new do |opts|
         | 
| 336 | 
            +
            		  	opts.banner = "Usage: tbgit add-webhooks [options]"
         | 
| 337 | 
            +
             | 
| 338 | 
            +
            		  opts.on("-y", "--yes","Proceed without asking for confirmation") do |y|
         | 
| 339 | 
            +
            		    options[:yes] = y
         | 
| 340 | 
            +
            		  end
         | 
| 341 | 
            +
             | 
| 342 | 
            +
            		  opts.on("-o", "--organization NAME","Specify the name of the GitHub organization.") do |o|
         | 
| 343 | 
            +
            		    options[:organization] = o
         | 
| 344 | 
            +
            		  end
         | 
| 345 | 
            +
             | 
| 346 | 
            +
            		  opts.on("-r", "--repo NAME","Specify the name of the student repositories.") do |r|
         | 
| 347 | 
            +
            		    options[:reponame] = r
         | 
| 348 | 
            +
            		  end
         | 
| 349 | 
            +
             | 
| 350 | 
            +
            		  opts.on("-u", "--user USERNAME", "Your GitHub username.") do |u|
         | 
| 351 | 
            +
            		  	options[:username] = u
         | 
| 352 | 
            +
            		  end
         | 
| 353 | 
            +
             | 
| 354 | 
            +
            		  opts.on("-p", "--pass PASSWORD", "Your GitHub password.") do |p|
         | 
| 355 | 
            +
            		  	options[:password] = p
         | 
| 356 | 
            +
            		  end
         | 
| 357 | 
            +
             | 
| 358 | 
            +
            		  opts.on("-l", "--url URL", "Webhook URL") do |l|
         | 
| 359 | 
            +
            		  	options[:url] = l
         | 
| 360 | 
            +
            		  end
         | 
| 361 | 
            +
             | 
| 362 | 
            +
            		  opts.on_tail("-h", "--help", "Show this message") do
         | 
| 363 | 
            +
            		    puts opts
         | 
| 364 | 
            +
            		    exit
         | 
| 365 | 
            +
            		  end
         | 
| 366 | 
            +
            		end
         | 
| 367 | 
            +
            		opt_parser.parse!(args)
         | 
| 368 | 
            +
             | 
| 369 | 
            +
            		if options[:organization] == nil
         | 
| 370 | 
            +
            			puts "Organization Name:"
         | 
| 371 | 
            +
            			organization = $stdin.gets.chomp
         | 
| 372 | 
            +
            		else
         | 
| 373 | 
            +
            			organization = options[:organization]
         | 
| 374 | 
            +
            		end
         | 
| 375 | 
            +
             | 
| 376 | 
            +
            		if options[:reponame] == nil
         | 
| 377 | 
            +
            			puts "Student Repository Name:"
         | 
| 378 | 
            +
            			reponame = $stdin.gets.chomp
         | 
| 379 | 
            +
            		else
         | 
| 380 | 
            +
            			reponame = options[:reponame]
         | 
| 381 | 
            +
            		end
         | 
| 382 | 
            +
             | 
| 383 | 
            +
            		if options[:username] == nil
         | 
| 384 | 
            +
            			print "Username:"
         | 
| 385 | 
            +
            			user = $stdin.gets.chomp
         | 
| 386 | 
            +
            		else 
         | 
| 387 | 
            +
            			user = options[:username]
         | 
| 388 | 
            +
            		end
         | 
| 389 | 
            +
             | 
| 390 | 
            +
            		if options[:password] == nil
         | 
| 391 | 
            +
            			pass = ask("Password: ") { |q| q.echo = false }
         | 
| 392 | 
            +
            		else 
         | 
| 393 | 
            +
            			pass = options[:password]
         | 
| 394 | 
            +
            		end
         | 
| 395 | 
            +
             | 
| 396 | 
            +
            		if options[:url] == nil
         | 
| 397 | 
            +
            			puts "Webhook url:"
         | 
| 398 | 
            +
            			url = $stdin.gets.chomp
         | 
| 399 | 
            +
            		else
         | 
| 400 | 
            +
            			url = options[:url]
         | 
| 401 | 
            +
            		end
         | 
| 402 | 
            +
             | 
| 403 | 
            +
            		confirm(options[:yes],"Webhooks will be added to each student's GitHub repository. Continue?")
         | 
| 404 | 
            +
             | 
| 405 | 
            +
            		on_each_ruby(['create = CreateWebhooks.new; create.post(\''+ organization.to_s + '\',\'<branch>\',\''+reponame.to_s+'\',
         | 
| 406 | 
            +
            				\''+user.to_s+'\',\''+pass.to_s+'\',\''+url.to_s+'\')'])
         | 
| 407 | 
            +
             | 
| 408 | 
            +
            	end
         | 
| 409 | 
            +
            end #class
         | 
    
        data/lib/tbspec.rb
    ADDED
    
    | @@ -0,0 +1,130 @@ | |
| 1 | 
            +
            require "score_parser"
         | 
| 2 | 
            +
            require "tbgit"
         | 
| 3 | 
            +
            require "optparse"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class TBSpec
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            	def spec(args)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            	options = {}
         | 
| 10 | 
            +
            	opt_parser = OptionParser.new do |opts|
         | 
| 11 | 
            +
              	opts.banner = "Usage: tbgit spec [options]"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            	  opts.on("-y", "--yes","Proceed without asking for confirmation") do |y|
         | 
| 14 | 
            +
            	    options[:yes] = y
         | 
| 15 | 
            +
            	  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            	  opts.on("-f", "--specfile FILE", "Specify the relative path from your pwd to the rspec file you would like to spec, eg. 'hw1/spec/spec.rb'") do |f|
         | 
| 18 | 
            +
            	  	options[:specfile] = f
         | 
| 19 | 
            +
            	  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            	  opts.on("-s", "--studentcopy FILE", "Specify where you would like to save each student's individual results. Must be inside the student's repo directory, eg. 'hw1/spec/results.txt'") do |s|
         | 
| 22 | 
            +
            	  	options[:studentcopy] = s 
         | 
| 23 | 
            +
            	  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            	  opts.on("-t", "--teachercopy FILE", "Specify where you would like to save a copy of all results. Must be outside the student's repo directory, eg. '../results'") do |t|
         | 
| 26 | 
            +
            	  	options[:mastercopy] = t
         | 
| 27 | 
            +
            	  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            	  opts.on("-m", "--message MESSAGE", "Specify the commit message (commiting each student's results to their repo)") do |m|
         | 
| 30 | 
            +
            	  	options[:message] = m 
         | 
| 31 | 
            +
            	  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            	  opts.on("-n", "--studentname NAME", "If you would like to spec an individual student, please specify their name. Otherwise, use the --all option to spec all students.") do |n|
         | 
| 34 | 
            +
            	  	options[:student] = n 
         | 
| 35 | 
            +
            	  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            	  opts.on("-a", "--all", "Use this option to spec all student homework.") do|a|
         | 
| 38 | 
            +
            	  	options[:all] = a
         | 
| 39 | 
            +
            	  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            	  opts.on_tail("-h", "--help", "Show this message") do
         | 
| 42 | 
            +
            	    puts opts
         | 
| 43 | 
            +
            	    exit
         | 
| 44 | 
            +
            	  end
         | 
| 45 | 
            +
            	end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            	opt_parser.parse!(args)
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            		if 	options[:specfile]==nil
         | 
| 50 | 
            +
            			puts "Please specify the relative path from your pwd to the rspec file you would like to spec, eg. 'hw1/spec/spec.rb'"
         | 
| 51 | 
            +
            			specfile = $stdin.gets.chomp
         | 
| 52 | 
            +
            		else
         | 
| 53 | 
            +
            			specfile = options[:specfile]
         | 
| 54 | 
            +
            		end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            		if options[:studentcopy]==nil
         | 
| 57 | 
            +
            			puts "Where would you like to save each student's individual results?"
         | 
| 58 | 
            +
            			puts "**Must be inside the student's repo directory, eg. 'hw1/spec/results.txt'**"
         | 
| 59 | 
            +
            			studentcopy = $stdin.gets.chomp
         | 
| 60 | 
            +
            		else
         | 
| 61 | 
            +
            			studentcopy = options[:studentcopy]
         | 
| 62 | 
            +
            		end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            		if options[:mastercopy]==nil
         | 
| 65 | 
            +
            			puts "In which folder would you like to save a copy of all results?"
         | 
| 66 | 
            +
            			puts "**Must be outside the student's repo directory, eg. '../results'**"
         | 
| 67 | 
            +
            			mastercopy = $stdin.gets.chomp
         | 
| 68 | 
            +
            		else
         | 
| 69 | 
            +
            			mastercopy = options[:mastercopy]
         | 
| 70 | 
            +
            		end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            		puts "mkdir " + mastercopy
         | 
| 73 | 
            +
            		system "mkdir " + mastercopy
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            		if options[:message]==nil
         | 
| 76 | 
            +
            			puts "Commit message (commiting each student's results to their repo):"
         | 
| 77 | 
            +
            			commit_message = $stdin.gets.chomp
         | 
| 78 | 
            +
            		else
         | 
| 79 | 
            +
            			commit_message = options[:message]
         | 
| 80 | 
            +
            		end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            		all = false
         | 
| 83 | 
            +
            		student = ""
         | 
| 84 | 
            +
            		if options[:student]==nil && !options[:all]
         | 
| 85 | 
            +
            			puts "Please specify a student to spec. Type 'all' to spec all students"
         | 
| 86 | 
            +
            			student = $stdin.gets.chomp
         | 
| 87 | 
            +
            		elsif options[:student]!=nil && !options[:all]
         | 
| 88 | 
            +
            			student = options[:student]
         | 
| 89 | 
            +
            		elsif options[:student]!=nil && options[:all]
         | 
| 90 | 
            +
            			raise "--student and --all cannot be used at the same time!"
         | 
| 91 | 
            +
            		else
         | 
| 92 | 
            +
            			all = true
         | 
| 93 | 
            +
            		end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            		if student == "all"
         | 
| 96 | 
            +
            			all = true
         | 
| 97 | 
            +
            		end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            		tbgit = TBGit.new
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            		if  all
         | 
| 102 | 
            +
            			tbgit.confirm(options[:yes],"'rspec " + specfile + "' will be executed on each student's local branch. 
         | 
| 103 | 
            +
            				Individual results will be saved to " + studentcopy + " and master results to " + mastercopy + ". Continue?")
         | 
| 104 | 
            +
             | 
| 105 | 
            +
            			tbgit.on_each_exec(["rspec " +specfile + " > " + studentcopy,   	#overwrite
         | 
| 106 | 
            +
            				"rspec --format json --out " + mastercopy + "/<branch> " + specfile,
         | 
| 107 | 
            +
            			 	"git add --all",
         | 
| 108 | 
            +
            			 	"git commit -am '" + commit_message + "'",
         | 
| 109 | 
            +
            			 	"git push <branch> <branch>:master"])
         | 
| 110 | 
            +
            		else
         | 
| 111 | 
            +
            			system("git checkout " + student)
         | 
| 112 | 
            +
            			puts "rspec " + specfile + " > " + studentcopy
         | 
| 113 | 
            +
            			system("rspec " + specfile + " > " + studentcopy)
         | 
| 114 | 
            +
            			puts "rspec --format json --out " + mastercopy + "/"+student+" " + specfile
         | 
| 115 | 
            +
            			system("rspec --format json --out " + mastercopy + "/"+student+" " + specfile)
         | 
| 116 | 
            +
            			puts "git add --all"
         | 
| 117 | 
            +
            			system("git add --all")
         | 
| 118 | 
            +
            			puts "git commit -am '" + commit_message + "'"
         | 
| 119 | 
            +
            			system("git commit -am '" + commit_message + "'")
         | 
| 120 | 
            +
            			puts "git push "+student+" "+student+":master"
         | 
| 121 | 
            +
            			system("git push "+student+" "+student+":master")
         | 
| 122 | 
            +
            		tbgit.switch_to_master
         | 
| 123 | 
            +
             | 
| 124 | 
            +
            		end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
            	 	my_parser = Parser.new
         | 
| 127 | 
            +
            	 	my_parser.score_parse(mastercopy)
         | 
| 128 | 
            +
             | 
| 129 | 
            +
            	end #method
         | 
| 130 | 
            +
            end #class
         | 
    
        data/tbgit.gemspec
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: tbgit
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Charlie Proctor
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-05- | 
| 11 | 
            +
            date: 2014-05-25 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -80,6 +80,20 @@ dependencies: | |
| 80 80 | 
             
                - - ">="
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: '0'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: optparse
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - ">="
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: '0'
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - ">="
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: '0'
         | 
| 83 97 | 
             
            description: ''
         | 
| 84 98 | 
             
            email:
         | 
| 85 99 | 
             
            - charlie@charlieproctor.com
         | 
| @@ -97,10 +111,10 @@ files: | |
| 97 111 | 
             
            - lib/add_webhooks.rb
         | 
| 98 112 | 
             
            - lib/helptext.rb
         | 
| 99 113 | 
             
            - lib/score_parser.rb
         | 
| 100 | 
            -
            - lib/scoresheet.txt
         | 
| 101 114 | 
             
            - lib/tbgit.rb
         | 
| 102 115 | 
             
            - lib/tbgit/version.rb
         | 
| 103 116 | 
             
            - lib/tbgit/version.rb~
         | 
| 117 | 
            +
            - lib/tbspec.rb
         | 
| 104 118 | 
             
            - tbgit.gemspec
         | 
| 105 119 | 
             
            homepage: ''
         | 
| 106 120 | 
             
            licenses:
         | 
    
        data/lib/scoresheet.txt
    DELETED