Class: PluginTool::WatcherPoll
- Inherits:
-
Object
- Object
- PluginTool::WatcherPoll
- Defined in:
- lib/watchers.rb
Instance Method Summary collapse
-
#initialize(dirs) ⇒ WatcherPoll
constructor
A new instance of WatcherPoll.
- #make_contents ⇒ Object
- #wait(timeout) ⇒ Object
Constructor Details
#initialize(dirs) ⇒ WatcherPoll
Returns a new instance of WatcherPoll.
5 6 7 8 |
# File 'lib/watchers.rb', line 5 def initialize(dirs) @dirs = dirs @last_contents = make_contents end |
Instance Method Details
#make_contents ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/watchers.rb', line 20 def make_contents c = '' @dirs.each do |dir| Dir.glob("#{dir}/**/*").each do |file| c << file c << ":#{File.mtime(file).to_i}\n" end end c end |
#wait(timeout) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/watchers.rb', line 9 def wait(timeout) while timeout > 0 c = make_contents if @last_contents != c @last_contents = c return end timeout -= 1 sleep 1 end end |