5
6
7
8
9
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
43
44
45
|
# File 'lib/time_tap/watcher.rb', line 5
def keep_watching editor
last = nil
editor = editor.new
File.open(File.join(TimeTap.config[:root], ".tap_history"), 'a') do |history|
history.sync = true
loop do
exit if $stop
begin
if editor.is_running? && !(path = editor.current_path).blank?
mtime = File.stat(path).mtime
current = [path, mtime]
unless current == last
history << "#{mtime.to_i}: #{path}\n"
last = [path, mtime]
end
end
rescue Editors::EditorError
rescue
puts Time.now.to_s
puts $!.to_s
puts $!.backtrace.join("\n")
File.open(File.join(TimeTap.config[:root], ".tap_errors"), "w") do |file|
file.puts Time.now.to_s
file.puts $!.to_s
file.puts $!.backtrace.join("\n")
end
raise if $!.kind_of?(SignalException)
end
sleep 30
end
end
end
|