Class: Puppet::Util::WatchedFile
- Defined in:
- lib/puppet/util/watched_file.rb
Overview
Monitor a given file for changes on a periodic interval. Changes are detected by looking for a change in the file ctime.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#changed? ⇒ true, false
If the file has changed since it was last checked.
-
#initialize(filename, timer = Puppet::Util::Watcher::Timer.new(Puppet[:filetimeout])) ⇒ WatchedFile
constructor
A new instance of WatchedFile.
- #to_s ⇒ Object
-
#to_str ⇒ Object
Allow this to be used as the name of the file being watched in various other methods (such as Puppet::FileSystem.exist?).
Constructor Details
#initialize(filename, timer = Puppet::Util::Watcher::Timer.new(Puppet[:filetimeout])) ⇒ WatchedFile
Returns a new instance of WatchedFile.
15 16 17 18 19 20 21 22 |
# File 'lib/puppet/util/watched_file.rb', line 15 def initialize(filename, timer = Puppet::Util::Watcher::Timer.new(Puppet[:filetimeout])) @filename = filename @timer = timer @info = Puppet::Util::Watcher::PeriodicWatcher.new( Puppet::Util::Watcher::Common.file_ctime_change_watcher(@filename), timer) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
9 10 11 |
# File 'lib/puppet/util/watched_file.rb', line 9 def filename @filename end |
Instance Method Details
#changed? ⇒ true, false
Returns If the file has changed since it was last checked.
25 26 27 |
# File 'lib/puppet/util/watched_file.rb', line 25 def changed? @info.changed? end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/puppet/util/watched_file.rb', line 35 def to_s "<WatchedFile: filename = #{@filename}, timeout = #{@timer.timeout}>" end |
#to_str ⇒ Object
Allow this to be used as the name of the file being watched in various other methods (such as Puppet::FileSystem.exist?)
31 32 33 |
# File 'lib/puppet/util/watched_file.rb', line 31 def to_str @filename end |