atom-tools 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/COPYING +18 -0
  2. data/README +103 -0
  3. data/Rakefile +77 -0
  4. data/bin/atom-client.rb +246 -0
  5. data/bin/atom-server.rb~ +71 -0
  6. data/doc/classes/Atom/App.html +217 -0
  7. data/doc/classes/Atom/Author.html +130 -0
  8. data/doc/classes/Atom/Category.html +128 -0
  9. data/doc/classes/Atom/Collection.html +322 -0
  10. data/doc/classes/Atom/Content.html +129 -0
  11. data/doc/classes/Atom/Contributor.html +119 -0
  12. data/doc/classes/Atom/Element.html +325 -0
  13. data/doc/classes/Atom/Entry.html +365 -0
  14. data/doc/classes/Atom/Feed.html +585 -0
  15. data/doc/classes/Atom/HTTP.html +374 -0
  16. data/doc/classes/Atom/Link.html +137 -0
  17. data/doc/classes/Atom/Text.html +229 -0
  18. data/doc/classes/XHTML.html +118 -0
  19. data/doc/created.rid +1 -0
  20. data/doc/files/README.html +213 -0
  21. data/doc/files/lib/atom/app_rb.html +110 -0
  22. data/doc/files/lib/atom/collection_rb.html +110 -0
  23. data/doc/files/lib/atom/element_rb.html +109 -0
  24. data/doc/files/lib/atom/entry_rb.html +111 -0
  25. data/doc/files/lib/atom/feed_rb.html +112 -0
  26. data/doc/files/lib/atom/http_rb.html +109 -0
  27. data/doc/files/lib/atom/text_rb.html +108 -0
  28. data/doc/files/lib/atom/xml_rb.html +110 -0
  29. data/doc/files/lib/atom/yaml_rb.html +109 -0
  30. data/doc/fr_class_index.html +39 -0
  31. data/doc/fr_file_index.html +36 -0
  32. data/doc/fr_method_index.html +62 -0
  33. data/doc/index.html +24 -0
  34. data/doc/rdoc-style.css +208 -0
  35. data/lib/atom/app.rb +87 -0
  36. data/lib/atom/collection.rb +75 -0
  37. data/lib/atom/element.rb +277 -0
  38. data/lib/atom/entry.rb +135 -0
  39. data/lib/atom/feed.rb +229 -0
  40. data/lib/atom/http.rb +132 -0
  41. data/lib/atom/text.rb +163 -0
  42. data/lib/atom/xml.rb +200 -0
  43. data/lib/atom/yaml.rb +101 -0
  44. data/setup.rb +1585 -0
  45. data/test/conformance/order.rb +117 -0
  46. data/test/conformance/title.rb +108 -0
  47. data/test/conformance/updated.rb +33 -0
  48. data/test/conformance/xhtmlcontentdiv.rb +18 -0
  49. data/test/conformance/xmlnamespace.rb +54 -0
  50. data/test/runtests.rb +14 -0
  51. data/test/test_constructs.rb +91 -0
  52. data/test/test_feed.rb +128 -0
  53. data/test/test_general.rb +99 -0
  54. data/test/test_http.rb +86 -0
  55. data/test/test_protocol.rb +69 -0
  56. data/test/test_xml.rb +353 -0
  57. metadata +107 -0
@@ -0,0 +1,585 @@
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::Feed</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::Feed</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/atom/feed_rb.html">
59
+ lib/atom/feed.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="Element.html">
69
+ Atom::Element
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+ <div id="description">
84
+ <p>
85
+ A feed of entries. As an <a href="Element.html">Atom::Element</a>, it can
86
+ be manipulated using accessors for each of its child elements. You can set
87
+ them with any object that makes sense; they will be returned in the types
88
+ listed.
89
+ </p>
90
+ <p>
91
+ Feeds have the following children:
92
+ </p>
93
+ <table>
94
+ <tr><td valign="top">id:</td><td>a universally unique IRI which permanently identifies the feed
95
+
96
+ </td></tr>
97
+ <tr><td valign="top">title:</td><td>a human-readable title (<a href="Text.html">Atom::Text</a>)
98
+
99
+ </td></tr>
100
+ <tr><td valign="top">subtitle:</td><td>a human-readable description or subtitle (<a
101
+ href="Text.html">Atom::Text</a>)
102
+
103
+ </td></tr>
104
+ <tr><td valign="top">updated:</td><td>the most recent Time the feed was modified in a way the publisher considers
105
+ significant
106
+
107
+ </td></tr>
108
+ <tr><td valign="top">generator:</td><td>the agent used to generate a feed
109
+
110
+ </td></tr>
111
+ <tr><td valign="top">icon:</td><td>an IRI identifying an icon which visually identifies a feed (1:1 aspect
112
+ ratio, looks OK small)
113
+
114
+ </td></tr>
115
+ <tr><td valign="top">logo:</td><td>an IRI identifying an image which visually identifies a feed (2:1 aspect
116
+ ratio)
117
+
118
+ </td></tr>
119
+ <tr><td valign="top">rights:</td><td>rights held in and over a feed (<a href="Text.html">Atom::Text</a>)
120
+
121
+ </td></tr>
122
+ </table>
123
+ <p>
124
+ There are also <tt>links</tt>, <tt>categories</tt>, <tt>authors</tt>,
125
+ <tt>contributors</tt> and <tt>entries</tt>, each of which is an Array of
126
+ its respective type and can be used thusly:
127
+ </p>
128
+ <pre>
129
+ entry = feed.entries.new
130
+ entry.title = &quot;blah blah blah&quot;
131
+ </pre>
132
+
133
+ </div>
134
+
135
+
136
+ </div>
137
+
138
+ <div id="method-list">
139
+ <h3 class="section-bar">Methods</h3>
140
+
141
+ <div class="name-list">
142
+ <a href="#M000015">&lt;&lt;</a>&nbsp;&nbsp;
143
+ <a href="#M000009">each</a>&nbsp;&nbsp;
144
+ <a href="#M000010">get_everything!</a>&nbsp;&nbsp;
145
+ <a href="#M000013">merge</a>&nbsp;&nbsp;
146
+ <a href="#M000012">merge!</a>&nbsp;&nbsp;
147
+ <a href="#M000011">merge_entries!</a>&nbsp;&nbsp;
148
+ <a href="#M000008">new</a>&nbsp;&nbsp;
149
+ <a href="#M000007">parse</a>&nbsp;&nbsp;
150
+ <a href="#M000014">update!</a>&nbsp;&nbsp;
151
+ </div>
152
+ </div>
153
+
154
+ </div>
155
+
156
+
157
+ <!-- if includes -->
158
+ <div id="includes">
159
+ <h3 class="section-bar">Included Modules</h3>
160
+
161
+ <div id="includes-list">
162
+ <span class="include-name">Enumerable</span>
163
+ </div>
164
+ </div>
165
+
166
+ <div id="section">
167
+
168
+
169
+
170
+
171
+
172
+ <div id="attribute-list">
173
+ <h3 class="section-bar">Attributes</h3>
174
+
175
+ <div class="name-list">
176
+ <table>
177
+ <tr class="top-aligned-row context-row">
178
+ <td class="context-item-name">etag</td>
179
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
180
+ <td class="context-item-desc">
181
+ conditional get information from the last fetch
182
+
183
+ </td>
184
+ </tr>
185
+ <tr class="top-aligned-row context-row">
186
+ <td class="context-item-name">last_modified</td>
187
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
188
+ <td class="context-item-desc">
189
+ conditional get information from the last fetch
190
+
191
+ </td>
192
+ </tr>
193
+ <tr class="top-aligned-row context-row">
194
+ <td class="context-item-name">next</td>
195
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
196
+ <td class="context-item-desc">
197
+ the <a href="Feed.html">Atom::Feed</a> pointed to by
198
+ link[@rel=&#8217;next&#8217;]
199
+
200
+ </td>
201
+ </tr>
202
+ <tr class="top-aligned-row context-row">
203
+ <td class="context-item-name">prev</td>
204
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
205
+ <td class="context-item-desc">
206
+ the <a href="Feed.html">Atom::Feed</a> pointed to by
207
+ link[@rel=&#8217;previous&#8217;]
208
+
209
+ </td>
210
+ </tr>
211
+ <tr class="top-aligned-row context-row">
212
+ <td class="context-item-name">uri</td>
213
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
214
+ <td class="context-item-desc"></td>
215
+ </tr>
216
+ </table>
217
+ </div>
218
+ </div>
219
+
220
+
221
+
222
+ <!-- if method_list -->
223
+ <div id="methods">
224
+ <h3 class="section-bar">Public Class methods</h3>
225
+
226
+ <div id="method-M000008" class="method-detail">
227
+ <a name="M000008"></a>
228
+
229
+ <div class="method-heading">
230
+ <a href="#M000008" class="method-signature">
231
+ <span class="method-name">new</span><span class="method-args">(feed_uri = nil, http = Atom::HTTP.new)</span>
232
+ </a>
233
+ </div>
234
+
235
+ <div class="method-description">
236
+ <p>
237
+ Create a new <a href="Feed.html">Feed</a> that can be found at feed_uri and
238
+ retrieved using an <a href="HTTP.html">Atom::HTTP</a> object http
239
+ </p>
240
+ <p><a class="source-toggle" href="#"
241
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
242
+ <div class="method-source-code" id="M000008-source">
243
+ <pre>
244
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 82</span>
245
+ 82: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">feed_uri</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">http</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>
246
+ 83: <span class="ruby-ivar">@entries</span> = []
247
+ 84: <span class="ruby-ivar">@http</span> = <span class="ruby-identifier">http</span>
248
+ 85:
249
+ 86: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feed_uri</span>
250
+ 87: <span class="ruby-ivar">@uri</span> = <span class="ruby-identifier">feed_uri</span>.<span class="ruby-identifier">to_uri</span>
251
+ 88: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">base</span> = <span class="ruby-identifier">feed_uri</span>
252
+ 89: <span class="ruby-keyword kw">end</span>
253
+ 90:
254
+ 91: <span class="ruby-keyword kw">super</span> <span class="ruby-value str">&quot;feed&quot;</span>
255
+ 92: <span class="ruby-keyword kw">end</span>
256
+ </pre>
257
+ </div>
258
+ </div>
259
+ </div>
260
+
261
+ <div id="method-M000007" class="method-detail">
262
+ <a name="M000007"></a>
263
+
264
+ <div class="method-heading">
265
+ <a href="#M000007" class="method-signature">
266
+ <span class="method-name">parse</span><span class="method-args">(xml, base = &quot;&quot;)</span>
267
+ </a>
268
+ </div>
269
+
270
+ <div class="method-description">
271
+ <p>
272
+ parses XML fetched from <tt>base</tt> into an <a
273
+ href="Feed.html">Atom::Feed</a>
274
+ </p>
275
+ <p><a class="source-toggle" href="#"
276
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
277
+ <div class="method-source-code" id="M000007-source">
278
+ <pre>
279
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 72</span>
280
+ 72: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">xml</span>, <span class="ruby-identifier">base</span> = <span class="ruby-value str">&quot;&quot;</span>
281
+ 73: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:to_atom_entry</span>
282
+ 74: <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">to_atom_feed</span>(<span class="ruby-identifier">base</span>)
283
+ 75: <span class="ruby-keyword kw">else</span>
284
+ 76: <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_atom_feed</span>(<span class="ruby-identifier">base</span>)
285
+ 77: <span class="ruby-keyword kw">end</span>
286
+ 78: <span class="ruby-keyword kw">end</span>
287
+ </pre>
288
+ </div>
289
+ </div>
290
+ </div>
291
+
292
+ <h3 class="section-bar">Public Instance methods</h3>
293
+
294
+ <div id="method-M000015" class="method-detail">
295
+ <a name="M000015"></a>
296
+
297
+ <div class="method-heading">
298
+ <a href="#M000015" class="method-signature">
299
+ <span class="method-name">&lt;&lt;</span><span class="method-args">(entry)</span>
300
+ </a>
301
+ </div>
302
+
303
+ <div class="method-description">
304
+ <p>
305
+ adds an entry to this feed. if this feed already contains an entry with the
306
+ same id, the newest one is used.
307
+ </p>
308
+ <p><a class="source-toggle" href="#"
309
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
310
+ <div class="method-source-code" id="M000015-source">
311
+ <pre>
312
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 214</span>
313
+ 214: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">entry</span>
314
+ 215: <span class="ruby-identifier">existing</span> = <span class="ruby-identifier">entries</span>.<span class="ruby-identifier">find</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
315
+ 216: <span class="ruby-identifier">e</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">id</span>
316
+ 217: <span class="ruby-keyword kw">end</span>
317
+ 218:
318
+ 219: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">existing</span>
319
+ 220: <span class="ruby-ivar">@entries</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">entry</span>
320
+ 221: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">existing</span>.<span class="ruby-identifier">updated</span> <span class="ruby-keyword kw">or</span> (<span class="ruby-identifier">existing</span>.<span class="ruby-identifier">updated</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">updated</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">updated</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">existing</span>.<span class="ruby-identifier">updated</span>)
321
+ 222: <span class="ruby-ivar">@entries</span>[<span class="ruby-ivar">@entries</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">existing</span>)] = <span class="ruby-identifier">entry</span>
322
+ 223: <span class="ruby-keyword kw">end</span>
323
+ 224: <span class="ruby-keyword kw">end</span>
324
+ </pre>
325
+ </div>
326
+ </div>
327
+ </div>
328
+
329
+ <div id="method-M000009" class="method-detail">
330
+ <a name="M000009"></a>
331
+
332
+ <div class="method-heading">
333
+ <a href="#M000009" class="method-signature">
334
+ <span class="method-name">each</span><span class="method-args">(&amp;block)</span>
335
+ </a>
336
+ </div>
337
+
338
+ <div class="method-description">
339
+ <p>
340
+ iterates over a feed&#8217;s entries
341
+ </p>
342
+ <p><a class="source-toggle" href="#"
343
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
344
+ <div class="method-source-code" id="M000009-source">
345
+ <pre>
346
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 95</span>
347
+ 95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
348
+ 96: <span class="ruby-ivar">@entries</span>.<span class="ruby-identifier">each</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
349
+ 97: <span class="ruby-keyword kw">end</span>
350
+ </pre>
351
+ </div>
352
+ </div>
353
+ </div>
354
+
355
+ <div id="method-M000010" class="method-detail">
356
+ <a name="M000010"></a>
357
+
358
+ <div class="method-heading">
359
+ <a href="#M000010" class="method-signature">
360
+ <span class="method-name">get_everything!</span><span class="method-args">()</span>
361
+ </a>
362
+ </div>
363
+
364
+ <div class="method-description">
365
+ <p>
366
+ gets everything in the logical feed (could be a lot of stuff) (see &lt;<a
367
+ href="http://www.ietf.org/internet-drafts/draft-nottingham-atompub-feed-history-05.txt">www.ietf.org/internet-drafts/draft-nottingham-atompub-feed-history-05.txt</a>&gt;)
368
+ </p>
369
+ <p><a class="source-toggle" href="#"
370
+ onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
371
+ <div class="method-source-code" id="M000010-source">
372
+ <pre>
373
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 101</span>
374
+ 101: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_everything!</span>
375
+ 102: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">update!</span>
376
+ 103:
377
+ 104: <span class="ruby-identifier">prev</span> = <span class="ruby-ivar">@prev</span>
378
+ 105: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">prev</span>
379
+ 106: <span class="ruby-identifier">prev</span>.<span class="ruby-identifier">update!</span>
380
+ 107:
381
+ 108: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">merge_entries!</span> <span class="ruby-identifier">prev</span>
382
+ 109: <span class="ruby-identifier">prev</span> = <span class="ruby-identifier">prev</span>.<span class="ruby-identifier">prev</span>
383
+ 110: <span class="ruby-keyword kw">end</span>
384
+ 111:
385
+ 112: <span class="ruby-identifier">nxt</span> = <span class="ruby-ivar">@next</span>
386
+ 113: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">nxt</span>
387
+ 114: <span class="ruby-identifier">nxt</span>.<span class="ruby-identifier">update!</span>
388
+ 115:
389
+ 116: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">merge_entries!</span> <span class="ruby-identifier">nxt</span>
390
+ 117: <span class="ruby-identifier">nxt</span> = <span class="ruby-identifier">nxt</span>.<span class="ruby-identifier">next</span>
391
+ 118: <span class="ruby-keyword kw">end</span>
392
+ 119:
393
+ 120: <span class="ruby-keyword kw">self</span>
394
+ 121: <span class="ruby-keyword kw">end</span>
395
+ </pre>
396
+ </div>
397
+ </div>
398
+ </div>
399
+
400
+ <div id="method-M000013" class="method-detail">
401
+ <a name="M000013"></a>
402
+
403
+ <div class="method-heading">
404
+ <a href="#M000013" class="method-signature">
405
+ <span class="method-name">merge</span><span class="method-args">(other_feed)</span>
406
+ </a>
407
+ </div>
408
+
409
+ <div class="method-description">
410
+ <p>
411
+ merges &quot;important&quot; properties of this feed with another one,
412
+ returning a new feed
413
+ </p>
414
+ <p><a class="source-toggle" href="#"
415
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
416
+ <div class="method-source-code" id="M000013-source">
417
+ <pre>
418
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 148</span>
419
+ 148: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span> <span class="ruby-identifier">other_feed</span>
420
+ 149: <span class="ruby-identifier">feed</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">clone</span>
421
+ 150:
422
+ 151: <span class="ruby-identifier">feed</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">other_feed</span>
423
+ 152:
424
+ 153: <span class="ruby-identifier">feed</span>
425
+ 154: <span class="ruby-keyword kw">end</span>
426
+ </pre>
427
+ </div>
428
+ </div>
429
+ </div>
430
+
431
+ <div id="method-M000012" class="method-detail">
432
+ <a name="M000012"></a>
433
+
434
+ <div class="method-heading">
435
+ <a href="#M000012" class="method-signature">
436
+ <span class="method-name">merge!</span><span class="method-args">(other_feed)</span>
437
+ </a>
438
+ </div>
439
+
440
+ <div class="method-description">
441
+ <p>
442
+ like <a href="Feed.html#M000013">merge</a>, but in place
443
+ </p>
444
+ <p><a class="source-toggle" href="#"
445
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
446
+ <div class="method-source-code" id="M000012-source">
447
+ <pre>
448
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 132</span>
449
+ 132: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge!</span> <span class="ruby-identifier">other_feed</span>
450
+ 133: [<span class="ruby-identifier">:id</span>, <span class="ruby-identifier">:title</span>, <span class="ruby-identifier">:subtitle</span>, <span class="ruby-identifier">:updated</span>, <span class="ruby-identifier">:rights</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
451
+ 134: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{p}=&quot;</span>, <span class="ruby-identifier">other_feed</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{p}&quot;</span>))
452
+ 135: }
453
+ 136:
454
+ 137: [<span class="ruby-identifier">:links</span>, <span class="ruby-identifier">:categories</span>, <span class="ruby-identifier">:authors</span>, <span class="ruby-identifier">:contributors</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
455
+ 138: <span class="ruby-identifier">other_feed</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{p}&quot;</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
456
+ 139: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{p}&quot;</span>) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>
457
+ 140: <span class="ruby-keyword kw">end</span>
458
+ 141: <span class="ruby-keyword kw">end</span>
459
+ 142:
460
+ 143: <span class="ruby-identifier">merge_entries!</span> <span class="ruby-identifier">other_feed</span>
461
+ 144: <span class="ruby-keyword kw">end</span>
462
+ </pre>
463
+ </div>
464
+ </div>
465
+ </div>
466
+
467
+ <div id="method-M000011" class="method-detail">
468
+ <a name="M000011"></a>
469
+
470
+ <div class="method-heading">
471
+ <a href="#M000011" class="method-signature">
472
+ <span class="method-name">merge_entries!</span><span class="method-args">(other_feed)</span>
473
+ </a>
474
+ </div>
475
+
476
+ <div class="method-description">
477
+ <p>
478
+ merges the entries from another feed into this one
479
+ </p>
480
+ <p><a class="source-toggle" href="#"
481
+ onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
482
+ <div class="method-source-code" id="M000011-source">
483
+ <pre>
484
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 124</span>
485
+ 124: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge_entries!</span> <span class="ruby-identifier">other_feed</span>
486
+ 125: <span class="ruby-identifier">other_feed</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
487
+ 126: <span class="ruby-comment cmt"># TODO: add atom:source elements</span>
488
+ 127: <span class="ruby-keyword kw">self</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">entry</span>
489
+ 128: <span class="ruby-keyword kw">end</span>
490
+ 129: <span class="ruby-keyword kw">end</span>
491
+ </pre>
492
+ </div>
493
+ </div>
494
+ </div>
495
+
496
+ <div id="method-M000014" class="method-detail">
497
+ <a name="M000014"></a>
498
+
499
+ <div class="method-heading">
500
+ <a href="#M000014" class="method-signature">
501
+ <span class="method-name">update!</span><span class="method-args">()</span>
502
+ </a>
503
+ </div>
504
+
505
+ <div class="method-description">
506
+ <p>
507
+ fetches this feed&#8217;s URL, parses the result and <a
508
+ href="Feed.html#M000012">merge!</a>s changes, new entries, &amp;c.
509
+ </p>
510
+ <p><a class="source-toggle" href="#"
511
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
512
+ <div class="method-source-code" id="M000014-source">
513
+ <pre>
514
+ <span class="ruby-comment cmt"># File lib/atom/feed.rb, line 158</span>
515
+ 158: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update!</span>
516
+ 159: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">&quot;can't fetch without a uri.&quot;</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@uri</span>
517
+ 160:
518
+ 161: <span class="ruby-identifier">headers</span> = {}
519
+ 162: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;If-None-Match&quot;</span>] = <span class="ruby-ivar">@etag</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@etag</span>
520
+ 163: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;If-Modified-Since&quot;</span>] = <span class="ruby-ivar">@last_modified</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@last_modified</span>
521
+ 164:
522
+ 165: <span class="ruby-identifier">res</span> = <span class="ruby-ivar">@http</span>.<span class="ruby-identifier">get</span>(<span class="ruby-ivar">@uri</span>, <span class="ruby-identifier">headers</span>)
523
+ 166:
524
+ 167: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;304&quot;</span>
525
+ 168: <span class="ruby-comment cmt"># we're already all up to date</span>
526
+ 169: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
527
+ 170: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;410&quot;</span>
528
+ 171: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">FeedGone</span>, <span class="ruby-node">&quot;410 Gone (#{@uri})&quot;</span>
529
+ 172: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;200&quot;</span>
530
+ 173: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPException</span>, <span class="ruby-node">&quot;Unexpected HTTP response code: #{res.code}&quot;</span>
531
+ 174: <span class="ruby-keyword kw">end</span>
532
+ 175:
533
+ 176: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/^application\/atom\+xml/</span>)
534
+ 177: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPException</span>, <span class="ruby-node">&quot;Unexpected HTTP response Content-Type: #{res.content_type} (wanted application/atom+xml)&quot;</span>
535
+ 178: <span class="ruby-keyword kw">end</span>
536
+ 179:
537
+ 180: <span class="ruby-ivar">@etag</span> = <span class="ruby-identifier">res</span>[<span class="ruby-value str">&quot;Etag&quot;</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>[<span class="ruby-value str">&quot;Etag&quot;</span>]
538
+ 181: <span class="ruby-ivar">@last_modified</span> = <span class="ruby-identifier">res</span>[<span class="ruby-value str">&quot;Last-Modified&quot;</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>[<span class="ruby-value str">&quot;Last-Modified&quot;</span>]
539
+ 182:
540
+ 183: <span class="ruby-identifier">xml</span> = <span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>
541
+ 184:
542
+ 185: <span class="ruby-identifier">coll</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml</span>)
543
+ 186:
544
+ 187: <span class="ruby-identifier">update_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-identifier">coll</span>, <span class="ruby-value str">&quot;/atom:feed/atom:updated&quot;</span>, { <span class="ruby-value str">&quot;atom&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">NS</span> } ).<span class="ruby-identifier">text</span>)
545
+ 188:
546
+ 189: <span class="ruby-comment cmt"># the feed hasn't been updated, don't bother</span>
547
+ 190: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">updated</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">updated</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">update_time</span>
548
+ 191: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
549
+ 192: <span class="ruby-keyword kw">end</span>
550
+ 193:
551
+ 194: <span class="ruby-identifier">coll</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Feed</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">coll</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">base</span>.<span class="ruby-identifier">to_s</span>)
552
+ 195: <span class="ruby-identifier">merge!</span> <span class="ruby-identifier">coll</span>
553
+ 196:
554
+ 197: <span class="ruby-identifier">link</span> = <span class="ruby-identifier">coll</span>.<span class="ruby-identifier">links</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>[<span class="ruby-value str">&quot;rel&quot;</span>] = <span class="ruby-value str">&quot;next&quot;</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">l</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;application/atom+xml&quot;</span> }
555
+ 198: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">link</span>
556
+ 199: <span class="ruby-identifier">abs_uri</span> = <span class="ruby-ivar">@uri</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">link</span>[<span class="ruby-value str">&quot;href&quot;</span>]
557
+ 200: <span class="ruby-ivar">@next</span> = <span class="ruby-constant">Feed</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">abs_uri</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-ivar">@http</span>)
558
+ 201: <span class="ruby-keyword kw">end</span>
559
+ 202:
560
+ 203: <span class="ruby-identifier">link</span> = <span class="ruby-identifier">coll</span>.<span class="ruby-identifier">links</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>[<span class="ruby-value str">&quot;rel&quot;</span>] = <span class="ruby-value str">&quot;previous&quot;</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">l</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;application/atom+xml&quot;</span> }
561
+ 204: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">link</span>
562
+ 205: <span class="ruby-identifier">abs_uri</span> = <span class="ruby-ivar">@uri</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">link</span>[<span class="ruby-value str">&quot;href&quot;</span>]
563
+ 206: <span class="ruby-ivar">@prev</span> = <span class="ruby-constant">Feed</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">abs_uri</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-ivar">@http</span>)
564
+ 207: <span class="ruby-keyword kw">end</span>
565
+ 208:
566
+ 209: <span class="ruby-keyword kw">self</span>
567
+ 210: <span class="ruby-keyword kw">end</span>
568
+ </pre>
569
+ </div>
570
+ </div>
571
+ </div>
572
+
573
+
574
+ </div>
575
+
576
+
577
+ </div>
578
+
579
+
580
+ <div id="validator-badges">
581
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
582
+ </div>
583
+
584
+ </body>
585
+ </html>