Skip to content

Instantly share code, notes, and snippets.

@jraines
Created January 11, 2009 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jraines/45637 to your computer and use it in GitHub Desktop.
Save jraines/45637 to your computer and use it in GitHub Desktop.
Feed summarizer
# All code in this gist is public domain and freely available for use and alteration without attribution
require 'rubygems'
require 'simple-rss'
require 'rss'
require 'open-uri'
feed = 'http://www.tweetlinkmonster.com/feed/jraines.atom'
rss = SimpleRSS.parse(open(feed))
content = []
10.times do |i|
item = rss.items[i]
content << { :link =>"<a href='#{item.link}'>#{item.title}</a>",
:date => "Published on: #{item.updated || item.pubDate}", # atom || rss
:description => "#{item.summary || item.description}",
:author => "#{item.author || "Link"}" }
end
destination = "output.xml"
new_feed = RSS::Maker.make("2.0") do |feed|
feed.channel.title = "Twitter links via TLM"
feed.channel.link = "http://jeremyraines.com"
feed.channel.description = "Links from Twits"
output = ""
content.each do |item|
output = output + "#{item[:author]}: #{item[:link]}<br /> \n\n #{item[:description]} \n\n<br /> #{item[:date]} \n\n <br /><br />"
end
item = feed.items.new_item
item.title = "Last 10 Feed Items"
item.date = Time.now
item.description = output
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment