atom-tools 0.9.0 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. data/COPYING +3 -3
  2. data/README +9 -49
  3. data/Rakefile +65 -62
  4. data/bin/atom-cp +159 -0
  5. data/bin/atom-grep +78 -0
  6. data/bin/atom-post +73 -0
  7. data/bin/atom-purge +82 -0
  8. data/doc/classes/Atom/AttrEl.html +163 -0
  9. data/doc/classes/Atom/Author.html +2 -19
  10. data/doc/classes/Atom/AutodiscoveryFailure.html +111 -0
  11. data/doc/classes/Atom/Categories.html +168 -0
  12. data/doc/classes/Atom/Category.html +10 -1
  13. data/doc/classes/Atom/Collection.html +194 -91
  14. data/doc/classes/Atom/Content.html +42 -1
  15. data/doc/classes/Atom/Contributor.html +2 -8
  16. data/doc/classes/Atom/Control.html +126 -0
  17. data/doc/classes/Atom/Converters.html +571 -0
  18. data/doc/classes/Atom/DigestAuth.html +285 -0
  19. data/doc/classes/Atom/Element.html +673 -106
  20. data/doc/classes/Atom/FileCache.html +287 -0
  21. data/doc/classes/Atom/HTTP.html +211 -95
  22. data/doc/classes/Atom/HTTPResponse.html +190 -0
  23. data/doc/classes/Atom/HasCategories.html +187 -0
  24. data/doc/classes/Atom/HasLinks.html +168 -0
  25. data/doc/classes/Atom/Link.html +80 -3
  26. data/doc/classes/Atom/NilCache.html +202 -0
  27. data/doc/classes/Atom/ParseError.html +111 -0
  28. data/doc/classes/Atom/Parsers.html +311 -0
  29. data/doc/classes/Atom/Person.html +130 -0
  30. data/doc/classes/Atom/Rights.html +113 -0
  31. data/doc/classes/Atom/Service.html +298 -0
  32. data/doc/{files/lib/atom/yaml_rb.html → classes/Atom/Source.html} +26 -24
  33. data/doc/classes/Atom/Subtitle.html +113 -0
  34. data/doc/classes/Atom/Summary.html +113 -0
  35. data/doc/classes/Atom/Text.html +196 -53
  36. data/doc/classes/Atom/Title.html +113 -0
  37. data/doc/classes/Atom/Tools.html +525 -0
  38. data/doc/classes/Atom/Workspace.html +121 -0
  39. data/doc/classes/Object.html +204 -0
  40. data/doc/created.rid +1 -1
  41. data/doc/files/README.html +9 -49
  42. data/doc/files/lib/atom/cache_rb.html +302 -0
  43. data/doc/files/lib/atom/collection_rb.html +1 -2
  44. data/doc/files/lib/atom/element_rb.html +2 -1
  45. data/doc/files/lib/atom/entry_rb.html +2 -2
  46. data/doc/files/lib/atom/feed_rb.html +1 -2
  47. data/doc/files/lib/atom/http_rb.html +6 -1
  48. data/doc/files/lib/atom/{xml_rb.html → service_rb.html} +8 -6
  49. data/doc/files/lib/atom/text_rb.html +2 -1
  50. data/doc/files/lib/atom/{app_rb.html → tools_rb.html} +4 -6
  51. data/doc/fr_class_index.html +23 -3
  52. data/doc/fr_file_index.html +3 -3
  53. data/doc/fr_method_index.html +111 -36
  54. data/lib/atom/cache.rb +178 -0
  55. data/lib/atom/collection.rb +90 -40
  56. data/lib/atom/element.rb +569 -161
  57. data/lib/atom/entry.rb +63 -89
  58. data/lib/atom/feed.rb +65 -67
  59. data/lib/atom/http.rb +421 -49
  60. data/lib/atom/service.rb +106 -0
  61. data/lib/atom/text.rb +138 -61
  62. data/lib/atom/tools.rb +163 -0
  63. data/spec/entry_spec.rb +364 -0
  64. data/spec/ext_spec.rb +42 -0
  65. data/spec/feed_spec.rb +39 -0
  66. data/spec/fixtures/contacts-feed.xml +34 -0
  67. data/spec/fixtures/entry-w-ext.xml +15 -0
  68. data/spec/fixtures/entry-w-xml.xml +24 -0
  69. data/spec/fixtures/entry.xml +42 -0
  70. data/spec/fixtures/feed-w-ext.xml +33 -0
  71. data/spec/fixtures/service-w-xhtml-ns.xml +21 -0
  72. data/spec/fixtures/service.xml +36 -0
  73. data/spec/service_spec.rb +108 -0
  74. data/spec/spec_helper.rb +9 -0
  75. data/test/conformance/order.rb +11 -10
  76. data/test/conformance/title.rb +9 -9
  77. data/test/conformance/updated.rb +2 -1
  78. data/test/runtests.rb +0 -0
  79. data/test/test_constructs.rb +78 -8
  80. data/test/test_feed.rb +35 -29
  81. data/test/test_general.rb +3 -30
  82. data/test/test_http.rb +248 -34
  83. data/test/test_protocol.rb +143 -24
  84. data/test/test_xml.rb +145 -53
  85. metadata +116 -62
  86. data/bin/atom-client.rb +0 -246
  87. data/bin/atom-server.rb~ +0 -71
  88. data/doc/classes/Atom/App.html +0 -217
  89. data/doc/classes/Atom/Entry.html +0 -365
  90. data/doc/classes/Atom/Feed.html +0 -585
  91. data/lib/atom/app.rb +0 -87
  92. data/lib/atom/xml.rb +0 -200
  93. data/lib/atom/yaml.rb +0 -101
