Class: Recot::Commands::Listener
- Inherits:
-
Object
- Object
- Recot::Commands::Listener
- Defined in:
- lib/recot/commands/listener.rb
Instance Method Summary collapse
-
#initialize(ignore = nil) ⇒ Listener
constructor
A new instance of Listener.
- #notify(files) ⇒ Object
- #on_added(files) ⇒ Object
- #on_modifyed(files) ⇒ Object
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(ignore = nil) ⇒ Listener
Returns a new instance of Listener.
9 10 |
# File 'lib/recot/commands/listener.rb', line 9 def initialize(ignore = nil) end |
Instance Method Details
#notify(files) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/recot/commands/listener.rb', line 28 def notify(files) return if files.empty? # Check test no. unless Cache::StateCache.restore_no puts "Please input test no. Press the Enter to continue." return end # Run all tasks. Recot::Tasks::ALL_TASKS.each do |t| cls = Object.const_get("Recot::Tasks::#{t}") cls.new.run(files) end end |
#on_added(files) ⇒ Object
20 21 22 |
# File 'lib/recot/commands/listener.rb', line 20 def on_added(files) notify(files) end |
#on_modifyed(files) ⇒ Object
24 25 26 |
# File 'lib/recot/commands/listener.rb', line 24 def on_modifyed(files) notify(files) end |
#run ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/recot/commands/listener.rb', line 12 def run @listener = ::Listen.to(Recot.basket_dir) do |mod, add, del| on_modifyed(mod) on_added(add) end @listener.start end |
#stop ⇒ Object
44 45 46 |
# File 'lib/recot/commands/listener.rb', line 44 def stop @listener.stop end |