Created
March 13, 2013 17:17
-
-
Save wbarksdale/5154223 to your computer and use it in GitHub Desktop.
An Automatic runner for learning with ruby Koans (http://rubykoans.com/) Whenever a file is modified, this will run the command "ruby path_to_enlightenment.rb"
This file contains hidden or 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 this to automatically re-run "ruby path_to_enlightenment.rb" on save | |
ruby_files = Dir.entries(".").select{ |filename| filename[/.rb/] } | |
mtimes = ruby_files.map { |filename| | |
File.stat(filename).mtime | |
} | |
ruby_files.each { |filename| puts filename } | |
files_and_mtimes = ruby_files.zip(mtimes) | |
puts "Waiting for files to change..." | |
while true | |
Kernel.sleep 1 | |
files_and_mtimes = files_and_mtimes.map{ |filename, last_modified| | |
if(File.stat(filename).mtime > last_modified) | |
puts "Dected modification to " + filename | |
Kernel.system("ruby path_to_enlightenment.rb") | |
last_modified = File.stat(filename).mtime | |
end | |
[filename, last_modified] | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this bro :)