ttscoff / Slogger

Social logging script for Day One
757 stars 160 forks source link

FacebookIFTTTLogger: `do_log': undefined method `each' #112

Open deadlyhifi opened 11 years ago

deadlyhifi commented 11 years ago

I'm getting the following error despite the file being written to by IFTTT https://ifttt.com/recipes/56242. Is this something to do with the Ruby version I'm using?

Logging FacebookIFTTTLogger posts at     /Users/deadlyhifi/Dropbox/Apps/IFTTT/Facebook/facebook.md.txt
/Users/deadlyhifi/Dropbox/Apps/slogger/plugins/facebookifttt.rb:83:in `do_log': undefined     method `each' for #<String:0x007fb4c2aca2f0> (NoMethodError)
from /Users/deadlyhifi/Dropbox/Apps/slogger/slogger.rb:197:in `block in run_plugins'
from /Users/deadlyhifi/Dropbox/Apps/slogger/slogger.rb:185:in `each'
from /Users/deadlyhifi/Dropbox/Apps/slogger/slogger.rb:185:in `run_plugins'
from /Users/deadlyhifi/Dropbox/Apps/slogger/slogger.rb:325:in `<top (required)>'
from /Users/deadlyhifi/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/deadlyhifi/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from slogger:18:in `<main>'
ttscoff commented 11 years ago

You'll need to contact @spiritofnine about updating the plugin, but it looks like the each statement needs a .split("\n") or other means of making it an array before running on the content string.

byamabe commented 11 years ago

I got this to work by changing:

f = File.new(File.expand_path(inputFile))
content = f.read
f.close

if !content.empty?
  content.each do |line|
  ...
  end
end

to:

f = File.new(File.expand_path(inputFile))
f.each_line do |line|
  ...
end

f.close