Sha256: e0b7f05deb84efa607fcf1471cd7db3f8beaf678c57004a076df819551bebcc7
Contents?: true
Size: 913 Bytes
Versions: 4
Compression:
Stored size: 913 Bytes
Contents
#-- # Copied from Wee 0.8.0 # (c) 2004 Michael Neumann. #++ module Kernel # Note that this method will load any file that matches the glob and is # modified since the method call, regardless whether it's loaded by the # current application or not. The glob is expanded only once at the initial # method call. # def autoreload_glob(glob, check_interval=1) files = Dir.glob(glob) file_mtime = {} start_time = Time.now Thread.new { loop { sleep check_interval files.each { |file| if (File.exists?(file) and File.stat(file).mtime > (file_mtime[file] || start_time)) file_mtime[file] = File.stat(file).mtime STDERR.puts "reload #{ file }" begin load(file) rescue Exception => e STDERR.puts e.inspect end end } } } end end
Version data entries
4 entries across 4 versions & 2 rubygems