zenom
7/23/2010 - 9:50 PM

gistfile1.rb

# Using updated_feed.any?
servers/feed.rb:25:in `block in <main>': undefined method `any?' for #<Feedzirra::Parser::RSS:0x000001045e58f8> (NoMethodError)

# Using updated_feed.updated?
servers/feed.rb:25:in `block in <main>': undefined method `updated?' for nil:NilClass (NoMethodError)

# the developers example @ https://gist.github.com/132671/6727818ec78f766ef4b8321c114f29fbd72286a0


require File.expand_path(File.dirname(__FILE__) + "/../config/boot")

# get all the feeds
@feeds = Feed.good_feeds.all

@feeds.each do |feed|  

  # build a feed to see if its updated.
  feed_to_update                = feed.feed_format == 'atom' ? Feedzirra::Parser::Atom.new : Feedzirra::Parser::RSS.new
  feed_to_update.feed_url       = feed.feed_url
  feed_to_update.etag           = feed.etag
  feed_to_update.last_modified  = feed.last_modified
  
  last_entry              = feed.feed_format == 'atom' ? Feedzirra::Parser::AtomEntry.new : Feedzirra::Parser::RSSEntry.new
  last_entry.url          = Post.last_entry_for_feed(feed.id)[0].url

  feed_to_update.entries  = [last_entry]

  updated_feed = Feedzirra::Feed.update(feed_to_update)
  
  if updated_feed.updated?
    logger.info("Working on #{feed.title}")
  end