Class: Puppet::Util::FileWatcher
- Includes:
- Enumerable
- Defined in:
- lib/puppet/util/file_watcher.rb
Instance Method Summary collapse
- #changed? ⇒ Boolean
- #clear ⇒ Object
- #each(&blk) ⇒ Object
-
#initialize ⇒ FileWatcher
constructor
A new instance of FileWatcher.
- #watch(filename) ⇒ Object
- #watching?(filename) ⇒ Boolean
Constructor Details
#initialize ⇒ FileWatcher
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
14 15 16 |
# File 'lib/puppet/util/file_watcher.rb', line 14 def changed? @files.values.any?(&:changed?) end |
#clear ⇒ Object
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
24 25 26 |
# File 'lib/puppet/util/file_watcher.rb', line 24 def watching?(filename) @files.has_key?(filename) end |