Created
November 1, 2008 01:40
-
-
Save audionerd/21461 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
# | |
# autoreload | |
# reload webkit whenever files in the current directory are modified | |
# | |
# requires: | |
# * RubyCocoa (bundled with Leopard) | |
# * gem install fsevents (http://github.com/ymendel/fsevents/tree/master) | |
# | |
require 'fsevents' | |
require 'osx/foundation' | |
OSX.require_framework 'ScriptingBridge' | |
def reload_webkit | |
# @browser = OSX::SBApplication.applicationWithBundleIdentifier_("org.apple.Safari") | |
@browser = OSX::SBApplication.applicationWithBundleIdentifier_("org.webkit.nightly.WebKit") | |
@browser.documents.first.URL = @browser.documents.first.URL | |
end | |
def watch_for_events | |
stream = FSEvents::Stream.watch('.') do |events| | |
puts "#{Time.now} MODIFIED", events.modified_files | |
reload_webkit | |
end | |
stream.run | |
end | |
watch_for_events |
This file contains 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment