Created
February 11, 2011 21:37
-
-
Save squarism/823086 to your computer and use it in GitHub Desktop.
watchr script for running python 3 koans
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
# watchr script for running python 3 koans: | |
# https://github.com/gregmalcolm/python_koans | |
# put this in <python_koans_home>/python_koans_watchr.rb | |
# cd python_3 | |
# watchr ../python_koans_watchr.rb | |
ENV["WATCHR"] = "1" | |
system 'clear' | |
def run(cmd) | |
puts(cmd) | |
`#{cmd}` | |
end | |
def run_koans | |
system('clear') | |
system('./run.sh') | |
end | |
watch('koans/.*\.py') { run_koans } | |
# Ctrl-\ | |
Signal.trap 'QUIT' do | |
puts " --- Running koans ---\n\n" | |
run_koans | |
end | |
@interrupted = false | |
# Ctrl-C | |
Signal.trap 'INT' do | |
if @interrupted then | |
@wants_to_quit = true | |
abort("\n") | |
else | |
puts "Interrupt a second time to quit" | |
@interrupted = true | |
Kernel.sleep 1.5 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment