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.
16 17 18 19 20 21 22 23 24 |
# File 'lib/puppet/util/watched_file.rb', line 16 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.
10 11 12 |
# File 'lib/puppet/util/watched_file.rb', line 10 def filename @filename end |
Instance Method Details
#changed? ⇒ true, false
Returns If the file has changed since it was last checked.
27 28 29 |
# File 'lib/puppet/util/watched_file.rb', line 27 def changed? @info.changed? end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/puppet/util/watched_file.rb', line 37 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?)
33 34 35 |
# File 'lib/puppet/util/watched_file.rb', line 33 def to_str @filename end |