我正在关注示例:https ://github.com/Shopify/dashing/issues/78#issuecomment-14940695
每次我修改电子表格时,eventmachine.watch_file 都会返回“file_deleted”。它实际上应该返回“file_modified”
有人能帮我吗?
require 'roo'
EM.kqueue = EM.kqueue?
file_path = "#{Dir.pwd}/spreadsheet.xls"
def fetch_spreadsheet_data(path)
s = Roo::Excel.new(path)
send_event('career_score', { current: s.cell(2, 2) })
end
module Handler
def file_modified
puts "BLAHBLAH1"
fetch_spreadsheet_data(path)
puts "BLAHBLAH"
end
def file_moved
puts "Moved"
fetch_spreadsheet_data(path)
end
def file_deleted
puts "Deleted"
fetch_spreadsheet_data(path)
end
def unbind
puts "#{path} monitoring ceased"
end
end
fetch_spreadsheet_data(file_path)
EM.next_tick do
EM.watch_file(file_path, Handler)
end