@@ -55,10 +55,6 @@
55
55
  <tr class="top-aligned-row">
56
56
  <td><strong>In:</strong></td>
57
57
  <td>
58
- <a href="../../files/lib/atom/collection_rb.html">
59
- lib/atom/collection.rb
60
- </a>
61
- <br />
62
58
  <a href="../../files/lib/atom/http_rb.html">
63
59
  lib/atom/http.rb
64
60
  </a>
@@ -69,7 +65,9 @@
69
65
  <tr class="top-aligned-row">
70
66
  <td><strong>Parent:</strong></td>
71
67
  <td>
68
+ <a href="../Object.html">
72
69
  Object
70
+ </a>
73
71
  </td>
74
72
  </tr>
75
73
  </table>
@@ -90,9 +88,9 @@ implemented).
90
88
  </p>
91
89
  <p>
92
90
  This object can be used on its own, or passed to an <a
93
- href="App.html">Atom::App</a>, <a
94
- href="Collection.html">Atom::Collection</a> or <a
95
- href="Feed.html">Atom::Feed</a>, where it will be used for requests.
91
+ href="Service.html">Atom::Service</a>, <a
92
+ href="Collection.html">Atom::Collection</a> or Atom::Feed, where it will be
93
+ used for requests.
96
94
  </p>
97
95
  <p>
98
96
  All its <a href="HTTP.html">HTTP</a> methods return a Net::HTTPResponse
@@ -107,13 +105,14 @@ All its <a href="HTTP.html">HTTP</a> methods return a Net::HTTPResponse
107
105
  <h3 class="section-bar">Methods</h3>
108
106
 
109
107
  <div class="name-list">
110
- <a href="#M000024">delete</a>&nbsp;&nbsp;
111
- <a href="#M000021">get</a>&nbsp;&nbsp;
112
- <a href="#M000019">get_atom_entry</a>&nbsp;&nbsp;
113
- <a href="#M000022">post</a>&nbsp;&nbsp;
114
- <a href="#M000023">put</a>&nbsp;&nbsp;
115
- <a href="#M000020">put_atom_entry</a>&nbsp;&nbsp;
116
- <a href="#M000025">when_auth</a>&nbsp;&nbsp;
108
+ <a href="#M000071">delete</a>&nbsp;&nbsp;
109
+ <a href="#M000068">get</a>&nbsp;&nbsp;
110
+ <a href="#M000073">get_atom_entry</a>&nbsp;&nbsp;
111
+ <a href="#M000067">new</a>&nbsp;&nbsp;
112
+ <a href="#M000069">post</a>&nbsp;&nbsp;
113
+ <a href="#M000070">put</a>&nbsp;&nbsp;
114
+ <a href="#M000074">put_atom_entry</a>&nbsp;&nbsp;
115
+ <a href="#M000072">when_auth</a>&nbsp;&nbsp;
117
116
  </div>
