10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/insup/listener.rb', line 10
def listen(&block)
return if @listener
@listener = Listen.to(tracked_locations, force_polling: @settings.options['force_polling']) do |modified, added, removed|
flags = {}
added.each do |file|
flags[file] = flags[file] ? flags[file] | 4 : 4
end
modified.each do |file|
flags[file] = flags[file] ? flags[file] | 2 : 2
end
removed.each do |file|
flags[file] = flags[file] ? flags[file] | 1 : 1
end
res = []
flags.each do |f, flag|
pn = Pathname.new(f)
basepn = Pathname.new(@base)
file = pn.relative_path_from(basepn).to_s
next if ignore_matcher.matched?(file)
tracked_file = create_tracked_file(flag, file)
res << tracked_file if !tracked_file.nil?
end
yield res
end
@listener.start
end
|