Class: Puppet::Util::FileWatcher

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/puppet/util/file_watcher.rb

Instance Method Summary collapse

Constructor Details

#initializeFileWatcher

Returns a new instance of FileWatcher.



9
10
11
# File 'lib/puppet/util/file_watcher.rb', line 9

def initialize
  @files = {}
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/puppet/util/file_watcher.rb', line 13

def changed?
  @files.values.any?(&:changed?)
end

#clearObject



26
27
28
# File 'lib/puppet/util/file_watcher.rb', line 26

def clear
  @files.clear
end

#each(&blk) ⇒ Object



5
6
7
# File 'lib/puppet/util/file_watcher.rb', line 5

def each(&blk)
  @files.keys.each(&blk)
end

#watch(filename) ⇒ Object



17
18
19
20
# File 'lib/puppet/util/file_watcher.rb', line 17

def watch(filename)
  return if watching?(filename)
  @files[filename] = Puppet::Util::WatchedFile.new(filename)
end

#watching?(filename) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/puppet/util/file_watcher.rb', line 22

def watching?(filename)
  @files.has_key?(filename)
end