Sha256: 2d700cfdc77f314212f0e5d554595adbc862c42c6f8723d904bd1df11f3766ef

Contents?: true

Size: 703 Bytes

Versions: 3

Compression:

Stored size: 703 Bytes

Contents

# Copied from Wee 0.8.0
# (c) 2004 Michael Neumann.

module Kernel

def autoreload(check_interval=10)
  Thread.new(Time.now) { |start_time|
    file_mtime = {}
    loop do
      sleep check_interval 
      $LOADED_FEATURES.each do |feature|
        $LOAD_PATH.each do |lp|
          file = File.join(lp, feature)
          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
    end
  }
end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
glue-0.21.0 lib/glue/autoreload.rb
glue-0.21.2 lib/glue/autoreload.rb
glue-0.22.0 lib/glue/autoreload.rb