118
117
  </div>
119
118
 
@@ -121,6 +120,13 @@ All its <a href="HTTP.html">HTTP</a> methods return a Net::HTTPResponse
121
120
 
122
121
 
123
122
  <!-- if includes -->
123
+ <div id="includes">
124
+ <h3 class="section-bar">Included Modules</h3>
125
+
126
+ <div id="includes-list">
127
+ <span class="include-name"><a href="DigestAuth.html">DigestAuth</a></span>
128
+ </div>
129
+ </div>
124
130
 
125
131
  <div id="section">
126
132
 
@@ -133,11 +139,62 @@ All its <a href="HTTP.html">HTTP</a> methods return a Net::HTTPResponse
133
139
 
134
140
  <div class="name-list">
135
141
  <table>
142
+ <tr class="top-aligned-row context-row">
143
+ <td class="context-item-name">allow_all_redirects</td>
144
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
145
+ <td class="context-item-desc">
146
+ automatically handle redirects, even for POST/PUT/DELETE requests?
147
+
148
+ <p>
149
+ defaults to false, which will transparently redirect GET requests but
150
+ return a Net::HTTPRedirection object when the server indicates to redirect
151
+ a POST/PUT/DELETE
152
+ </p>
153
+ </td>
154
+ </tr>
155
+ <tr class="top-aligned-row context-row">
156
+ <td class="context-item-name">always_auth</td>
157
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
158
+ <td class="context-item-desc">
159
+ when set to :basic, :wsse or :authsub, this will send an Authentication
160
+ header with every request instead of waiting for a challenge from the
161
+ server.
162
+
163
+ <p>
164
+ be careful; always_auth :basic will send your username and password in
165
+ plain text to every URL this object requests.
166
+ </p>
167
+ <p>
168
+ :digest won&#8216;t work, since Digest authentication requires an initial
169
+ challenge to generate a response
170
+ </p>
171
+ <p>
172
+ defaults to nil
173
+ </p>
174
+ </td>
175
+ </tr>
136
176
  <tr class="top-aligned-row context-row">
137
177
  <td class="context-item-name">pass</td>
138
178
  <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
139
179
  <td class="context-item-desc">
140
- used by the default <a href="HTTP.html#M000025">when_auth</a>
180
+ used by the default <a href="HTTP.html#M000072">when_auth</a>
181
+
182
+ </td>
183
+ </tr>
184
+ <tr class="top-aligned-row context-row">
185
+ <td class="context-item-name">strict_ssl</td>
186
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
187
+ <td class="context-item-desc">
188
+ if this is true, we tell Net::HTTP to die if it can&#8216;t verify the SSL
189
+ when doing https
190
+
191
+ </td>
192
+ </tr>
193
+ <tr class="top-aligned-row context-row">
194
+ <td class="context-item-name">token</td>
195
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
196
+ <td class="context-item-desc">
197
+ the token used for Google&#8216;s AuthSub authentication
141
198
 
142
199
  </td>
143
200
  </tr>
@@ -145,7 +202,7 @@ used by the default <a href="HTTP.html#M000025">when_auth</a>
145
202
  <td class="context-item-name">user</td>
146
203
  <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
147
204
  <td class="context-item-desc">
148
- used by the default <a href="HTTP.html#M000025">when_auth</a>
205
+ used by the default <a href="HTTP.html#M000072">when_auth</a>
149
206
 
150
207
  </td>
