Generating an Atom feed using the rss gem

| updated

See Atom feeds for a summary of the Atom specification.

The rss gem is bundled with Ruby. On Debian, it is included in the librubyX.Y package.

Usage example

The README has the following example for generating an Atom feed:

require 'rss'

rss = RSS::Maker.make('atom') do |maker|
  maker.channel.author = 'matz'
  maker.channel.updated = Time.now.to_s
  maker.channel.about = 'http://www.ruby-lang.org/en/feeds/news.rss'
  maker.channel.title = 'Example Feed'

  maker.items.new_item do |item|
    item.link = 'http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/'
    item.title = 'Ruby 1.9.2-p136 is released'
    item.updated = Time.now.to_s
  end
end

puts rss

It generates the following output:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <author>
    <name>matz</name>
  </author>
  <id>http://www.ruby-lang.org/en/feeds/news.rss</id>
  <title>Example Feed</title>
  <updated>2025-03-26T08:14:32+02:00</updated>

  <entry>
    <id>http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/</id>
    <link href="http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"/>
    <title>Ruby 1.9.2-p136 is released</title>
    <updated>2025-03-26T08:14:32+02:00</updated>
    <dc:date>2025-03-26T08:14:32+02:00</dc:date>
  </entry>

  <dc:date>2025-03-26T08:14:32+02:00</dc:date>

</feed>

Observations

Decisions

For this blog …