Created
October 2, 2010 21:07
-
-
Save marioaquino/607998 to your computer and use it in GitHub Desktop.
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
def js_command(command) | |
"-e 'do JavaScript \"#{command}\" in first document'" | |
end | |
def reload | |
js_command("window.location.reload();") | |
end | |
def scroll | |
js_command("window.scrollTo(0, document.body.scrollHeight);") | |
end | |
def safari_cmd(*cmds) | |
"osascript -e 'tell app \"Safari\"' #{cmds.join(' ')} -e 'end tell'" | |
end | |
def reload_and_scroll | |
safari_cmd reload, scroll | |
end | |
def scroll_to_bottom | |
safari_cmd scroll | |
end | |
def run_it(command = scroll_to_bottom) | |
system("ps -xc|grep -sq Safari && #{command}") | |
end | |
system("open /Applications/Safari.app KoansRunner.html") | |
run_it | |
watch( 'koans/.*\.js' ) { run_it(reload_and_scroll) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment