Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@squarism
Created February 11, 2011 21:37
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 squarism/823086 to your computer and use it in GitHub Desktop.
Save squarism/823086 to your computer and use it in GitHub Desktop.
watchr script for running python 3 koans
# 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