151
208
  </tr>
@@ -157,13 +214,58 @@ used by the default <a href="HTTP.html#M000025">when_auth</a>
157
214
 
158
215
  <!-- if method_list -->
159
216
  <div id="methods">
217
+ <h3 class="section-bar">Public Class methods</h3>
218
+
219
+ <div id="method-M000067" class="method-detail">
220
+ <a name="M000067"></a>
221
+
222
+ <div class="method-heading">
223
+ <a href="#M000067" class="method-signature">
224
+ <span class="method-name">new</span><span class="method-args">(cache = nil)</span>
225
+ </a>
226
+ </div>
227
+
228
+ <div class="method-description">
229
+ <p>
230
+ if set, &#8216;cache&#8217; should be a directory for a disk cache, or an
231
+ object with the same interface as <a
232
+ href="FileCache.html">Atom::FileCache</a>
233
+ </p>
234
+ <p><a class="source-toggle" href="#"
235
+ onclick="toggleCode('M000067-source');return false;">[Source]</a></p>
236
+ <div class="method-source-code" id="M000067-source">
237
+ <pre>
238
+ <span class="ruby-comment cmt"># File lib/atom/http.rb, line 147</span>
239
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">cache</span> = <span class="ruby-keyword kw">nil</span>
240
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cache</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
241
+ <span class="ruby-ivar">@cache</span> = <span class="ruby-constant">FileCache</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cache</span>)
242
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">cache</span>
243
+ <span class="ruby-ivar">@cache</span> = <span class="ruby-identifier">cache</span>
244
+ <span class="ruby-keyword kw">else</span>
245
+ <span class="ruby-ivar">@cache</span> = <span class="ruby-constant">NilCache</span>.<span class="ruby-identifier">new</span>
246
+ <span class="ruby-keyword kw">end</span>
247
+
248
+ <span class="ruby-comment cmt"># initialize default #when_auth</span>
249
+ <span class="ruby-ivar">@get_auth_details</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">abs_url</span>, <span class="ruby-identifier">realm</span><span class="ruby-operator">|</span>
250
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@user</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@pass</span>
251
+ [<span class="ruby-ivar">@user</span>, <span class="ruby-ivar">@pass</span>]
252
+ <span class="ruby-keyword kw">else</span>
253
+ <span class="ruby-keyword kw">nil</span>
254
+ <span class="ruby-keyword kw">end</span>
255
+ <span class="ruby-keyword kw">end</span>
256
+ <span class="ruby-keyword kw">end</span>
257
+ </pre>
258
+ </div>
259
+ </div>
260
+ </div>
261
+
160
262
  <h3 class="section-bar">Public Instance methods</h3>
161
263
 
162
- <div id="method-M000024" class="method-detail">
163
- <a name="M000024"></a>
264
+ <div id="method-M000071" class="method-detail">
265
+ <a name="M000071"></a>
164
266
 
165
267
  <div class="method-heading">
166
- <a href="#M000024" class="method-signature">
268
+ <a href="#M000071" class="method-signature">
167
269
  <span class="method-name">delete</span><span class="method-args">(url, body = nil, headers = {})</span>
168
270
  </a>
169
271
  </div>
@@ -173,23 +275,23 @@ used by the default <a href="HTTP.html#M000025">when_auth</a>
173
275
  DELETEs to url
174
276
  </p>
175
277
  <p><a class="source-toggle" href="#"
176
- onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
177
- <div class="method-source-code" id="M000024-source">
278
+ onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
279
+ <div class="method-source-code" id="M000071-source">
178
280
  <pre>
179
- <span class="ruby-comment cmt"># File lib/atom/http.rb, line 54</span>
180
- 54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">body</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span> = {}
181
- 55: <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">url</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Delete</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span>)
182
- 56: <span class="ruby-keyword kw">end</span>
281
+ <span class="ruby-comment cmt"># File lib/atom/http.rb, line 182</span>
282
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">body</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span> = {}
283
+ <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">url</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Delete</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span>)
284
+ <span class="ruby-keyword kw">end</span>
183
285
  </pre>
