Class: Watchcat::CLI::Watcher
- Inherits:
-
Object
- Object
- Watchcat::CLI::Watcher
- Defined in:
- lib/watchcat/cli/watcher.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Watcher
constructor
A new instance of Watcher.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config) ⇒ Watcher
Returns a new instance of Watcher.
4 5 6 7 |
# File 'lib/watchcat/cli/watcher.rb', line 4 def initialize(config) @config = config @watchers = [] end |
Instance Method Details
#start ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/watchcat/cli/watcher.rb', line 9 def start puts "Starting Watchcat file watcher..." @config.watches.each do |watch_config| start_watching_path(watch_config) end puts "Watchcat is now watching for file changes. Press Ctrl+C to stop." # Keep the main thread alive begin sleep rescue Interrupt puts "\nStopping Watchcat..." stop end end |
#stop ⇒ Object
27 28 29 30 |
# File 'lib/watchcat/cli/watcher.rb', line 27 def stop @watchers.each(&:stop) @watchers.clear end |