atom-tools 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README +3 -3
  2. data/Rakefile +1 -1
  3. data/bin/atom-client.rb +13 -10
  4. data/lib/atom/collection.rb +2 -2
  5. data/lib/atom/element.rb +5 -1
  6. data/lib/atom/entry.rb +9 -2
  7. data/lib/atom/feed.rb +11 -6
  8. data/lib/atom/http.rb +157 -38
  9. data/lib/atom/service.rb +170 -0
  10. data/lib/atom/text.rb +15 -2
  11. data/lib/atom/xml.rb +1 -1
  12. data/test/conformance/updated.rb +2 -1
  13. data/test/test_constructs.rb +45 -2
  14. data/test/test_feed.rb +27 -0
  15. data/test/test_http.rb +116 -20
  16. data/test/test_protocol.rb +77 -13
  17. data/test/test_xml.rb +15 -1
  18. metadata +3 -38
  19. data/bin/atom-server.rb~ +0 -71
  20. data/doc/classes/Atom/App.html +0 -217
  21. data/doc/classes/Atom/Author.html +0 -130
  22. data/doc/classes/Atom/Category.html +0 -128
  23. data/doc/classes/Atom/Collection.html +0 -322
  24. data/doc/classes/Atom/Content.html +0 -129
  25. data/doc/classes/Atom/Contributor.html +0 -119
  26. data/doc/classes/Atom/Element.html +0 -325
  27. data/doc/classes/Atom/Entry.html +0 -365
  28. data/doc/classes/Atom/Feed.html +0 -585
  29. data/doc/classes/Atom/HTTP.html +0 -374
  30. data/doc/classes/Atom/Link.html +0 -137
  31. data/doc/classes/Atom/Text.html +0 -229
  32. data/doc/classes/XHTML.html +0 -118
  33. data/doc/created.rid +0 -1
  34. data/doc/files/README.html +0 -213
  35. data/doc/files/lib/atom/app_rb.html +0 -110
  36. data/doc/files/lib/atom/collection_rb.html +0 -110
  37. data/doc/files/lib/atom/element_rb.html +0 -109
  38. data/doc/files/lib/atom/entry_rb.html +0 -111
  39. data/doc/files/lib/atom/feed_rb.html +0 -112
  40. data/doc/files/lib/atom/http_rb.html +0 -109
  41. data/doc/files/lib/atom/text_rb.html +0 -108
  42. data/doc/files/lib/atom/xml_rb.html +0 -110
  43. data/doc/files/lib/atom/yaml_rb.html +0 -109
  44. data/doc/fr_class_index.html +0 -39
  45. data/doc/fr_file_index.html +0 -36
  46. data/doc/fr_method_index.html +0 -62
  47. data/doc/index.html +0 -24
  48. data/doc/rdoc-style.css +0 -208
  49. data/lib/atom/app.rb +0 -87
