eventmachine.watch_file返回错误的文件状态

时间:2014-07-06 17:04:53

标签: eventmachine dashing

我关注的是示例: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

1 个答案:

答案 0 :(得分:0)

似乎roo XLS文件有问题。将其转换为CSV后,工作正常。