Created
September 17, 2009 17:24
-
-
Save scottru/188601 to your computer and use it in GitHub Desktop.
problems with update for Feedzirra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Full parse - note modified timestamp | |
>> Feedzirra::Feed.fetch_and_parse("http://oodlesofart.blogspot.com/feeds/posts/default") | |
=> #<Feedzirra::Parser::Atom:0x103403d38 | |
@feed_url="http://oodlesofart.blogspot.com/feeds/posts/default", | |
@links=["http://oodlesofart.blogspot.com/feeds/posts/default", ...], | |
@entries=[...], @title="Oodles of Art", | |
@etag="W/\"DUAFQnk6cCl7ImA9WxNQEUQ.\"", | |
@url="http://oodlesofart.blogspot.com/", | |
@last_modified=Thu Sep 17 07:28:33 -0700 2009> | |
# Now start with previous data | |
>> rss_feed = RssFeed.find_by_url("http://oodlesofart.blogspot.com/") | |
=> #<TeacherFeed id: 16, title: " Oodles of Art", | |
feed_url: "http://oodlesofart.blogspot.com/feeds/posts/default/", | |
feed_updated_date: "2009-09-16 11:05:27", url: "http://oodlesofart.blogspot.com/", | |
etag: "W/\"A0YGRn44cSl7ImA9WxNQEEQ.\""> | |
# Set starting variables | |
>> feed_to_update = Feedzirra::Parser::Atom.new | |
>> feed_to_update.feed_url = rss_feed.feed_url | |
>> feed_to_update.etag = rss_feed.etag | |
>> feed_to_update.last_modified = rss_feed.feed_updated_date | |
>> last_entry = Feedzirra::Parser::AtomEntry.new | |
>> last_entry.url = (first_article = rss_feed.rss_articles.first) ? first_article['link'] : nil | |
>> feed_to_update.entries = [last_entry] | |
# make sure that worked | |
>> feed_to_update | |
=> #<Feedzirra::Parser::Atom:0x102da7d18 | |
@feed_url="http://oodlesofart.blogspot.com/feeds/posts/default", | |
@entries=[#<Feedzirra::Parser::AtomEntry:0x102d94510 @url="http://oodlesofart.blogspot.com/2009/09/miro-funky-people-1st-grade.html">], | |
@etag="W/\"A0YGRn44cSl7ImA9WxNQEEQ.\"", | |
@last_modified=Wed, 16 Sep 2009 04:05:27 PDT -07:00> | |
# OK, get the update | |
>> updated_feed = Feedzirra::Feed.update(feed_to_update) | |
=> #<Feedzirra::Parser::Atom:0x102da7d18 | |
@feed_url="http://oodlesofart.blogspot.com/feeds/posts/default", | |
@links=[], @title="Oodles of Art", | |
@entries=[#<Feedzirra::Parser::AtomEntry:0x102d68bb8 @published=Thu Sep 17 14:25:00 UTC 2009,...>...], | |
@etag="W/\"A0YGRn44cSl7ImA9WxNQEEQ.\"", | |
@url="http://oodlesofart.blogspot.com/", | |
@last_modified=Wed, 16 Sep 2009 04:05:27 PDT -07:00, @updated=true> | |
# Note that there is a new entry in there, but the last_modified date has not changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment