Class: Evesync::Watcher::File
- Defined in:
- lib/evesync/watcher/file.rb
Overview
Watches the files and directories, defined in configuration attribute watch
TODO:
* Test on various cases, make it work properly
* Find out all possible occasions
Instance Method Summary collapse
-
#initialize(queue) ⇒ File
constructor
A new instance of File.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(queue) ⇒ File
Returns a new instance of File.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/evesync/watcher/file.rb', line 20 def initialize(queue) @queue = queue @watches = Config[:evemond]['watch'] @period = Config[:evemond]['watch_interval'].to_i @inotify = INotify::Notifier.new @events = {} @wfiles = [] @wdirs = [] initialize_watcher end |
Instance Method Details
#start ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/evesync/watcher/file.rb', line 31 def start @inotify_thr = Thread.new { @inotify.run } @main_thr = Thread.new do loop do sleep @period send_events end end end |
#stop ⇒ Object
41 42 43 44 45 |
# File 'lib/evesync/watcher/file.rb', line 41 def stop @inotify.stop @inotify_thr.exit @main_thr.exit end |