Class: MasterView::TemplateWatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/masterview/extras/watcher.rb

Class Method Summary collapse

Class Method Details

.check_updated(template_mio_tree, filename_pattern, &block) ⇒ Object

check all the templates in the MIOTree to see if their mtimes is newer than what we have saved in @@template_mtimes. If newer, then run block and add path to array to be returned If filename_pattern is specified then it will filter the results returns array of paths that were newer



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/masterview/extras/watcher.rb', line 9

def self.check_updated(template_mio_tree, filename_pattern, &block)
  template_paths_run = []
  template_mio_tree.find(:pattern => filename_pattern) do |mio|
    mtime = mio.mtime
    @@template_mtimes ||= {}
    unless @@template_mtimes[mio.pathname.to_s] == mtime
      yield mio
      @@template_mtimes[mio.pathname.to_s] = mtime
      template_paths_run << mio.pathname.to_s
    end
  end
  template_paths_run
end