184
286
  </div>
185
287
  </div>
186
288
  </div>
187
289
 
188
- <div id="method-M000021" class="method-detail">
189
- <a name="M000021"></a>
290
+ <div id="method-M000068" class="method-detail">
291
+ <a name="M000068"></a>
190
292
 
191
293
  <div class="method-heading">
192
- <a href="#M000021" class="method-signature">
294
+ <a href="#M000068" class="method-signature">
193
295
  <span class="method-name">get</span><span class="method-args">(url, headers = {})</span>
194
296
  </a>
195
297
  </div>
@@ -199,55 +301,59 @@ DELETEs to url
199
301
  GETs an url
200
302
  </p>
201
303
  <p><a class="source-toggle" href="#"
202
- onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
203
- <div class="method-source-code" id="M000021-source">
304
+ onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
305
+ <div class="method-source-code" id="M000068-source">
204
306
  <pre>
205
- <span class="ruby-comment cmt"># File lib/atom/http.rb, line 39</span>
206
- 39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">headers</span> = {}
207
- 40: <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">url</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
208
- 41: <span class="ruby-keyword kw">end</span>
307
+ <span class="ruby-comment cmt"># File lib/atom/http.rb, line 167</span>
308
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">headers</span> = {}
309
+ <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">url</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
310
+ <span class="ruby-keyword kw">end</span>
209
311
  </pre>
210
312
  </div>
211
313
  </div>
212
314
  </div>
213
315
 
214
- <div id="method-M000019" class="method-detail">
215
- <a name="M000019"></a>
316
+ <div id="method-M000073" class="method-detail">
317
+ <a name="M000073"></a>
216
318
 
217
319
  <div class="method-heading">
218
- <a href="#M000019" class="method-signature">
320
+ <a href="#M000073" class="method-signature">
219
321
  <span class="method-name">get_atom_entry</span><span class="method-args">(url)</span>
220
322
  </a>
221
323
  </div>
222
324
 
223
325
  <div class="method-description">
224
326
  <p>
225
- GET a URL and turn it into an <a href="Entry.html">Atom::Entry</a>
327
+ GET a URL and turn it into an Atom::Entry
226
328
  </p>
227
329
  <p><a class="source-toggle" href="#"
228
- onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
229
- <div class="method-source-code" id="M000019-source">
330
+ onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
331
+ <div class="method-source-code" id="M000073-source">
230
332
  <pre>
231
- <span class="ruby-comment cmt"># File lib/atom/collection.rb, line 57</span>
232
- 57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_atom_entry</span>(<span class="ruby-identifier">url</span>)
233
- 58: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">get</span>(<span class="ruby-identifier">url</span>)
234
- 59:
235
- 60: <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;200&quot;</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">content_type</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;application/atom+xml&quot;</span>
236
- 61: <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-value str">&quot;expected Atom::Entry, didn't get it&quot;</span>
237
- 62: <span class="ruby-keyword kw">end</span>
238
- 63:
239
- 64: <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Entry</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>, <span class="ruby-identifier">url</span>)
240
- 65: <span class="ruby-keyword kw">end</span>
333
+ <span class="ruby-comment cmt"># File lib/atom/http.rb, line 202</span>
334
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_atom_entry</span>(<span class="ruby-identifier">url</span>)
335
+ <span class="ruby-identifier">res</span> = <span class="ruby-identifier">get</span>(<span class="ruby-identifier">url</span>, <span class="ruby-value str">&quot;Accept&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;application/atom+xml&quot;</span>)
336
+
337
+ <span class="ruby-comment cmt"># XXX handle other HTTP codes</span>
338
+ <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;200&quot;</span>
339
+ <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;failed to fetch entry: expected 200 OK, got #{res.code}&quot;</span>
340
+ <span class="ruby-keyword kw">end</span>
341
+
342
+ <span class="ruby-comment cmt"># be picky for atom:entrys</span>
343
+ <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> ] )
344
+
345
+ <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Entry</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>, <span class="ruby-identifier">url</span>)
346
+ <span class="ruby-keyword kw">end</span>
241
347
  </pre>
