Class: Puppet::Util::FileWatcher

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

Instance Method Summary collapse

Methods included from Enumerable

#uniq

Constructor Details

#initializeFileWatcher

Returns a new instance of FileWatcher.



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

def initialize
  @files = {}
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


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

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

#clearObject



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

def clear
  @files.clear
end

#each(&blk) ⇒ Object



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

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

#watch(filename) ⇒ Object



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

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

#watching?(filename) ⇒ Boolean

Returns:

  • (Boolean)


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

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