= atom-tools README
atom-tools is an all-in-one library for parsing, creating and manipulating Atom feeds and entries.
It handles all the nasty XML and HTTP details so that you don't have to.
== Example
require "atom/feed"
require "open-uri"
feed = Atom::Feed.new "http://www.tbray.org/ongoing/ongoing.atom"
# =>
feed.update!
feed.entries.length
# => 20
feed.title.to_s
# => "ongoing"
feed.authors.first.name
# => "Tim Bray"
entry = feed.entries.first
# => #
entry.title.to_s
# => "M\303\274nchen"
entry.links.last
# => {"href"=>"http://www.tbray.org/ongoing/When/200x/2006/11/07/Munich#comments", "rel"=>"replies", "type" => "application/xhtml+xml"}
entry.summary.to_s
# => "That local spelling is nicer than the ugly English [...]"
Things are explained in more detail in the RDoc.
== The Atom Publishing Protocol
require "atom/service"
service = Atom::Service.new "http://necronomicorp.com/app.xml"
coll = service.workspaces.first.collections.first
# =>
coll.update!
# =>
entry = coll.entries.first
entry.title
# => 'html entities'#text
# modify the title
entry.title = "HTML entities"
# store the modified entry
coll.put! entry
# => #
coll.entries.first.title
# => 'HTML entities'#text
For details on authentication, see the documentation for Atom::HTTP
== Advanced Use
=== Extension Elements
irt = REXML::Element.new("in-reply-to")
irt.add_namespace "http://purl.org/syndication/thread/1.0"
irt.attributes["ref"] = "tag:entries.com,2005:1"
entry.extensions << irt
entry.to_s
# => ''
== YAML
if you feel like writing this stuff by hand, atom-tools can slurp an
atom:entry from YAML:
require "atom/yaml"
yaml = <blah blah blah blah
and so on.
END
entry = Atom::Entry.from_yaml(yaml)