Skip to content

Instantly share code, notes, and snippets.

@audionerd
Created November 1, 2008 01:40
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 audionerd/21461 to your computer and use it in GitHub Desktop.
Save audionerd/21461 to your computer and use it in GitHub Desktop.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment