Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Generating shell scripts
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