more changes

This commit is contained in:
John Bintz 2012-05-03 06:34:13 -04:00
parent 7babad2d65
commit d5e99159f1

View File

@ -80,7 +80,19 @@ class UnisonProfile
end end
def lines def lines
@lines ||= File.readlines(File.expand_path("~/.unison/#{@which}.prf")) return @lines if @lines
@lines = File.readlines(File.expand_path("~/.unison/#{@which}.prf"))
includes = []
@lines.each do |line|
if file = line[%r{^include (.*)}, 1]
includes += File.readlines(File.expand_path("~/.unison/#{file}"))
end
end
@lines += includes
end end
def paths def paths
@ -99,26 +111,28 @@ watcher = Thread.new do
while !Thread.current[:app]; sleep 0.1; end while !Thread.current[:app]; sleep 0.1; end
begin begin
watch = nil @watch = nil
p Thread.current[:paths]
case RbConfig::CONFIG['host_os'] case RbConfig::CONFIG['host_os']
when /darwin/ when /darwin/
require 'rb-fsevent' require 'rb-fsevent'
watch = FSEvent.new @watch = FSEvent.new
watch.watch Thread.current[:paths], :latency => 0.25 do |directories| @watch.watch Thread.current[:paths], :latency => 0.1 do |directories|
Thread.current[:app] << directories Thread.current[:app] << directories
end end
when /linux/ when /linux/
require 'rb-inotify' require 'rb-inotify'
watch = INotify::Notifier.new @watch = INotify::Notifier.new
Thread.current[:paths].each do |path| Thread.current[:paths].each do |path|
notifier.watch path, :recursive, :modify, :create, :delete do |event| @watch.watch path, :recursive, :modify, :create, :delete do |event|
Thread.current[:app] << event.absolute_name Thread.current[:app] << event.absolute_name
end end
end end
end end
watch.run @watch.run
rescue => e rescue => e
puts e.message puts e.message
puts e.backtrace.join("\n") puts e.backtrace.join("\n")