class Lookbook::Reloaders::Reloader

def file_watcher

def file_watcher
  return @_file_watcher if @_file_watcher
  to_watch = directories.each_with_object({}) do |directory, result|
    result[directory] = extensions
  end
  @_file_watcher ||= FileWatcher.new([], to_watch) do
    callback.call(@last_changes)
    @last_changes = nil
  end
end

def initialize(name, directories, extensions, &callback)

def initialize(name, directories, extensions, &callback)
  @name = name.to_sym
  @directories = directories
  @extensions = extensions
  @callback = callback
  @last_changes = nil
end

def watching?(changes)

def watching?(changes)
  file_paths = changes.to_h.values.flatten
  !!file_paths.find do |file_path|
    file_path = Pathname(file_path).expand_path
    directories.find do |dir_path|
      matcher = File.expand_path(File.join(dir_path, "**"))
      file_path.fnmatch?(matcher)
    end
  end
end