Created
February 14, 2016 16:57
-
-
Save marcgg/b1a50180d1ff239ba555 to your computer and use it in GitHub Desktop.
Generating shell scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run_template = "rvm use 2.2.3 | |
cd FULL_PATH | |
echo FULL_PATH: STARTED | |
bundle install | |
echo FULL_PATH: DONE BUNDLING | |
rake db:drop RAILS_ENV=test | |
rake db:create RAILS_ENV=test | |
rake db:migrate RAILS_ENV=test | |
echo FULL_PATH: DONE WITH MIGRATIONS | |
bundle exec rspec spec/controllers/students_controller_spec.rb spec/models/exam_spec.rb spec/models/grade_spec.rb spec/models/student_spec.rb > ../rspec_results.log | |
echo FULL_PATH: ALL DONE" | |
count = 0 | |
puts "\n\nSETTING UP" | |
Dir.entries($path).each do |entry| | |
next if %w(.DS_Store .. .).include?(entry) | |
count += 1 | |
puts "#{count}\t> #{entry}" | |
student_path = $path + "/" + entry | |
runsh_path = student_path + "/run.sh" | |
puts "\tWritting #{runsh_path} ..." | |
begin | |
puts "\t\t> Removing old script..." | |
FileUtils.rm(runsh_path) | |
rescue Errno::ENOENT | |
end | |
File.open(runsh_path, 'w') do |file| | |
file.write(run_template.gsub("FULL_PATH", student_path.gsub(" ", "\\ ") + "/code")) | |
end | |
FileUtils.chown("marcgauthier", "staff", runsh_path) | |
FileUtils.chmod(0777, runsh_path) | |
puts "-" * 80 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment