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.
- data/COPYING +3 -3
- data/README +9 -49
- data/Rakefile +65 -62
- data/bin/atom-cp +159 -0
- data/bin/atom-grep +78 -0
- data/bin/atom-post +73 -0
- data/bin/atom-purge +82 -0
- data/doc/classes/Atom/AttrEl.html +163 -0
- data/doc/classes/Atom/Author.html +2 -19
- data/doc/classes/Atom/AutodiscoveryFailure.html +111 -0
- data/doc/classes/Atom/Categories.html +168 -0
- data/doc/classes/Atom/Category.html +10 -1
- data/doc/classes/Atom/Collection.html +194 -91
- data/doc/classes/Atom/Content.html +42 -1
- data/doc/classes/Atom/Contributor.html +2 -8
- data/doc/classes/Atom/Control.html +126 -0
- data/doc/classes/Atom/Converters.html +571 -0
- data/doc/classes/Atom/DigestAuth.html +285 -0
- data/doc/classes/Atom/Element.html +673 -106
- data/doc/classes/Atom/FileCache.html +287 -0
- data/doc/classes/Atom/HTTP.html +211 -95
- data/doc/classes/Atom/HTTPResponse.html +190 -0
- data/doc/classes/Atom/HasCategories.html +187 -0
- data/doc/classes/Atom/HasLinks.html +168 -0
- data/doc/classes/Atom/Link.html +80 -3
- data/doc/classes/Atom/NilCache.html +202 -0
- data/doc/classes/Atom/ParseError.html +111 -0
- data/doc/classes/Atom/Parsers.html +311 -0
- data/doc/classes/Atom/Person.html +130 -0
- data/doc/classes/Atom/Rights.html +113 -0
- data/doc/classes/Atom/Service.html +298 -0
- data/doc/{files/lib/atom/yaml_rb.html → classes/Atom/Source.html} +26 -24
- data/doc/classes/Atom/Subtitle.html +113 -0
- data/doc/classes/Atom/Summary.html +113 -0
- data/doc/classes/Atom/Text.html +196 -53
- data/doc/classes/Atom/Title.html +113 -0
- data/doc/classes/Atom/Tools.html +525 -0
- data/doc/classes/Atom/Workspace.html +121 -0
- data/doc/classes/Object.html +204 -0
- data/doc/created.rid +1 -1
- data/doc/files/README.html +9 -49
- data/doc/files/lib/atom/cache_rb.html +302 -0
- data/doc/files/lib/atom/collection_rb.html +1 -2
- data/doc/files/lib/atom/element_rb.html +2 -1
- data/doc/files/lib/atom/entry_rb.html +2 -2
- data/doc/files/lib/atom/feed_rb.html +1 -2
- data/doc/files/lib/atom/http_rb.html +6 -1
- data/doc/files/lib/atom/{xml_rb.html → service_rb.html} +8 -6
- data/doc/files/lib/atom/text_rb.html +2 -1
- data/doc/files/lib/atom/{app_rb.html → tools_rb.html} +4 -6
- data/doc/fr_class_index.html +23 -3
- data/doc/fr_file_index.html +3 -3
- data/doc/fr_method_index.html +111 -36
- data/lib/atom/cache.rb +178 -0
- data/lib/atom/collection.rb +90 -40
- data/lib/atom/element.rb +569 -161
- data/lib/atom/entry.rb +63 -89
- data/lib/atom/feed.rb +65 -67
- data/lib/atom/http.rb +421 -49
- data/lib/atom/service.rb +106 -0
- data/lib/atom/text.rb +138 -61
- data/lib/atom/tools.rb +163 -0
- data/spec/entry_spec.rb +364 -0
- data/spec/ext_spec.rb +42 -0
- data/spec/feed_spec.rb +39 -0
- data/spec/fixtures/contacts-feed.xml +34 -0
- data/spec/fixtures/entry-w-ext.xml +15 -0
- data/spec/fixtures/entry-w-xml.xml +24 -0
- data/spec/fixtures/entry.xml +42 -0
- data/spec/fixtures/feed-w-ext.xml +33 -0
- data/spec/fixtures/service-w-xhtml-ns.xml +21 -0
- data/spec/fixtures/service.xml +36 -0
- data/spec/service_spec.rb +108 -0
- data/spec/spec_helper.rb +9 -0
- data/test/conformance/order.rb +11 -10
- data/test/conformance/title.rb +9 -9
- data/test/conformance/updated.rb +2 -1
- data/test/runtests.rb +0 -0
- data/test/test_constructs.rb +78 -8
- data/test/test_feed.rb +35 -29
- data/test/test_general.rb +3 -30
- data/test/test_http.rb +248 -34
- data/test/test_protocol.rb +143 -24
- data/test/test_xml.rb +145 -53
- metadata +116 -62
- data/bin/atom-client.rb +0 -246
- data/bin/atom-server.rb~ +0 -71
- data/doc/classes/Atom/App.html +0 -217
- data/doc/classes/Atom/Entry.html +0 -365
- data/doc/classes/Atom/Feed.html +0 -585
- data/lib/atom/app.rb +0 -87
- data/lib/atom/xml.rb +0 -200
- data/lib/atom/yaml.rb +0 -101
data/doc/classes/Atom/HTTP.html
CHANGED
|
@@ -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="
|
|
94
|
-
href="Collection.html">Atom::Collection</a> or
|
|
95
|
-
|
|
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="#
|
|
111
|
-
<a href="#
|
|
112
|
-
<a href="#
|
|
113
|
-
<a href="#
|
|
114
|
-
<a href="#
|
|
115
|
-
<a href="#
|
|
116
|
-
<a href="#
|
|
108
|
+
<a href="#M000071">delete</a>
|
|
109
|
+
<a href="#M000068">get</a>
|
|
110
|
+
<a href="#M000073">get_atom_entry</a>
|
|
111
|
+
<a href="#M000067">new</a>
|
|
112
|
+
<a href="#M000069">post</a>
|
|
113
|
+
<a href="#M000070">put</a>
|
|
114
|
+
<a href="#M000074">put_atom_entry</a>
|
|
115
|
+
<a href="#M000072">when_auth</a>
|
|
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"> [RW] </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"> [RW] </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‘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"> [RW] </td>
|
|
139
179
|
<td class="context-item-desc">
|
|
140
|
-
used by the default <a href="HTTP.html#
|
|
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"> [RW] </td>
|
|
187
|
+
<td class="context-item-desc">
|
|
188
|
+
if this is true, we tell Net::HTTP to die if it can‘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"> [RW] </td>
|
|
196
|
+
<td class="context-item-desc">
|
|
197
|
+
the token used for Google‘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"> [RW] </td>
|
|
147
204
|
<td class="context-item-desc">
|
|
148
|
-
used by the default <a href="HTTP.html#
|
|
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, ‘cache’ 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-
|
|
163
|
-
<a name="
|
|
264
|
+
<div id="method-M000071" class="method-detail">
|
|
265
|
+
<a name="M000071"></a>
|
|
164
266
|
|
|
165
267
|
<div class="method-heading">
|
|
166
|
-
<a href="#
|
|
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('
|
|
177
|
-
<div class="method-source-code" id="
|
|
278
|
+
onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
|
|
279
|
+
<div class="method-source-code" id="M000071-source">
|
|
178
280
|
<pre>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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-
|
|
189
|
-
<a name="
|
|
290
|
+
<div id="method-M000068" class="method-detail">
|
|
291
|
+
<a name="M000068"></a>
|
|
190
292
|
|
|
191
293
|
<div class="method-heading">
|
|
192
|
-
<a href="#
|
|
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('
|
|
203
|
-
<div class="method-source-code" id="
|
|
304
|
+
onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
|
|
305
|
+
<div class="method-source-code" id="M000068-source">
|
|
204
306
|
<pre>
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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-
|
|
215
|
-
<a name="
|
|
316
|
+
<div id="method-M000073" class="method-detail">
|
|
317
|
+
<a name="M000073"></a>
|
|
216
318
|
|
|
217
319
|
<div class="method-heading">
|
|
218
|
-
<a href="#
|
|
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
|
|
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('
|
|
229
|
-
<div class="method-source-code" id="
|
|
330
|
+
onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
|
|
331
|
+
<div class="method-source-code" id="M000073-source">
|
|
230
332
|
<pre>
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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">"Accept"</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"application/atom+xml"</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">"200"</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">"failed to fetch entry: expected 200 OK, got #{res.code}"</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">"application/atom+xml"</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-
|
|
247
|
-
<a name="
|
|
352
|
+
<div id="method-M000069" class="method-detail">
|
|
353
|
+
<a name="M000069"></a>
|
|
248
354
|
|
|
249
355
|
<div class="method-heading">
|
|
250
|
-
<a href="#
|
|
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('
|
|
261
|
-
<div class="method-source-code" id="
|
|
366
|
+
onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
|
|
367
|
+
<div class="method-source-code" id="M000069-source">
|
|
262
368
|
<pre>
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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-
|
|
273
|
-
<a name="
|
|
378
|
+
<div id="method-M000070" class="method-detail">
|
|
379
|
+
<a name="M000070"></a>
|
|
274
380
|
|
|
275
381
|
<div class="method-heading">
|
|
276
|
-
<a href="#
|
|
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('
|
|
287
|
-
<div class="method-source-code" id="
|
|
392
|
+
onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
|
|
393
|
+
<div class="method-source-code" id="M000070-source">
|
|
288
394
|
<pre>
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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-
|
|
299
|
-
<a name="
|
|
404
|
+
<div id="method-M000074" class="method-detail">
|
|
405
|
+
<a name="M000074"></a>
|
|
300
406
|
|
|
301
407
|
<div class="method-heading">
|
|
302
|
-
<a href="#
|
|
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
|
|
415
|
+
PUT an Atom::Entry to a URL
|
|
310
416
|
</p>
|
|
311
417
|
<p><a class="source-toggle" href="#"
|
|
312
|
-
onclick="toggleCode('
|
|
313
|
-
<div class="method-source-code" id="
|
|
418
|
+
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
|
419
|
+
<div class="method-source-code" id="M000074-source">
|
|
314
420
|
<pre>
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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">"Cowardly refusing to PUT a non-Atom::Entry (#{entry.class})"</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">"Content-Type"</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"application/atom+xml"</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-
|
|
328
|
-
<a name="
|
|
433
|
+
<div id="method-M000072" class="method-detail">
|
|
434
|
+
<a name="M000072"></a>
|
|
329
435
|
|
|
330
436
|
<div class="method-heading">
|
|
331
|
-
<a href="#
|
|
332
|
-
<span class="method-name">when_auth</span><span class="method-args">(
|
|
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
|
-
|
|
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
|
-
|
|
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('
|
|
351
|
-
<div class="method-source-code" id="
|
|
466
|
+
onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
|
|
467
|
+
<div class="method-source-code" id="M000072-source">
|
|
352
468
|
<pre>
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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">&</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>
|