@@ -1,229 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Atom::Text</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Atom::Text</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/atom/yaml_rb.html">
59
- lib/atom/yaml.rb
60
- </a>
61
- <br />
62
- <a href="../../files/lib/atom/text_rb.html">
63
- lib/atom/text.rb
64
- </a>
65
- <br />
66
- </td>
67
- </tr>
68
-
69
- <tr class="top-aligned-row">
70
- <td><strong>Parent:</strong></td>
71
- <td>
72
- <a href="Element.html">
73
- Atom::Element
74
- </a>
75
- </td>
76
- </tr>
77
- </table>
78
- </div>
79
- <!-- banner header -->
80
-
81
- <div id="bodyContent">
82
-
83
-
84
-
85
- <div id="contextContent">
86
-
87
- <div id="description">
88
- <p>
89
- An <a href="Element.html">Atom::Element</a> representing a text construct.
90
- It has a single attribute, &quot;type&quot;, which accepts values
91
- &quot;text&quot;, &quot;html&quot; and &quot;xhtml&quot;
92
- </p>
93
-
94
- </div>
95
-
96
-
97
- </div>
98
-
99
- <div id="method-list">
100
- <h3 class="section-bar">Methods</h3>
101
-
102
- <div class="name-list">
103
- <a href="#M000017">html</a>&nbsp;&nbsp;
104
- <a href="#M000016">to_s</a>&nbsp;&nbsp;
105
- <a href="#M000018">xml</a>&nbsp;&nbsp;
106
- </div>
107
- </div>
108
-
109
- </div>
110
-
111
-
112
- <!-- if includes -->
113
-
114
- <div id="section">
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
- <!-- if method_list -->
124
- <div id="methods">
125
- <h3 class="section-bar">Public Instance methods</h3>
126
-
127
- <div id="method-M000017" class="method-detail">
128
- <a name="M000017"></a>
129
-
130
- <div class="method-heading">
131
- <a href="#M000017" class="method-signature">
132
- <span class="method-name">html</span><span class="method-args">()</span>
133
- </a>
134
- </div>
135
-
136
- <div class="method-description">
137
- <p>
138
- returns a string suitable for dumping into an HTML document
139
- </p>
140
- <p><a class="source-toggle" href="#"
141
- onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
142
- <div class="method-source-code" id="M000017-source">
143
- <pre>
144
- <span class="ruby-comment cmt"># File lib/atom/text.rb, line 32</span>
145
- 32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">html</span>
146
- 33: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span> <span class="ruby-keyword kw">or</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;html&quot;</span>
147
- 34: <span class="ruby-identifier">to_s</span>
148
- 35: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;text&quot;</span>
149
- 36: <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_s</span>
150
- 37: <span class="ruby-keyword kw">end</span>
151
- 38: <span class="ruby-keyword kw">end</span>
152
- </pre>
153
- </div>
154
- </div>
155
- </div>
156
-
157
- <div id="method-M000016" class="method-detail">
158
- <a name="M000016"></a>
159
-
160
- <div class="method-heading">
161
- <a href="#M000016" class="method-signature">
162
- <span class="method-name">to_s</span><span class="method-args">()</span>
163
- </a>
164
- </div>
165
-
166
- <div class="method-description">
167
- <p><a class="source-toggle" href="#"
168
- onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
169
- <div class="method-source-code" id="M000016-source">
170
- <pre>
171
- <span class="ruby-comment cmt"># File lib/atom/text.rb, line 23</span>
172
- 23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
173
- 24: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span>
174
- 25: <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">to_s</span>
175
- 26: <span class="ruby-keyword kw">else</span>
176
- 27: <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">to_s</span>
177
- 28: <span class="ruby-keyword kw">end</span>
178
- 29: <span class="ruby-keyword kw">end</span>
179
- </pre>
180
- </div>
181
- </div>
182
- </div>
183
-
184
- <div id="method-M000018" class="method-detail">
185
- <a name="M000018"></a>
186
-
187
- <div class="method-heading">
188
- <a href="#M000018" class="method-signature">
189
- <span class="method-name">xml</span><span class="method-args">()</span>
190
- </a>
191
- </div>
192
-
193
- <div class="method-description">
194
- <p>
195
- attepts to parse the content and return it as an array of REXML::Elements
196
- </p>
197
- <p><a class="source-toggle" href="#"
198
- onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
199
- <div class="method-source-code" id="M000018-source">
200
- <pre>
201
- <span class="ruby-comment cmt"># File lib/atom/text.rb, line 41</span>
202
- 41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">xml</span>
203
- 42: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span>
204
- 43: <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">children</span>
205
- 44: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;text&quot;</span>
206
- 45: [<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>]
207
- 46: <span class="ruby-keyword kw">else</span>
208
- 47: <span class="ruby-comment cmt"># XXX - hpricot goes here?</span>
209
- 48: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;I haven't implemented this yet&quot;</span>
210
- 49: <span class="ruby-keyword kw">end</span>
211
- 50: <span class="ruby-keyword kw">end</span>
212
- </pre>
213
- </div>
214
- </div>
215
- </div>
216
-
217
-
218
- </div>
219
-
220
-
221
- </div>
222
-
223
-
224
- <div id="validator-badges">
225
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
226
- </div>
227
-
228
- </body>
229
- </html>
@@ -1,118 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Module: XHTML</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">XHTML</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/atom/text_rb.html">
59
- lib/atom/text.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
-
76
-
77
- </div>
78
-
79
-
80
- </div>
81
-
82
-
83
- <!-- if includes -->
84
-
85
- <div id="section">
86
-
87
-
88
- <div id="constants-list">
89
- <h3 class="section-bar">Constants</h3>
90
-
91
- <div class="name-list">
92
- <table summary="Constants">
93
- <tr class="top-aligned-row context-row">
94
- <td class="context-item-name">NS</td>
95
- <td>=</td>
96
- <td class="context-item-value">&quot;http://www.w3.org/1999/xhtml&quot;</td>
97
- </tr>
98
- </table>
99
- </div>
100
- </div>
101
-
102
-
103
-
104
-
105
-
106
-
107
- <!-- if method_list -->
108
-
109
-
110
- </div>
111
-
112
-
113
- <div id="validator-badges">
114
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
115
- </div>
116
-
117
- </body>
118
- </html>
data/doc/created.rid DELETED
@@ -1 +0,0 @@
1
- Fri Nov 10 17:13:31 MST 2006
@@ -1,213 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: README</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="fileHeader">
50
- <h1>README</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>README
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Thu Nov 09 14:53:37 MST 2006</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <h1>atom-tools README</h1>
73
- <p>
74
- atom-tools is an all-in-one library for parsing, creating and manipulating
75
- Atom &lt;<a href="http://www.w3.org/2005/Atom">www.w3.org/2005/Atom</a>&gt;
76
- feeds and entries. It handles all the nasty XML and HTTP details so that
77
- you don&#8217;t have to.
78
- </p>
79
- <h2>Example</h2>
80
- <pre>
81
- require &quot;atom/feed&quot;
82
- require &quot;open-uri&quot;
83
-
84
- feed = Atom::Feed.new &quot;http://www.tbray.org/ongoing/ongoing.atom&quot;
85
- # =&gt; &lt;http://www.tbray.org/ongoing/ongoing.atom entries: 0 title=''&gt;
86
-
87
- feed.update!
88
- feed.entries.length
89
- # =&gt; 20
90
-
91
- feed.title.to_s
92
- # =&gt; &quot;ongoing&quot;
93
-
94
- feed.authors.first.name
95
- # =&gt; &quot;Tim Bray&quot;
96
-
97
- entry = feed.entries.first
98
- # =&gt; #&lt;Atom::Entry id:'http://www.tbray.org/ongoing/When/200x/2006/11/07/Munich'&gt;
99
-
100
- entry.title.to_s
101
- # =&gt; &quot;M\303\274nchen&quot;
102
-
103
- entry.links.last
104
- # =&gt; {&quot;href&quot;=&gt;&quot;http://www.tbray.org/ongoing/When/200x/2006/11/07/Munich#comments&quot;, &quot;rel&quot;=&gt;&quot;replies&quot;, &quot;type&quot; =&gt; &quot;application/xhtml+xml&quot;}
105
-
106
- entry.summary.to_s
107
- # =&gt; &quot;That local spelling is nicer than the ugly English [...]&quot;
108
- </pre>
109
- <p>
110
- Things are explained in more detail in the RDoc.
111
- </p>
112
- <h2>The Atom Publishing Protocol</h2>
113
- <pre>
114
- require &quot;atom/app&quot;
115
-
116
- app = Atom::App.new &quot;http://necronomicorp.com/app.xml&quot;
117
- coll = app.collections.first
118
- # =&gt; &lt;http://necronomicorp.com/testatom?app entries: 0 title='testing: entry endpoint'&gt;
119
-
120
- coll.update!
121
- # =&gt; &lt;http://necronomicorp.com/testatom?app entries: 10 title='testing the APP'&gt;
122
-
123
- entry = coll.entries.first
124
- entry.title
125
- # =&gt; 'html entities'#text
126
-
127
- # modify the title
128
- entry.title = &quot;HTML entities&quot;
129
-
130
- # store the modified entry
131
- coll.put! entry
132
- # =&gt; #&lt;Net::HTTPOK 200 OK readbody=true&gt;
133
-
134
- coll.entries.first.title
135
- # =&gt; 'HTML entities'#text
136
- </pre>
137
- <p>
138
- For details on authentication, see the documentation for <a
139
- href="../classes/Atom/HTTP.html">Atom::HTTP</a>
140
- </p>
141
- <h2>Advanced Use</h2>
142
- <h3>Extension Elements</h3>
143
- <pre>
144
- irt = REXML::Element.new(&quot;in-reply-to&quot;)
145
- irt.add_namespace &quot;http://purl.org/syndication/thread/1.0&quot;
146
-
147
- irt.attributes[&quot;ref&quot;] = &quot;tag:entries.com,2005:1&quot;
148
-
149
- entry.extensions &lt;&lt; irt
150
-
151
- entry.to_s
152
- # =&gt; '&lt;entry xmlns=&quot;http://www.w3.org/2005/Atom&quot;&gt;&lt;in-reply-to ref=&quot;tag:entries.com,2005:1&quot; xmlns=&quot;http://purl.org/syndication/thread/1.0&quot;/&gt;&lt;/entry&gt;'
153
- </pre>
154
- <h2>YAML</h2>
155
- <p>
156
- if you feel like writing this stuff by hand, atom-tools can slurp an
157
- atom:entry from YAML:
158
- </p>
159
- <pre>
160
- require &quot;atom/yaml&quot;
161
-
162
- yaml = &lt;&lt;END
163
- title: Atom-Drunk Pirates Run Amok!
164
- tags: tag1 tag2
165
- authors:
166
- -
167
- name: Brendan Taylor
168
- email: whateley@gmail.com
169
- -
170
- name: Harvey
171
- uri: http://fake.com/
172
-
173
- content: |
174
- &lt;p&gt;blah blah blah blah&lt;/p&gt;
175
-
176
- &lt;p&gt;and so on.&lt;/p&gt;
177
- END
178
-
179
- entry = Atom::Entry.from_yaml(yaml)
180
- </pre>
181
-
182
- </div>
183
-
184
-
185
- </div>
186
-
187
-
188
- </div>
189
-
190
-
191
- <!-- if includes -->
192
-
193
- <div id="section">
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
- <!-- if method_list -->
203
-
204
-
205
- </div>
206
-
207
-
208
- <div id="validator-badges">
209
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
210
- </div>
211
-
212
- </body>
213
- </html>