atom-tools 2.0.4 → 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/Rakefile +1 -1
- data/doc/classes/Atom/AttrEl.html +163 -0
- data/doc/classes/Atom/Author.html +113 -0
- data/doc/classes/Atom/AutodiscoveryFailure.html +111 -0
- data/doc/classes/Atom/Categories.html +168 -0
- data/doc/classes/Atom/Category.html +137 -0
- data/doc/classes/Atom/Collection.html +425 -0
- data/doc/classes/Atom/Content.html +170 -0
- data/doc/classes/Atom/Contributor.html +113 -0
- 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 +892 -0
- data/doc/classes/Atom/FileCache.html +287 -0
- data/doc/classes/Atom/HTTP.html +490 -0
- 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 +214 -0
- 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/classes/Atom/Source.html +111 -0
- data/doc/classes/Atom/Subtitle.html +113 -0
- data/doc/classes/Atom/Summary.html +113 -0
- data/doc/classes/Atom/Text.html +372 -0
- 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/classes/XHTML.html +118 -0
- data/doc/created.rid +1 -0
- data/doc/files/README.html +173 -0
- data/doc/files/lib/atom/cache_rb.html +302 -0
- data/doc/files/lib/atom/collection_rb.html +109 -0
- data/doc/files/lib/atom/element_rb.html +110 -0
- data/doc/files/lib/atom/entry_rb.html +111 -0
- data/doc/files/lib/atom/feed_rb.html +111 -0
- data/doc/files/lib/atom/http_rb.html +114 -0
- data/doc/files/lib/atom/service_rb.html +112 -0
- data/doc/files/lib/atom/text_rb.html +109 -0
- data/doc/files/lib/atom/tools_rb.html +108 -0
- data/doc/fr_class_index.html +59 -0
- data/doc/fr_file_index.html +36 -0
- data/doc/fr_method_index.html +137 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/atom/cache.rb +1 -1
- data/lib/atom/http.rb +2 -2
- data/lib/atom/text.rb +15 -6
- data/spec/entry_spec.rb +12 -1
- data/spec/feed_spec.rb +20 -1
- data/spec/fixtures/contacts-feed.xml +34 -0
- data/spec/fixtures/entry-w-xml.xml +24 -0
- metadata +68 -5
@@ -0,0 +1,287 @@
|
|
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::FileCache</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::FileCache</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/atom/cache_rb.html">
|
59
|
+
lib/atom/cache.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="../Object.html">
|
69
|
+
Object
|
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
|
+
uses a local directory to store cache files
|
86
|
+
</p>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<div id="method-list">
|
94
|
+
<h3 class="section-bar">Methods</h3>
|
95
|
+
|
96
|
+
<div class="name-list">
|
97
|
+
<a href="#M000061">[]</a>
|
98
|
+
<a href="#M000062">[]=</a>
|
99
|
+
<a href="#M000063">delete</a>
|
100
|
+
<a href="#M000058">new</a>
|
101
|
+
<a href="#M000060">safe</a>
|
102
|
+
<a href="#M000059">to_file</a>
|
103
|
+
</div>
|
104
|
+
</div>
|
105
|
+
|
106
|
+
</div>
|
107
|
+
|
108
|
+
|
109
|
+
<!-- if includes -->
|
110
|
+
|
111
|
+
<div id="section">
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<!-- if method_list -->
|
121
|
+
<div id="methods">
|
122
|
+
<h3 class="section-bar">Public Class methods</h3>
|
123
|
+
|
124
|
+
<div id="method-M000058" class="method-detail">
|
125
|
+
<a name="M000058"></a>
|
126
|
+
|
127
|
+
<div class="method-heading">
|
128
|
+
<a href="#M000058" class="method-signature">
|
129
|
+
<span class="method-name">new</span><span class="method-args">(dir)</span>
|
130
|
+
</a>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<div class="method-description">
|
134
|
+
<p><a class="source-toggle" href="#"
|
135
|
+
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
|
136
|
+
<div class="method-source-code" id="M000058-source">
|
137
|
+
<pre>
|
138
|
+
<span class="ruby-comment cmt"># File lib/atom/cache.rb, line 145</span>
|
139
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">dir</span>
|
140
|
+
<span class="ruby-ivar">@dir</span> = <span class="ruby-identifier">dir</span>
|
141
|
+
<span class="ruby-keyword kw">end</span>
|
142
|
+
</pre>
|
143
|
+
</div>
|
144
|
+
</div>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
148
|
+
|
149
|
+
<div id="method-M000061" class="method-detail">
|
150
|
+
<a name="M000061"></a>
|
151
|
+
|
152
|
+
<div class="method-heading">
|
153
|
+
<a href="#M000061" class="method-signature">
|
154
|
+
<span class="method-name">[]</span><span class="method-args">(key)</span>
|
155
|
+
</a>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
<div class="method-description">
|
159
|
+
<p><a class="source-toggle" href="#"
|
160
|
+
onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
|
161
|
+
<div class="method-source-code" id="M000061-source">
|
162
|
+
<pre>
|
163
|
+
<span class="ruby-comment cmt"># File lib/atom/cache.rb, line 162</span>
|
164
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span> <span class="ruby-identifier">key</span>
|
165
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_file</span>(<span class="ruby-identifier">key</span>))
|
166
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
|
167
|
+
<span class="ruby-keyword kw">nil</span>
|
168
|
+
<span class="ruby-keyword kw">end</span>
|
169
|
+
</pre>
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
</div>
|
173
|
+
|
174
|
+
<div id="method-M000062" class="method-detail">
|
175
|
+
<a name="M000062"></a>
|
176
|
+
|
177
|
+
<div class="method-heading">
|
178
|
+
<a href="#M000062" class="method-signature">
|
179
|
+
<span class="method-name">[]=</span><span class="method-args">(key, value)</span>
|
180
|
+
</a>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<div class="method-description">
|
184
|
+
<p><a class="source-toggle" href="#"
|
185
|
+
onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
|
186
|
+
<div class="method-source-code" id="M000062-source">
|
187
|
+
<pre>
|
188
|
+
<span class="ruby-comment cmt"># File lib/atom/cache.rb, line 168</span>
|
189
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]=</span> <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>
|
190
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_file</span>(<span class="ruby-identifier">key</span>), <span class="ruby-value str">'w'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
191
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">value</span>)
|
192
|
+
<span class="ruby-keyword kw">end</span>
|
193
|
+
<span class="ruby-keyword kw">end</span>
|
194
|
+
</pre>
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
</div>
|
198
|
+
|
199
|
+
<div id="method-M000063" class="method-detail">
|
200
|
+
<a name="M000063"></a>
|
201
|
+
|
202
|
+
<div class="method-heading">
|
203
|
+
<a href="#M000063" class="method-signature">
|
204
|
+
<span class="method-name">delete</span><span class="method-args">(key)</span>
|
205
|
+
</a>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
<div class="method-description">
|
209
|
+
<p><a class="source-toggle" href="#"
|
210
|
+
onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
|
211
|
+
<div class="method-source-code" id="M000063-source">
|
212
|
+
<pre>
|
213
|
+
<span class="ruby-comment cmt"># File lib/atom/cache.rb, line 174</span>
|
214
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span> <span class="ruby-identifier">key</span>
|
215
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_file</span>(<span class="ruby-identifier">key</span>))
|
216
|
+
<span class="ruby-keyword kw">end</span>
|
217
|
+
</pre>
|
218
|
+
</div>
|
219
|
+
</div>
|
220
|
+
</div>
|
221
|
+
|
222
|
+
<div id="method-M000060" class="method-detail">
|
223
|
+
<a name="M000060"></a>
|
224
|
+
|
225
|
+
<div class="method-heading">
|
226
|
+
<a href="#M000060" class="method-signature">
|
227
|
+
<span class="method-name">safe</span><span class="method-args">(filename)</span>
|
228
|
+
</a>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
<div class="method-description">
|
232
|
+
<p>
|
233
|
+
turns a URL into a <a href="FileCache.html#M000060">safe</a> filename
|
234
|
+
</p>
|
235
|
+
<p><a class="source-toggle" href="#"
|
236
|
+
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
|
237
|
+
<div class="method-source-code" id="M000060-source">
|
238
|
+
<pre>
|
239
|
+
<span class="ruby-comment cmt"># File lib/atom/cache.rb, line 154</span>
|
240
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">safe</span> <span class="ruby-identifier">filename</span>
|
241
|
+
<span class="ruby-identifier">filemd5</span> = <span class="ruby-constant">MD5</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">filename</span>)
|
242
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/^\w+:\/\//</span>, <span class="ruby-value str">''</span>)
|
243
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[?\/:|]+/</span>, <span class="ruby-value str">','</span>)
|
244
|
+
|
245
|
+
<span class="ruby-identifier">filename</span> <span class="ruby-operator">+</span> <span class="ruby-value str">","</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">filemd5</span>
|
246
|
+
<span class="ruby-keyword kw">end</span>
|
247
|
+
</pre>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
|
252
|
+
<div id="method-M000059" class="method-detail">
|
253
|
+
<a name="M000059"></a>
|
254
|
+
|
255
|
+
<div class="method-heading">
|
256
|
+
<a href="#M000059" class="method-signature">
|
257
|
+
<span class="method-name">to_file</span><span class="method-args">(key)</span>
|
258
|
+
</a>
|
259
|
+
</div>
|
260
|
+
|
261
|
+
<div class="method-description">
|
262
|
+
<p><a class="source-toggle" href="#"
|
263
|
+
onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
|
264
|
+
<div class="method-source-code" id="M000059-source">
|
265
|
+
<pre>
|
266
|
+
<span class="ruby-comment cmt"># File lib/atom/cache.rb, line 149</span>
|
267
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_file</span>(<span class="ruby-identifier">key</span>)
|
268
|
+
<span class="ruby-ivar">@dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/"</span> <span class="ruby-operator">+</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">safe</span>(<span class="ruby-identifier">key</span>)
|
269
|
+
<span class="ruby-keyword kw">end</span>
|
270
|
+
</pre>
|
271
|
+
</div>
|
272
|
+
</div>
|
273
|
+
</div>
|
274
|
+
|
275
|
+
|
276
|
+
</div>
|
277
|
+
|
278
|
+
|
279
|
+
</div>
|
280
|
+
|
281
|
+
|
282
|
+
<div id="validator-badges">
|
283
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
284
|
+
</div>
|
285
|
+
|
286
|
+
</body>
|
287
|
+
</html>
|
@@ -0,0 +1,490 @@
|
|
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::HTTP</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::HTTP</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/atom/http_rb.html">
|
59
|
+
lib/atom/http.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="../Object.html">
|
69
|
+
Object
|
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
|
+
An object which handles the details of <a href="HTTP.html">HTTP</a> -
|
86
|
+
particularly authentication and caching (neither of which are fully
|
87
|
+
implemented).
|
88
|
+
</p>
|
89
|
+
<p>
|
90
|
+
This object can be used on its own, or passed to an <a
|
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.
|
94
|
+
</p>
|
95
|
+
<p>
|
96
|
+
All its <a href="HTTP.html">HTTP</a> methods return a Net::HTTPResponse
|
97
|
+
</p>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<div id="method-list">
|
105
|
+
<h3 class="section-bar">Methods</h3>
|
106
|
+
|
107
|
+
<div class="name-list">
|
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>
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
|
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>
|
130
|
+
|
131
|
+
<div id="section">
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<div id="attribute-list">
|
138
|
+
<h3 class="section-bar">Attributes</h3>
|
139
|
+
|
140
|
+
<div class="name-list">
|
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>
|
176
|
+
<tr class="top-aligned-row context-row">
|
177
|
+
<td class="context-item-name">pass</td>
|
178
|
+
<td class="context-item-value"> [RW] </td>
|
179
|
+
<td class="context-item-desc">
|
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
|
198
|
+
|
199
|
+
</td>
|
200
|
+
</tr>
|
201
|
+
<tr class="top-aligned-row context-row">
|
202
|
+
<td class="context-item-name">user</td>
|
203
|
+
<td class="context-item-value"> [RW] </td>
|
204
|
+
<td class="context-item-desc">
|
205
|
+
used by the default <a href="HTTP.html#M000072">when_auth</a>
|
206
|
+
|
207
|
+
</td>
|
208
|
+
</tr>
|
209
|
+
</table>
|
210
|
+
</div>
|
211
|
+
</div>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
<!-- if method_list -->
|
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
|
+
|
262
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
263
|
+
|
264
|
+
<div id="method-M000071" class="method-detail">
|
265
|
+
<a name="M000071"></a>
|
266
|
+
|
267
|
+
<div class="method-heading">
|
268
|
+
<a href="#M000071" class="method-signature">
|
269
|
+
<span class="method-name">delete</span><span class="method-args">(url, body = nil, headers = {})</span>
|
270
|
+
</a>
|
271
|
+
</div>
|
272
|
+
|
273
|
+
<div class="method-description">
|
274
|
+
<p>
|
275
|
+
DELETEs to url
|
276
|
+
</p>
|
277
|
+
<p><a class="source-toggle" href="#"
|
278
|
+
onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
|
279
|
+
<div class="method-source-code" id="M000071-source">
|
280
|
+
<pre>
|
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>
|
285
|
+
</pre>
|
286
|
+
</div>
|
287
|
+
</div>
|
288
|
+
</div>
|
289
|
+
|
290
|
+
<div id="method-M000068" class="method-detail">
|
291
|
+
<a name="M000068"></a>
|
292
|
+
|
293
|
+
<div class="method-heading">
|
294
|
+
<a href="#M000068" class="method-signature">
|
295
|
+
<span class="method-name">get</span><span class="method-args">(url, headers = {})</span>
|
296
|
+
</a>
|
297
|
+
</div>
|
298
|
+
|
299
|
+
<div class="method-description">
|
300
|
+
<p>
|
301
|
+
GETs an url
|
302
|
+
</p>
|
303
|
+
<p><a class="source-toggle" href="#"
|
304
|
+
onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
|
305
|
+
<div class="method-source-code" id="M000068-source">
|
306
|
+
<pre>
|
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>
|
311
|
+
</pre>
|
312
|
+
</div>
|
313
|
+
</div>
|
314
|
+
</div>
|
315
|
+
|
316
|
+
<div id="method-M000073" class="method-detail">
|
317
|
+
<a name="M000073"></a>
|
318
|
+
|
319
|
+
<div class="method-heading">
|
320
|
+
<a href="#M000073" class="method-signature">
|
321
|
+
<span class="method-name">get_atom_entry</span><span class="method-args">(url)</span>
|
322
|
+
</a>
|
323
|
+
</div>
|
324
|
+
|
325
|
+
<div class="method-description">
|
326
|
+
<p>
|
327
|
+
GET a URL and turn it into an Atom::Entry
|
328
|
+
</p>
|
329
|
+
<p><a class="source-toggle" href="#"
|
330
|
+
onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
|
331
|
+
<div class="method-source-code" id="M000073-source">
|
332
|
+
<pre>
|
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>
|
347
|
+
</pre>
|
348
|
+
</div>
|
349
|
+
</div>
|
350
|
+
</div>
|
351
|
+
|
352
|
+
<div id="method-M000069" class="method-detail">
|
353
|
+
<a name="M000069"></a>
|
354
|
+
|
355
|
+
<div class="method-heading">
|
356
|
+
<a href="#M000069" class="method-signature">
|
357
|
+
<span class="method-name">post</span><span class="method-args">(url, body, headers = {})</span>
|
358
|
+
</a>
|
359
|
+
</div>
|
360
|
+
|
361
|
+
<div class="method-description">
|
362
|
+
<p>
|
363
|
+
POSTs body to an url
|
364
|
+
</p>
|
365
|
+
<p><a class="source-toggle" href="#"
|
366
|
+
onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
|
367
|
+
<div class="method-source-code" id="M000069-source">
|
368
|
+
<pre>
|
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>
|
373
|
+
</pre>
|
374
|
+
</div>
|
375
|
+
</div>
|
376
|
+
</div>
|
377
|
+
|
378
|
+
<div id="method-M000070" class="method-detail">
|
379
|
+
<a name="M000070"></a>
|
380
|
+
|
381
|
+
<div class="method-heading">
|
382
|
+
<a href="#M000070" class="method-signature">
|
383
|
+
<span class="method-name">put</span><span class="method-args">(url, body, headers = {})</span>
|
384
|
+
</a>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
<div class="method-description">
|
388
|
+
<p>
|
389
|
+
PUTs body to an url
|
390
|
+
</p>
|
391
|
+
<p><a class="source-toggle" href="#"
|
392
|
+
onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
|
393
|
+
<div class="method-source-code" id="M000070-source">
|
394
|
+
<pre>
|
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>
|
399
|
+
</pre>
|
400
|
+
</div>
|
401
|
+
</div>
|
402
|
+
</div>
|
403
|
+
|
404
|
+
<div id="method-M000074" class="method-detail">
|
405
|
+
<a name="M000074"></a>
|
406
|
+
|
407
|
+
<div class="method-heading">
|
408
|
+
<a href="#M000074" class="method-signature">
|
409
|
+
<span class="method-name">put_atom_entry</span><span class="method-args">(entry, url = entry.edit_url)</span>
|
410
|
+
</a>
|
411
|
+
</div>
|
412
|
+
|
413
|
+
<div class="method-description">
|
414
|
+
<p>
|
415
|
+
PUT an Atom::Entry to a URL
|
416
|
+
</p>
|
417
|
+
<p><a class="source-toggle" href="#"
|
418
|
+
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
419
|
+
<div class="method-source-code" id="M000074-source">
|
420
|
+
<pre>
|
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>
|
428
|
+
</pre>
|
429
|
+
</div>
|
430
|
+
</div>
|
431
|
+
</div>
|
432
|
+
|
433
|
+
<div id="method-M000072" class="method-detail">
|
434
|
+
<a name="M000072"></a>
|
435
|
+
|
436
|
+
<div class="method-heading">
|
437
|
+
<a href="#M000072" class="method-signature">
|
438
|
+
<span class="method-name">when_auth</span><span class="method-args">( {|abs_url, realm| ...}</span>
|
439
|
+
</a>
|
440
|
+
</div>
|
441
|
+
|
442
|
+
<div class="method-description">
|
443
|
+
<p>
|
444
|
+
a block that will be called when a remote server responds with 401
|
445
|
+
Unauthorized, so that your application can prompt for authentication
|
446
|
+
details.
|
447
|
+
</p>
|
448
|
+
<p>
|
449
|
+
the default is to use the values of @user and @pass.
|
450
|
+
</p>
|
451
|
+
<p>
|
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
|
464
|
+
</p>
|
465
|
+
<p><a class="source-toggle" href="#"
|
466
|
+
onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
|
467
|
+
<div class="method-source-code" id="M000072-source">
|
468
|
+
<pre>
|
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>
|
473
|
+
</pre>
|
474
|
+
</div>
|
475
|
+
</div>
|
476
|
+
</div>
|
477
|
+
|
478
|
+
|
479
|
+
</div>
|
480
|
+
|
481
|
+
|
482
|
+
</div>
|
483
|
+
|
484
|
+
|
485
|
+
<div id="validator-badges">
|
486
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
487
|
+
</div>
|
488
|
+
|
489
|
+
</body>
|
490
|
+
</html>
|