openmind ☃   August 16, 2008  ☃  atom2rss.rb  (, , )

#!/usr/bin/env ruby

%w[pp rubygems atom rss/maker].each{|lib| require lib}

atom = Atom::Feed.new(File.readlines("index.atom").to_s)

content = RSS::Maker.make("2.0") do |rss|
  rss.channel.title = "title"
  rss.channel.link = "http://link"
  rss.channel.description = "descr"
  atom.entries.each do |a|
    i = rss.items.new_item
    i.title = a.title
    i.link = a.links
    i.content_encoded = a.content.value
    i.date = (a.published < a.updated) ? a.updated : a.published
  end
  rss
end

File.open("index.rss","w") do |f|
  f.write(content)
end

blog comments powered by Disqus