class Gotta::Mod::Listener
Attributes
listener[R]
queue[R]
working_directory[R]
Public Class Methods
new(working_directory:)
click to toggle source
# File lib/gotta/mod/listener.rb, line 7 def initialize(working_directory:) @working_directory = working_directory @queue = Queue.new @listener = ::Listen.to(working_directory, &callback) end
Public Instance Methods
callback()
click to toggle source
# File lib/gotta/mod/listener.rb, line 21 def callback Proc.new do |modified, added, removed| begin modified.each do |file| queue.push Event.new(type: :modified, absolute_path: file, working_directory: working_directory) end added.each do |file| queue.push Event.new(type: :added, absolute_path: file, working_directory: working_directory) end removed.each do |file| queue.push Event.new(type: :removed, absolute_path: file, working_directory: working_directory) end rescue StandardError => e puts e.full_message next end end end
start()
click to toggle source
# File lib/gotta/mod/listener.rb, line 13 def start listener.start end
stop()
click to toggle source
# File lib/gotta/mod/listener.rb, line 17 def stop listener.stop end