Skip to content

Instantly share code, notes, and snippets.

@wbarksdale
Created March 13, 2013 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbarksdale/5154223 to your computer and use it in GitHub Desktop.
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"
#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
@bishisht
Copy link

bishisht commented May 8, 2020

Thanks for this bro :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment