atom-tools 0.9.2 → 0.9.3

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