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.
- data/README +3 -3
- data/Rakefile +1 -1
- data/bin/atom-client.rb +13 -10
- data/lib/atom/collection.rb +2 -2
- data/lib/atom/element.rb +5 -1
- data/lib/atom/entry.rb +9 -2
- data/lib/atom/feed.rb +11 -6
- data/lib/atom/http.rb +157 -38
- data/lib/atom/service.rb +170 -0
- data/lib/atom/text.rb +15 -2
- data/lib/atom/xml.rb +1 -1
- data/test/conformance/updated.rb +2 -1
- data/test/test_constructs.rb +45 -2
- data/test/test_feed.rb +27 -0
- data/test/test_http.rb +116 -20
- data/test/test_protocol.rb +77 -13
- data/test/test_xml.rb +15 -1
- metadata +3 -38
- data/bin/atom-server.rb~ +0 -71
- data/doc/classes/Atom/App.html +0 -217
- data/doc/classes/Atom/Author.html +0 -130
- data/doc/classes/Atom/Category.html +0 -128
- data/doc/classes/Atom/Collection.html +0 -322
- data/doc/classes/Atom/Content.html +0 -129
- data/doc/classes/Atom/Contributor.html +0 -119
- data/doc/classes/Atom/Element.html +0 -325
- data/doc/classes/Atom/Entry.html +0 -365
- data/doc/classes/Atom/Feed.html +0 -585
- data/doc/classes/Atom/HTTP.html +0 -374
- data/doc/classes/Atom/Link.html +0 -137
- data/doc/classes/Atom/Text.html +0 -229
- data/doc/classes/XHTML.html +0 -118
- data/doc/created.rid +0 -1
- data/doc/files/README.html +0 -213
- data/doc/files/lib/atom/app_rb.html +0 -110
- data/doc/files/lib/atom/collection_rb.html +0 -110
- data/doc/files/lib/atom/element_rb.html +0 -109
- data/doc/files/lib/atom/entry_rb.html +0 -111
- data/doc/files/lib/atom/feed_rb.html +0 -112
- data/doc/files/lib/atom/http_rb.html +0 -109
- data/doc/files/lib/atom/text_rb.html +0 -108
- data/doc/files/lib/atom/xml_rb.html +0 -110
- data/doc/files/lib/atom/yaml_rb.html +0 -109
- data/doc/fr_class_index.html +0 -39
- data/doc/fr_file_index.html +0 -36
- data/doc/fr_method_index.html +0 -62
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
- data/lib/atom/app.rb +0 -87
data/doc/classes/Atom/Entry.html
DELETED
@@ -1,365 +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::Entry</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::Entry</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/app_rb.html">
|
63
|
-
lib/atom/app.rb
|
64
|
-
</a>
|
65
|
-
<br />
|
66
|
-
<a href="../../files/lib/atom/entry_rb.html">
|
67
|
-
lib/atom/entry.rb
|
68
|
-
</a>
|
69
|
-
<br />
|
70
|
-
</td>
|
71
|
-
</tr>
|
72
|
-
|
73
|
-
<tr class="top-aligned-row">
|
74
|
-
<td><strong>Parent:</strong></td>
|
75
|
-
<td>
|
76
|
-
Object
|
77
|
-
</td>
|
78
|
-
</tr>
|
79
|
-
</table>
|
80
|
-
</div>
|
81
|
-
<!-- banner header -->
|
82
|
-
|
83
|
-
<div id="bodyContent">
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<div id="contextContent">
|
88
|
-
|
89
|
-
<div id="description">
|
90
|
-
<p>
|
91
|
-
An individual entry in a feed. As an <a
|
92
|
-
href="Element.html">Atom::Element</a>, it can be manipulated using
|
93
|
-
accessors for each of its child elements. You should be able to set them
|
94
|
-
using an instance of any class that makes sense
|
95
|
-
</p>
|
96
|
-
<p>
|
97
|
-
Entries have the following children:
|
98
|
-
</p>
|
99
|
-
<table>
|
100
|
-
<tr><td valign="top">id:</td><td>a universally unique IRI which permanently identifies the entry
|
101
|
-
|
102
|
-
</td></tr>
|
103
|
-
<tr><td valign="top">title:</td><td>a human-readable title (<a href="Text.html">Atom::Text</a>)
|
104
|
-
|
105
|
-
</td></tr>
|
106
|
-
<tr><td valign="top">content:</td><td>contains or links to the content of an entry (<a
|
107
|
-
href="Content.html">Atom::Content</a>)
|
108
|
-
|
109
|
-
</td></tr>
|
110
|
-
<tr><td valign="top">rights:</td><td>information about rights held in and over an entry (<a
|
111
|
-
href="Text.html">Atom::Text</a>)
|
112
|
-
|
113
|
-
</td></tr>
|
114
|
-
<tr><td valign="top">source:</td><td>the source feed’s metadata (unimplemented)
|
115
|
-
|
116
|
-
</td></tr>
|
117
|
-
<tr><td valign="top">published:</td><td>a Time "early in the life cycle of an entry"
|
118
|
-
|
119
|
-
</td></tr>
|
120
|
-
<tr><td valign="top">updated:</td><td>the most recent Time an entry was modified in a way the publisher considers
|
121
|
-
significant
|
122
|
-
|
123
|
-
</td></tr>
|
124
|
-
<tr><td valign="top">summary:</td><td>a summary, abstract or excerpt of an entry (<a
|
125
|
-
href="Text.html">Atom::Text</a>)
|
126
|
-
|
127
|
-
</td></tr>
|
128
|
-
</table>
|
129
|
-
<p>
|
130
|
-
There are also <tt>categories</tt>, <tt>links</tt>, <tt>authors</tt> and
|
131
|
-
<tt>contributors</tt>, each of which is an Array of its respective type and
|
132
|
-
can be used thusly:
|
133
|
-
</p>
|
134
|
-
<pre>
|
135
|
-
author = entry.authors.new
|
136
|
-
author.name = "Captain Kangaroo"
|
137
|
-
</pre>
|
138
|
-
|
139
|
-
</div>
|
140
|
-
|
141
|
-
|
142
|
-
</div>
|
143
|
-
|
144
|
-
<div id="method-list">
|
145
|
-
<h3 class="section-bar">Methods</h3>
|
146
|
-
|
147
|
-
<div class="name-list">
|
148
|
-
<a href="#M000002">edit_url</a>
|
149
|
-
<a href="#M000001">from_yaml</a>
|
150
|
-
<a href="#M000003">parse</a>
|
151
|
-
<a href="#M000005">tag_with</a>
|
152
|
-
<a href="#M000004">updated!</a>
|
153
|
-
</div>
|
154
|
-
</div>
|
155
|
-
|
156
|
-
</div>
|
157
|
-
|
158
|
-
|
159
|
-
<!-- if includes -->
|
160
|
-
|
161
|
-
<div id="section">
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
<!-- if method_list -->
|
171
|
-
<div id="methods">
|
172
|
-
<h3 class="section-bar">Public Class methods</h3>
|
173
|
-
|
174
|
-
<div id="method-M000001" class="method-detail">
|
175
|
-
<a name="M000001"></a>
|
176
|
-
|
177
|
-
<div class="method-heading">
|
178
|
-
<a href="#M000001" class="method-signature">
|
179
|
-
<span class="method-name">from_yaml</span><span class="method-args">(yaml)</span>
|
180
|
-
</a>
|
181
|
-
</div>
|
182
|
-
|
183
|
-
<div class="method-description">
|
184
|
-
<p>
|
185
|
-
parses an <a href="Entry.html">Atom::Entry</a> from YAML
|
186
|
-
</p>
|
187
|
-
<p><a class="source-toggle" href="#"
|
188
|
-
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
189
|
-
<div class="method-source-code" id="M000001-source">
|
190
|
-
<pre>
|
191
|
-
<span class="ruby-comment cmt"># File lib/atom/yaml.rb, line 67</span>
|
192
|
-
67: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_yaml</span> <span class="ruby-identifier">yaml</span>
|
193
|
-
68: <span class="ruby-identifier">hash</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">yaml</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>); <span class="ruby-identifier">yaml</span> <span class="ruby-keyword kw">else</span> <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">yaml</span>); <span class="ruby-keyword kw">end</span>
|
194
|
-
69:
|
195
|
-
70: <span class="ruby-identifier">entry</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Entry</span>.<span class="ruby-identifier">new</span>
|
196
|
-
71:
|
197
|
-
72: <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">title</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">"title"</span>]
|
198
|
-
73: <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">summary</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">"summary"</span>]
|
199
|
-
74:
|
200
|
-
75: <span class="ruby-identifier">elem_constructs</span> = {<span class="ruby-value str">"authors"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">authors</span>, <span class="ruby-value str">"contributors"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">contributors</span>, <span class="ruby-value str">"links"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">links</span>, <span class="ruby-value str">"categories"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">categories</span>}
|
201
|
-
76:
|
202
|
-
77: <span class="ruby-identifier">elem_constructs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span>,<span class="ruby-identifier">ary</span><span class="ruby-operator">|</span>
|
203
|
-
78: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">type</span>] <span class="ruby-operator">||=</span> []
|
204
|
-
79:
|
205
|
-
80: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">type</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">yelem</span><span class="ruby-operator">|</span>
|
206
|
-
81: <span class="ruby-identifier">elem</span> = <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">new</span>
|
207
|
-
82:
|
208
|
-
83: <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attrb</span>,<span class="ruby-identifier">req</span><span class="ruby-operator">|</span>
|
209
|
-
84: <span class="ruby-identifier">elem</span>[<span class="ruby-identifier">attrb</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">yelem</span>[<span class="ruby-identifier">attrb</span>.<span class="ruby-identifier">to_s</span>]
|
210
|
-
85: <span class="ruby-keyword kw">end</span>
|
211
|
-
86:
|
212
|
-
87: <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">elements</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>,<span class="ruby-identifier">kind</span>,<span class="ruby-identifier">req</span><span class="ruby-operator">|</span>
|
213
|
-
88: <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">"#{name}="</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-identifier">yelem</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>])
|
214
|
-
89: <span class="ruby-keyword kw">end</span>
|
215
|
-
90: <span class="ruby-keyword kw">end</span>
|
216
|
-
91: <span class="ruby-keyword kw">end</span>
|
217
|
-
92:
|
218
|
-
93: <span class="ruby-comment cmt"># this adds more categories, and could cause conflicts</span>
|
219
|
-
94: <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">tag_with</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">"tags"</span>]
|
220
|
-
95: <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">content</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">"content"</span>]
|
221
|
-
96: <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">content</span>[<span class="ruby-value str">"type"</span>] = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">"type"</span>]
|
222
|
-
97:
|
223
|
-
98: <span class="ruby-identifier">entry</span>
|
224
|
-
99: <span class="ruby-keyword kw">end</span>
|
225
|
-
</pre>
|
226
|
-
</div>
|
227
|
-
</div>
|
228
|
-
</div>
|
229
|
-
|
230
|
-
<div id="method-M000003" class="method-detail">
|
231
|
-
<a name="M000003"></a>
|
232
|
-
|
233
|
-
<div class="method-heading">
|
234
|
-
<a href="#M000003" class="method-signature">
|
235
|
-
<span class="method-name">parse</span><span class="method-args">(xml, base = "")</span>
|
236
|
-
</a>
|
237
|
-
</div>
|
238
|
-
|
239
|
-
<div class="method-description">
|
240
|
-
<p>
|
241
|
-
parses XML fetched from <tt>base</tt> into an <a
|
242
|
-
href="Entry.html">Atom::Entry</a>
|
243
|
-
</p>
|
244
|
-
<p><a class="source-toggle" href="#"
|
245
|
-
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
246
|
-
<div class="method-source-code" id="M000003-source">
|
247
|
-
<pre>
|
248
|
-
<span class="ruby-comment cmt"># File lib/atom/entry.rb, line 59</span>
|
249
|
-
59: <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">""</span>
|
250
|
-
60: <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>
|
251
|
-
61: <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">to_atom_entry</span>(<span class="ruby-identifier">base</span>)
|
252
|
-
62: <span class="ruby-keyword kw">else</span>
|
253
|
-
63: <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_entry</span>(<span class="ruby-identifier">base</span>)
|
254
|
-
64: <span class="ruby-keyword kw">end</span>
|
255
|
-
65: <span class="ruby-keyword kw">end</span>
|
256
|
-
</pre>
|
257
|
-
</div>
|
258
|
-
</div>
|
259
|
-
</div>
|
260
|
-
|
261
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
262
|
-
|
263
|
-
<div id="method-M000002" class="method-detail">
|
264
|
-
<a name="M000002"></a>
|
265
|
-
|
266
|
-
<div class="method-heading">
|
267
|
-
<a href="#M000002" class="method-signature">
|
268
|
-
<span class="method-name">edit_url</span><span class="method-args">()</span>
|
269
|
-
</a>
|
270
|
-
</div>
|
271
|
-
|
272
|
-
<div class="method-description">
|
273
|
-
<p>
|
274
|
-
the @href of an entry’s link[@rel="edit"]
|
275
|
-
</p>
|
276
|
-
<p><a class="source-toggle" href="#"
|
277
|
-
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
278
|
-
<div class="method-source-code" id="M000002-source">
|
279
|
-
<pre>
|
280
|
-
<span class="ruby-comment cmt"># File lib/atom/app.rb, line 75</span>
|
281
|
-
75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">edit_url</span>
|
282
|
-
76: <span class="ruby-keyword kw">begin</span>
|
283
|
-
77: <span class="ruby-identifier">edit_link</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">links</span>.<span class="ruby-identifier">find</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">link</span><span class="ruby-operator">|</span>
|
284
|
-
78: <span class="ruby-identifier">link</span>[<span class="ruby-value str">"rel"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"edit"</span>
|
285
|
-
79: <span class="ruby-keyword kw">end</span>
|
286
|
-
80:
|
287
|
-
81: <span class="ruby-identifier">edit_link</span>[<span class="ruby-value str">"href"</span>]
|
288
|
-
82: <span class="ruby-keyword kw">rescue</span>
|
289
|
-
83: <span class="ruby-keyword kw">nil</span>
|
290
|
-
84: <span class="ruby-keyword kw">end</span>
|
291
|
-
85: <span class="ruby-keyword kw">end</span>
|
292
|
-
</pre>
|
293
|
-
</div>
|
294
|
-
</div>
|
295
|
-
</div>
|
296
|
-
|
297
|
-
<div id="method-M000005" class="method-detail">
|
298
|
-
<a name="M000005"></a>
|
299
|
-
|
300
|
-
<div class="method-heading">
|
301
|
-
<a href="#M000005" class="method-signature">
|
302
|
-
<span class="method-name">tag_with</span><span class="method-args">(string)</span>
|
303
|
-
</a>
|
304
|
-
</div>
|
305
|
-
|
306
|
-
<div class="method-description">
|
307
|
-
<p>
|
308
|
-
categorize the entry based on a space-separated string
|
309
|
-
</p>
|
310
|
-
<p><a class="source-toggle" href="#"
|
311
|
-
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
312
|
-
<div class="method-source-code" id="M000005-source">
|
313
|
-
<pre>
|
314
|
-
<span class="ruby-comment cmt"># File lib/atom/entry.rb, line 77</span>
|
315
|
-
77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tag_with</span> <span class="ruby-identifier">string</span>
|
316
|
-
78: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">nil?</span>
|
317
|
-
79:
|
318
|
-
80: <span class="ruby-identifier">string</span>.<span class="ruby-identifier">split</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">tag</span><span class="ruby-operator">|</span>
|
319
|
-
81: <span class="ruby-identifier">categories</span>.<span class="ruby-identifier">new</span>[<span class="ruby-value str">"term"</span>] = <span class="ruby-identifier">tag</span>
|
320
|
-
82: <span class="ruby-keyword kw">end</span>
|
321
|
-
83: <span class="ruby-keyword kw">end</span>
|
322
|
-
</pre>
|
323
|
-
</div>
|
324
|
-
</div>
|
325
|
-
</div>
|
326
|
-
|
327
|
-
<div id="method-M000004" class="method-detail">
|
328
|
-
<a name="M000004"></a>
|
329
|
-
|
330
|
-
<div class="method-heading">
|
331
|
-
<a href="#M000004" class="method-signature">
|
332
|
-
<span class="method-name">updated!</span><span class="method-args">()</span>
|
333
|
-
</a>
|
334
|
-
</div>
|
335
|
-
|
336
|
-
<div class="method-description">
|
337
|
-
<p>
|
338
|
-
declare that this entry has updated
|
339
|
-
</p>
|
340
|
-
<p><a class="source-toggle" href="#"
|
341
|
-
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
342
|
-
<div class="method-source-code" id="M000004-source">
|
343
|
-
<pre>
|
344
|
-
<span class="ruby-comment cmt"># File lib/atom/entry.rb, line 72</span>
|
345
|
-
72: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">updated!</span>
|
346
|
-
73: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">updated</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
347
|
-
74: <span class="ruby-keyword kw">end</span>
|
348
|
-
</pre>
|
349
|
-
</div>
|
350
|
-
</div>
|
351
|
-
</div>
|
352
|
-
|
353
|
-
|
354
|
-
</div>
|
355
|
-
|
356
|
-
|
357
|
-
</div>
|
358
|
-
|
359
|
-
|
360
|
-
<div id="validator-badges">
|
361
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
362
|
-
</div>
|
363
|
-
|
364
|
-
</body>
|
365
|
-
</html>
|
data/doc/classes/Atom/Feed.html
DELETED
@@ -1,585 +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 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 = "blah blah blah"
|
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"><<</a>
|
143
|
-
<a href="#M000009">each</a>
|
144
|
-
<a href="#M000010">get_everything!</a>
|
145
|
-
<a href="#M000013">merge</a>
|
146
|
-
<a href="#M000012">merge!</a>
|
147
|
-
<a href="#M000011">merge_entries!</a>
|
148
|
-
<a href="#M000008">new</a>
|
149
|
-
<a href="#M000007">parse</a>
|
150
|
-
<a href="#M000014">update!</a>
|
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"> [R] </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"> [R] </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"> [R] </td>
|
196
|
-
<td class="context-item-desc">
|
197
|
-
the <a href="Feed.html">Atom::Feed</a> pointed to by
|
198
|
-
link[@rel=’next’]
|
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"> [R] </td>
|
205
|
-
<td class="context-item-desc">
|
206
|
-
the <a href="Feed.html">Atom::Feed</a> pointed to by
|
207
|
-
link[@rel=’previous’]
|
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"> [R] </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">"feed"</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 = "")</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">""</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"><<</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"><<</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"><<</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">>=</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">(&block)</span>
|
335
|
-
</a>
|
336
|
-
</div>
|
337
|
-
|
338
|
-
<div class="method-description">
|
339
|
-
<p>
|
340
|
-
iterates over a feed’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">&</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">&</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 <<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>>)
|
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 "important" 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">"#{p}="</span>, <span class="ruby-identifier">other_feed</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">"#{p}"</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">"#{p}"</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">"#{p}"</span>) <span class="ruby-operator"><<</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"><<</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’s URL, parses the result and <a
|
508
|
-
href="Feed.html#M000012">merge!</a>s changes, new entries, &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">"can't fetch without a uri."</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">"If-None-Match"</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">"If-Modified-Since"</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">"304"</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">"410"</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">"410 Gone (#{@uri})"</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">"200"</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">"Unexpected HTTP response code: #{res.code}"</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">"Unexpected HTTP response Content-Type: #{res.content_type} (wanted application/atom+xml)"</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">"Etag"</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>[<span class="ruby-value str">"Etag"</span>]
|
538
|
-
181: <span class="ruby-ivar">@last_modified</span> = <span class="ruby-identifier">res</span>[<span class="ruby-value str">"Last-Modified"</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>[<span class="ruby-value str">"Last-Modified"</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">"/atom:feed/atom:updated"</span>, { <span class="ruby-value str">"atom"</span> =<span class="ruby-operator">></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">>=</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">"rel"</span>] = <span class="ruby-value str">"next"</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">l</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"application/atom+xml"</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">"href"</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">"rel"</span>] = <span class="ruby-value str">"previous"</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">l</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"application/atom+xml"</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">"href"</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>
|