1## 2# = RSS reading and writing 3# 4# Really Simple Syndication (RSS) is a family of formats that describe 'feeds,' 5# specially constructed XML documents that allow an interested person to 6# subscribe and receive updates from a particular web service. This portion of 7# the standard library provides tooling to read and create these feeds. 8# 9# The standard library supports RSS 0.91, 1.0, 2.0, and Atom, a related format. 10# Here are some links to the standards documents for these formats: 11# 12# * RSS 13# * 0.9.1[http://www.rssboard.org/rss-0-9-1-netscape] 14# * 1.0[http://web.resource.org/rss/1.0/] 15# * 2.0[http://www.rssboard.org/rss-specification] 16# * Atom[http://tools.ietf.org/html/rfc4287] 17# 18# == Consuming RSS 19# 20# If you'd like to read someone's RSS feed with your Ruby code, you've come to 21# the right place. It's really easy to do this, but we'll need the help of 22# open-uri: 23# 24# require 'rss' 25# require 'open-uri' 26# 27# url = 'http://www.ruby-lang.org/en/feeds/news.rss' 28# open(url) do |rss| 29# feed = RSS::Parser.parse(rss) 30# puts "Title: #{feed.channel.title}" 31# feed.items.each do |item| 32# puts "Item: #{item.title}" 33# end 34# end 35# 36# As you can see, the workhorse is RSS::Parser#parse, which takes the source of 37# the feed and a parameter that performs validation on the feed. We get back an 38# object that has all of the data from our feed, accessible through methods. 39# This example shows getting the title out of the channel element, and looping 40# through the list of items. 41# 42# == Producing RSS 43# 44# Producing our own RSS feeds is easy as well. Let's make a very basic feed: 45# 46# require "rss" 47# 48# rss = RSS::Maker.make("atom") do |maker| 49# maker.channel.author = "matz" 50# maker.channel.updated = Time.now.to_s 51# maker.channel.about = "http://www.ruby-lang.org/en/feeds/news.rss" 52# maker.channel.title = "Example Feed" 53# 54# maker.items.new_item do |item| 55# item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/" 56# item.title = "Ruby 1.9.2-p136 is released" 57# item.updated = Time.now.to_s 58# end 59# end 60# 61# puts rss 62# 63# As you can see, this is a very Builder-like DSL. This code will spit out an 64# Atom feed with one item. If we needed a second item, we'd make another block 65# with maker.items.new_item and build a second one. 66# 67# == Copyright 68# 69# Copyright (c) 2003-2007 Kouhei Sutou <kou@cozmixng.org> 70# 71# You can redistribute it and/or modify it under the same terms as Ruby. 72# 73# There is an additional tutorial by the author of RSS at: 74# http://www.cozmixng.org/~rwiki/?cmd=view;name=RSS+Parser%3A%3ATutorial.en 75 76module RSS 77end 78 79require 'rss/1.0' 80require 'rss/2.0' 81require 'rss/atom' 82require 'rss/content' 83require 'rss/dublincore' 84require 'rss/image' 85require 'rss/itunes' 86require 'rss/slash' 87require 'rss/syndication' 88require 'rss/taxonomy' 89require 'rss/trackback' 90 91require "rss/maker" 92