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.



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

def initialize
  @files = {}
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


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

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

#clearObject



28
29
30
# File 'lib/puppet/util/file_watcher.rb', line 28

def clear
  @files.clear
end

#each(&blk) ⇒ Object



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

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

#watch(filename) ⇒ Object



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

def watch(filename)
  return if watching?(filename)

  @files[filename] = Puppet::Util::WatchedFile.new(filename)
end

#watching?(filename) ⇒ Boolean

Returns:

  • (Boolean)


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

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