242
348
  </div>
243
349
  </div>
244
350
  </div>
245
351
 
246
- <div id="method-M000022" class="method-detail">
247
- <a name="M000022"></a>
352
+ <div id="method-M000069" class="method-detail">
353
+ <a name="M000069"></a>
248
354
 
249
355
  <div class="method-heading">
250
- <a href="#M000022" class="method-signature">
356
+ <a href="#M000069" class="method-signature">
251
357
  <span class="method-name">post</span><span class="method-args">(url, body, headers = {})</span>
252
358
  </a>
253
359
  </div>
@@ -257,23 +363,23 @@ GET a URL and turn it into an <a href="Entry.html">Atom::Entry</a>
257
363
  POSTs body to an url
258
364
  </p>
259
365
  <p><a class="source-toggle" href="#"
260
- onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
261
- <div class="method-source-code" id="M000022-source">
366
+ onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
367
+ <div class="method-source-code" id="M000069-source">
262
368
  <pre>
263
- <span class="ruby-comment cmt"># File lib/atom/http.rb, line 44</span>
264
- 44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span> = {}
265
- 45: <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">url</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span>)
266
- 46: <span class="ruby-keyword kw">end</span>
369
+ <span class="ruby-comment cmt"># File lib/atom/http.rb, line 172</span>
370
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span> = {}
371
+ <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">url</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span>)
372
+ <span class="ruby-keyword kw">end</span>
267
373
  </pre>
268
374
  </div>
269
375
  </div>
270
376
  </div>
271
377
 
272
- <div id="method-M000023" class="method-detail">
273
- <a name="M000023"></a>
378
+ <div id="method-M000070" class="method-detail">
379
+ <a name="M000070"></a>
274
380
 
275
381
  <div class="method-heading">
276
- <a href="#M000023" class="method-signature">
382
+ <a href="#M000070" class="method-signature">
277
383
  <span class="method-name">put</span><span class="method-args">(url, body, headers = {})</span>
278
384
  </a>
279
385
  </div>
@@ -283,53 +389,53 @@ POSTs body to an url
283
389
  PUTs body to an url
284
390
  </p>
285
391
  <p><a class="source-toggle" href="#"
286
- onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
287
- <div class="method-source-code" id="M000023-source">
392
+ onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
393
+ <div class="method-source-code" id="M000070-source">
288
394
  <pre>
289
- <span class="ruby-comment cmt"># File lib/atom/http.rb, line 49</span>
290
- 49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span> = {}
291
- 50: <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">url</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Put</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span>)
292
- 51: <span class="ruby-keyword kw">end</span>
395
+ <span class="ruby-comment cmt"># File lib/atom/http.rb, line 177</span>
396
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span> = {}
397
+ <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">url</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Put</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">headers</span>)
398
+ <span class="ruby-keyword kw">end</span>
293
399
  </pre>
294
400
  </div>
295
401
  </div>
296
402
  </div>
297
403
 
298
- <div id="method-M000020" class="method-detail">
299
- <a name="M000020"></a>
404
+ <div id="method-M000074" class="method-detail">
405
+ <a name="M000074"></a>
300
406
 
301
407
  <div class="method-heading">
302
- <a href="#M000020" class="method-signature">
408
+ <a href="#M000074" class="method-signature">
303
409
  <span class="method-name">put_atom_entry</span><span class="method-args">(entry, url = entry.edit_url)</span>
304
410
  </a>
305
411
  </div>
306
412
 
307
413
  <div class="method-description">
308
414
  <p>
309
- PUT an <a href="Entry.html">Atom::Entry</a> to a URL
415
+ PUT an Atom::Entry to a URL
310
416
  </p>
311
417
  <p><a class="source-toggle" href="#"
312
- onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
313
- <div class="method-source-code" id="M000020-source">
418
+ onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
419
+ <div class="method-source-code" id="M000074-source">
314
420
  <pre>
