Skip to content

Instantly share code, notes, and snippets.

@zenom
Created July 23, 2010 21:50
Show Gist options
  • Save zenom/488085 to your computer and use it in GitHub Desktop.
Save zenom/488085 to your computer and use it in GitHub Desktop.
# 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
@zenom
Copy link
Author

zenom commented Jul 23, 2010

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
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment