Skip to content
Browse files

Using feedzirra as an rss-parser - now finally this seems to work

  • Loading branch information...
1 parent 7568f4c commit 7e2fc3875a44253a5151d62a353691984df184d6 @PragTob committed Sep 26, 2011
Showing with 7 additions and 7 deletions.
  1. +1 −0 infoes.rb
  2. +3 −3 lib/rss_entry.rb
  3. +3 −4 lib/rss_feeds.rb
View
1 infoes.rb
@@ -5,6 +5,7 @@
gem 'twitter'
gem 'oauth'
gem 'launchy'
+ gem 'feedzirra'
end
# requires are strange but require_relative throws "Can't infer basepath errors"
View
6 lib/rss_entry.rb
@@ -1,4 +1,3 @@
-require 'rss/2.0'
require 'launchy'
require_relative 'date_time_comparable'
@@ -11,8 +10,9 @@ class RSSEntry
# initialize given the feed object
def initialize(feed_entry)
@title = feed_entry.title
- @url = feed_entry.link
- @date_time = feed_entry.pubDate
+ @url = feed_entry.url
+ # RSS vs. Atom
+ @date_time = feed_entry.published
end
def display(shoes)
View
7 lib/rss_feeds.rb
@@ -1,4 +1,4 @@
-require 'rss/2.0'
+require 'feedzirra'
require 'open-uri'
require 'yaml'
require_relative 'rss_entry'
@@ -59,9 +59,8 @@ def change_preferences
def parse_rss_entries(url)
content = ""
begin
- open(url) { |s| content = s.read }
-
- RSS::Parser.parse(content, false).items.inject([]) do |entries, rss_entry|
+ Feedzirra::Feed.fetch_and_parse(url).entries.inject([]) do
+ |entries, rss_entry|
entries << RSSEntry.new(rss_entry)
end
rescue

0 comments on commit 7e2fc38

Please sign in to comment.
Something went wrong with that request. Please try again.