I am following the example: https://github.com/Shopify/dashing/issues/78#issuecomment-14940695
The eventmachine.watch_file returns "file_deleted" everytime I modify the spreadsheet. It should actually return "file_modified"
Can someone help me?
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
Seems that roo has problem with XLS files. Works fine after I convert it to CSV.