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.
14 15 16 17 18 19 20 21 |
# File 'lib/puppet/util/watched_file.rb', line 14 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.
8 9 10 |
# File 'lib/puppet/util/watched_file.rb', line 8 def filename @filename end |
Instance Method Details
#changed? ⇒ true, false
Returns If the file has changed since it was last checked.
24 25 26 |
# File 'lib/puppet/util/watched_file.rb', line 24 def changed? @info.changed? end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/puppet/util/watched_file.rb', line 34 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?)
30 31 32 |
# File 'lib/puppet/util/watched_file.rb', line 30 def to_str @filename end |