public
Fork of sr/atom-tools
Description: A Ruby library for Atom and the Atom Publishing Protocol.
Homepage: http://github.com/bct/atom-tools/wikis
Clone URL: git://github.com/bct/atom-tools.git
bct (author)
Sat Aug 15 14:31:56 -0700 2009
commit  21f1b3106e83d98a58a86369a6ff1bd07e83ae67
tree    6112ca38a20ea6de191c60b4c9038876551e06f0
parent  28fbf204a02d1e45214224c3ec5f471daea4e05f
atom-tools / README
100644 64 lines (42 sloc) 1.752 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
= 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.