Saturday, March 08, 2008

rAtom 0.2.1 Gem released

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], 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 (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"))

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"
feed.updated = Time.now
end

To output a Feed as XML use to_xml

> puts feed.to_xml
<feed xmlns="http://www.w3.org/2005/Atom">
<title>My Cool Feed</title>
<id>http://example.com/my_feed.atom</id>
<updated>2008-03-03T23:19:44+10:30</updated>
</feed>

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/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"
entry.content = Atom::Content::Html.new("<p>rAtom lets me post to my blog using Ruby, how cool!</p>")
end

And publish it to the Collection:
published_entry = collection.publish(entry)

More Information

See http://ratom.rubyforge.org for more information.

10 comments:

dkubb said...

Any chance you'd consider removing ActiveSupport as a dependency for this gem? (or accept a patch that does this). I'd like to use this with a merb app, but I'd prefer not to bloat the app by pulling in all of ActiveSupport.

Sean Geoghegan said...

I haven't got a problem removing ActiveSupport. I'm only using cattr_accessor so ActiveSupport is definitely overkill.

I can probably do this in the next couple of days, or you want to submit a patch I can get it done sooner.

Thanks.

Sean Geoghegan said...

Release 0.2.2 removes Active Support. Should be available in the gem index soon. Let me know if you have any problems.

Luigi Montanez said...

Thanks for this. I'm looking to rock out with AtomPub and this looks to be a good solution. For anyone interested, there's also atom-tools. I look forward to trying both of these out.

Multifuncional said...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the Impressora e Multifuncional, I hope you enjoy. The address is http://impressora-multifuncional.blogspot.com. A hug.

Bill said...

I config'd the gem (in my Rails 2.1.0-based project) with this in environment.rb:

config.gem 'ratom', :version => '~>0.5.1'

and I see "no such file to load -- ratom" when I start my server. Do I need a :library option on that config.gem line? If so, what's the :library name?

Sean Geoghegan said...

@bill: :lib => 'atom' should fix it. Thanks

great mineral makeup said...

black mold exposureblack mold symptoms of exposurewrought iron garden gatesiron garden gates find them herefine thin hair hairstylessearch hair styles for fine thin hairnight vision binocularsbuy night vision binocularslipitor reactionslipitor allergic reactionsluxury beach resort in the philippines

afordable beach resorts in the philippineshomeopathy for eczema.baby eczema.save big with great mineral makeup bargainsmineral makeup wholesalersprodam iphone Apple prodam iphone prahacect iphone manualmanual for P 168 iphonefero 52 binocularsnight vision Fero 52 binocularsThe best night vision binoculars here

night vision binoculars bargainsfree photo albums computer programsfree software to make photo albumsfree tax formsprintable tax forms for free craftmatic air bedcraftmatic air bed adjustable info hereboyd air bedboyd night air bed lowest pricefind air beds in wisconsinbest air beds in wisconsincloud air beds

best cloud inflatable air bedssealy air beds portableportables air bedsrv luggage racksaluminum made rv luggage racksair bed raisedbest form raised air bedsaircraft support equipmentsbest support equipments for aircraftsbed air informercialsbest informercials bed airmattress sized air beds

bestair bed mattress antique doorknobsantique doorknob identification tipsdvd player troubleshootingtroubleshooting with the dvd playerflat panel television lcd vs plasmaflat panel lcd television versus plasma pic the bestThe causes of economic recessionwhat are the causes of economic recessionadjustable bed air foam The best bed air foam

hoof prints antique equestrian printsantique hoof prints equestrian printsBuy air bedadjustablebuy the best adjustable air bedsair beds canadian storesCanadian stores for air beds

migraine causemigraine treatments floridaflorida headache clinicdrying dessicantair drying dessicantdessicant air dryerpediatric asthmaasthma specialistasthma children specialistcarpet cleaning dallas txcarpet cleaners dallascarpet cleaning dallas

vero beach vacationvero beach vacationsbeach vacation homes veroms beach vacationsms beach vacationms beach condosmaui beach vacationmaui beach vacationsmaui beach clubbeach vacationsyour beach vacationscheap beach vacations

bob hairstylebob haircutsbob layeredpob hairstylebobbedclassic bobCare for Curly HairTips for Curly Haircurly hair12r 22.5 best pricetires truck bustires 12r 22.5

washington new housenew house houstonnew house san antonionew house venturanew houston house houston house txstains removal dyestains removal clothesstains removalteeth whiteningteeth whiteningbright teeth

Flerkin McBlerkin said...

Man that looks so much simpler than the hoops you have to jump through with PHP!
Sunroom

Anonymous said...

purchase viagra pfizer viagra problems with viagra effect of viagra on women viagra facts ship free viagra sample herbal viagra reviews pharmacy viagra women does viagra work non prescription viagra buy viagra in england viagra covered by insurance 2007 viagra hmo how does viagra work