# rAtom 0.2.1 Gem Released

**URL:** <https://www.ruby-forum.com/t/ratom-0-2-1-gem-released/131393>\
**Category:** Ruby\
**Created:** [March 9, 2008, 7:19am UTC](https://www.ruby-forum.com/t/ratom-0-2-1-gem-released/131393 "2008-03-09T07:19:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Geoghegan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@Sean\_Geoghegan](https://www.ruby-forum.com/u/Sean_Geoghegan)\
**Post date:** [March 9, 2008, 7:19am UTC](https://www.ruby-forum.com/t/ratom-0-2-1-gem-released/131393/1 "2008-03-09T07:19:49Z")

</div>

rAtom is a Ruby Gem for working with the Atom Syndication Format and  
the Atom Publishing Protocol (APP).

rAtom was originally built to support the communication between a  
number of applications built by Peerworks[[http://peerworks.org](http://peerworks.org)], via  
the Atom Publishing protocol. However, it supports, or aims to  
support, all the Atom Syndication Format and Publication Protocol and  
can be used to access Atom feeds or to script publishing entries to a  
blog supporting APP.

Features:

- Uses libxml-ruby so it is _much_ faster than a REXML based library.
- Uses the libxml pull parser so it has much lighter memory usage.
- Supports RFC 5005 ([NetMovies Queue](http://www.ietf.org/rfc/rfc5005.txt)) for feed  
pagination.

You can install via gem using:

# sudo gem install ratom

= Usage

To fetch and parse an Atom Feed you can simply:

feed = Atom::Feed.load\_feed(URI.parse(“[http://example.com/feed.atom](http://example.com/feed.atom)”))

And then iterate over the entries in the feed using:

feed.each\_entry do |entry|

# do cool stuff

end

To construct a Feed

feed = Atom::Feed.new do |feed|  
feed.title = “My Cool Feed”  
feed.id = “[http://example.com/my\_feed.atom](http://example.com/my_feed.atom)”  
feed.updated = Time.now  
end

To output a Feed as XML use to\_xml

> puts feed.to\_xml

 My Cool Feed http://example.com/my\_feed.atom 2008-03-03T23:19:44+10:30

= Publishing

To publish to a remote feed using the Atom Publishing Protocol, first  
you need to create a collection to publish to:

collection = Atom::Pub::Collection.new(:href =\> ‘[http://example.org/](http://example.org/)  
myblog’)

Then create a new entry:

entry = Atom::Entry.new do |entry|  
entry.title = “I have discovered rAtom”  
entry.authors \<\< name =“”\> ‘A happy developer’)  
entry.updated = Time.now  
entry.id = “[http://example.org/myblog/newpost](http://example.org/myblog/newpost)”  
entry.content = Atom::Content::Html.new(“

rAtom lets me post to my  
blog using Ruby, how cool!

”)  
end

And publish it to the Collection:

published\_entry = collection.publish(entry)

= More Information

See [http://ratom.rubyforge.org](http://ratom.rubyforge.org) for more information.
