Class: FileWatch::Discoverer

Inherits:
Object
  • Object
show all
Includes:
LogStash::Util::Loggable
Defined in:
lib/filewatch/discoverer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(watched_files_collection, sincedb_collection, settings) ⇒ Discoverer

Returns a new instance of Discoverer.



14
15
16
17
18
19
20
21
# File 'lib/filewatch/discoverer.rb', line 14

def initialize(watched_files_collection, sincedb_collection, settings)
  @watching = Concurrent::Array.new
  @exclude = Concurrent::Array.new
  @watched_files_collection = watched_files_collection
  @sincedb_collection = sincedb_collection
  @settings = settings
  @settings.exclude.each { |p| @exclude << p }
end

Instance Attribute Details

#watched_files_collectionObject (readonly)

Returns the value of attribute watched_files_collection.



12
13
14
# File 'lib/filewatch/discoverer.rb', line 12

def watched_files_collection
  @watched_files_collection
end

Instance Method Details

#add_path(path) ⇒ Object



23
24
25
26
27
28
# File 'lib/filewatch/discoverer.rb', line 23

def add_path(path)
  return if @watching.member?(path)
  @watching << path
  discover_files_new_path(path)
  self
end

#discoverObject



30
31
32
33
34
# File 'lib/filewatch/discoverer.rb', line 30

def discover
  @watching.each do |path|
    discover_files_ongoing(path)
  end
end