module Pave class Reload def self.live_reload(browser="chrome") # docs: http://brettterpstra.com/2011/03/07/watch-for-file-changes-and-refresh-your-browser-automatically/ trap("SIGINT") { exit } puts "Watching #{watch_folder} and subfolders for changes in project files..." while true do files = [] filetypes.each {|type| files += Dir.glob( File.join( watch_folder, "**", "*.#{type}" ) ) } new_hash = files.collect {|f| [ f, File.stat(f).mtime.to_i ] } hash ||= new_hash diff_hash = new_hash - hash unless diff_hash.empty? hash = new_hash diff_hash.each do |df| print "Detected change in #{df[0]}, refreshing" if browser == "chrome" print " Chrome" %x{osascript<