Parent

Class Index [+]

Quicksearch

Ramaze::Reloader::WatchStat

Public Class Methods

new() click to toggle source
   # File lib/ramaze/reloader/watch_stat.rb, line 4
4:       def initialize
5:         # @files[file_path] = stat
6:         @files = {}
7:         @last = Time.now
8:       end

Public Instance Methods

call(cooldown) click to toggle source
    # File lib/ramaze/reloader/watch_stat.rb, line 10
10:       def call(cooldown)
11:         if cooldown and Time.now > @last + cooldown
12:           yield
13:           @last = Time.now
14:         end
15:       end
changed_files() click to toggle source

return files changed since last call

    # File lib/ramaze/reloader/watch_stat.rb, line 40
40:       def changed_files
41:         @files.each do |file, stat|
42:           if new_stat = safe_stat(file)
43:             if new_stat.mtime > stat.mtime
44:               @files[file] = new_stat
45:               yield(file)
46:             end
47:           end
48:         end
49:       end
close() click to toggle source

no need for cleanup

    # File lib/ramaze/reloader/watch_stat.rb, line 36
36:       def close
37:       end
remove_watch(file) click to toggle source

stop watching a file for changes

    # File lib/ramaze/reloader/watch_stat.rb, line 31
31:       def remove_watch(file)
32:         @files.delete(file)
33:       end
safe_stat(file) click to toggle source
    # File lib/ramaze/reloader/watch_stat.rb, line 51
51:       def safe_stat(file)
52:         File.stat(file)
53:       rescue Errno::ENOENT, Errno::ENOTDIR
54:         nil
55:       end
watch(file) click to toggle source

start watching a file for changes true if succeeded, false if failure

    # File lib/ramaze/reloader/watch_stat.rb, line 19
19:       def watch(file)
20:         return true if watching?(file) # if already watching
21:         if stat = safe_stat(file)
22:           @files[file] = stat
23:         end
24:       end
watching?(file) click to toggle source
    # File lib/ramaze/reloader/watch_stat.rb, line 26
26:       def watching?(file)
27:         @files.has_key?(file)
28:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.