sr / atom-tools

mirror of the darcs repository (ruby lib for atom/atompub)

This URL has Read+Write access

name age message
file COPYING Wed Feb 20 20:19:04 -0800 2008 whitespace cleanup and a teensy-tiny bugfix da... [bct]
file README Mon Jun 29 00:36:13 -0700 2009 hashed out ln 600 of element.rb, updated README. [Tim]
file Rakefile Tue May 13 18:32:33 -0700 2008 fix-homepage haha, I'm dumb darcs-hash:200805... [bct]
directory bin/ Fri Mar 28 19:49:38 -0700 2008 more-tools darcs-hash:20080329024938-ce558-d20... [bct]
directory lib/ Tue May 13 18:29:56 -0700 2008 atom-tools-2.0.1 version bump darcs-hash:2008... [bct]
file setup.rb Thu Nov 09 10:12:31 -0800 2006 [project @ whateley@gmail.com-20061109181231-30... [bct]
directory spec/ Tue May 06 19:08:03 -0700 2008 absolutize-coll-hrefs darcs-hash:2008050702080... [bct]
directory test/ Mon Mar 17 19:43:57 -0700 2008 specs-bugfixes-whitespace darcs-hash:200803180... [bct]
README
= atom-tools README

atom-tools is an all-in-one library for parsing, creating and manipulating Atom <http://www.w3.org/2005/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"
    # => <http://www.tbray.org/ongoing/ongoing.atom entries: 0 title=''>

  feed.update!
  feed.entries.length
    # => 20

  feed.title.to_s
    # => "ongoing"

  feed.authors.first.name
    # => "Tim Bray"

  entry = feed.entries.first
    # => #<Atom::Entry id:'http://www.tbray.org/ongoing/When/200x/2006/11/07/Munich'>

  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
    # => <http://necronomicorp.com/testatom?app entries: 0 title='testing: entry endpoint'>

  coll.feed.update!
    # => <http://necronomicorp.com/testatom?app entries: 10 title='testing the APP'>

  entry = coll.feed.entries.first
  entry.title
    # => 'html entities'#text

  # modify the title
  entry.title = "HTML entities"

  # store the modified entry
  coll.put! entry
    # => #<Net::HTTPOK 200 OK readbody=true>

  coll.feed.entries.first.title
    # => 'HTML entities'#text

For details on authentication, see the documentation for Atom::HTTP.