315
- <span class="ruby-comment cmt"># File lib/atom/collection.rb, line 68</span>
316
- 68: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_atom_entry</span>(<span class="ruby-identifier">entry</span>, <span class="ruby-identifier">url</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">edit_url</span>)
317
- 69: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Cowardly refusing to PUT a non-Atom::Entry (#{entry.class})&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Entry</span>
318
- 70: <span class="ruby-identifier">headers</span> = {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;application/atom+xml&quot;</span> }
319
- 71:
320
- 72: <span class="ruby-identifier">put</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">headers</span>)
321
- 73: <span class="ruby-keyword kw">end</span>
421
+ <span class="ruby-comment cmt"># File lib/atom/http.rb, line 217</span>
422
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_atom_entry</span>(<span class="ruby-identifier">entry</span>, <span class="ruby-identifier">url</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">edit_url</span>)
423
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Cowardly refusing to PUT a non-Atom::Entry (#{entry.class})&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Entry</span>
424
+ <span class="ruby-identifier">headers</span> = {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;application/atom+xml&quot;</span> }
425
+
426
+ <span class="ruby-identifier">put</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">headers</span>)
427
+ <span class="ruby-keyword kw">end</span>
322
428
  </pre>
323
429
  </div>
324
430
  </div>
325
431
  </div>
326
432
 
327
- <div id="method-M000025" class="method-detail">
328
- <a name="M000025"></a>
433
+ <div id="method-M000072" class="method-detail">
434
+ <a name="M000072"></a>
329
435
 
330
436
  <div class="method-heading">
331
- <a href="#M000025" class="method-signature">
332
- <span class="method-name">when_auth</span><span class="method-args">(&amp;block)</span>
437
+ <a href="#M000072" class="method-signature">
438
+ <span class="method-name">when_auth</span><span class="method-args">( {|abs_url, realm| ...}</span>
333
439
  </a>
334
440
  </div>
335
441
 
@@ -337,23 +443,33 @@ PUT an <a href="Entry.html">Atom::Entry</a> to a URL
337
443
  <p>
338
444
  a block that will be called when a remote server responds with 401
339
445
  Unauthorized, so that your application can prompt for authentication
340
- details
446
+ details.
341
447
  </p>
342
448
  <p>
343
- it will be called with the base URL of the requested URL, and the realm
344
- used in the WWW-Authenticate header.
449
+ the default is to use the values of @user and @pass.
345
450
  </p>
346
451
  <p>
347
- it should return a value of the form [username, password]
452
+ your block will be called with two parameters:
453
+ </p>
454
+ <table>
455
+ <tr><td valign="top">abs_url:</td><td>the base URL of the request URL
456
+
457
+ </td></tr>
458
+ <tr><td valign="top">realm:</td><td>the realm used in the WWW-Authenticate header (maybe nil)
459
+
460
+ </td></tr>
461
+ </table>
462
+ <p>
463
+ your block should return [username, password], or nil
348
464
  </p>
349
465
  <p><a class="source-toggle" href="#"
350
- onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
351
- <div class="method-source-code" id="M000025-source">
466
+ onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
467
+ <div class="method-source-code" id="M000072-source">
352
468
  <pre>
353
- <span class="ruby-comment cmt"># File lib/atom/http.rb, line 65</span>
354
- 65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">when_auth</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
355
- 66: <span class="ruby-ivar">@get_auth_details</span> = <span class="ruby-identifier">block</span>
356
- 67: <span class="ruby-keyword kw">end</span>
469
+ <span class="ruby-comment cmt"># File lib/atom/http.rb, line 197</span>
470
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">when_auth</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> <span class="ruby-comment cmt"># :yields: abs_url, realm</span>
471
+ <span class="ruby-ivar">@get_auth_details</span> = <span class="ruby-identifier">block</span>
472
+ <span class="ruby-keyword kw">end</span>
357
473
  </pre>
358
474
  </div>
359
475
  </div>