atom-tools 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/Rakefile +1 -1
  2. data/doc/classes/Atom/AttrEl.html +163 -0
  3. data/doc/classes/Atom/Author.html +113 -0
  4. data/doc/classes/Atom/AutodiscoveryFailure.html +111 -0
  5. data/doc/classes/Atom/Categories.html +168 -0
  6. data/doc/classes/Atom/Category.html +137 -0
  7. data/doc/classes/Atom/Collection.html +425 -0
  8. data/doc/classes/Atom/Content.html +170 -0
  9. data/doc/classes/Atom/Contributor.html +113 -0
  10. data/doc/classes/Atom/Control.html +126 -0
  11. data/doc/classes/Atom/Converters.html +571 -0
  12. data/doc/classes/Atom/DigestAuth.html +285 -0
  13. data/doc/classes/Atom/Element.html +892 -0
  14. data/doc/classes/Atom/FileCache.html +287 -0
  15. data/doc/classes/Atom/HTTP.html +490 -0
  16. data/doc/classes/Atom/HTTPResponse.html +190 -0
  17. data/doc/classes/Atom/HasCategories.html +187 -0
  18. data/doc/classes/Atom/HasLinks.html +168 -0
  19. data/doc/classes/Atom/Link.html +214 -0
  20. data/doc/classes/Atom/NilCache.html +202 -0
  21. data/doc/classes/Atom/ParseError.html +111 -0
  22. data/doc/classes/Atom/Parsers.html +311 -0
  23. data/doc/classes/Atom/Person.html +130 -0
  24. data/doc/classes/Atom/Rights.html +113 -0
  25. data/doc/classes/Atom/Service.html +298 -0
  26. data/doc/classes/Atom/Source.html +111 -0
  27. data/doc/classes/Atom/Subtitle.html +113 -0
  28. data/doc/classes/Atom/Summary.html +113 -0
  29. data/doc/classes/Atom/Text.html +372 -0
  30. data/doc/classes/Atom/Title.html +113 -0
  31. data/doc/classes/Atom/Tools.html +525 -0
  32. data/doc/classes/Atom/Workspace.html +121 -0
  33. data/doc/classes/Object.html +204 -0
  34. data/doc/classes/XHTML.html +118 -0
  35. data/doc/created.rid +1 -0
  36. data/doc/files/README.html +173 -0
  37. data/doc/files/lib/atom/cache_rb.html +302 -0
  38. data/doc/files/lib/atom/collection_rb.html +109 -0
  39. data/doc/files/lib/atom/element_rb.html +110 -0
  40. data/doc/files/lib/atom/entry_rb.html +111 -0
  41. data/doc/files/lib/atom/feed_rb.html +111 -0
  42. data/doc/files/lib/atom/http_rb.html +114 -0
  43. data/doc/files/lib/atom/service_rb.html +112 -0
  44. data/doc/files/lib/atom/text_rb.html +109 -0
  45. data/doc/files/lib/atom/tools_rb.html +108 -0
  46. data/doc/fr_class_index.html +59 -0
  47. data/doc/fr_file_index.html +36 -0
  48. data/doc/fr_method_index.html +137 -0
  49. data/doc/index.html +24 -0
  50. data/doc/rdoc-style.css +208 -0
  51. data/lib/atom/cache.rb +1 -1
  52. data/lib/atom/http.rb +2 -2
  53. data/lib/atom/text.rb +15 -6
  54. data/spec/entry_spec.rb +12 -1
  55. data/spec/feed_spec.rb +20 -1
  56. data/spec/fixtures/contacts-feed.xml +34 -0
  57. data/spec/fixtures/entry-w-xml.xml +24 -0
  58. metadata +68 -5
@@ -0,0 +1,113 @@
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::Title</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::Title</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/atom/text_rb.html">
59
+ lib/atom/text.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="Text.html">
69
+ Atom::Text
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
+
84
+
85
+ </div>
86
+
87
+
88
+ </div>
89
+
90
+
91
+ <!-- if includes -->
92
+
93
+ <div id="section">
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ <!-- if method_list -->
103
+
104
+
105
+ </div>
106
+
107
+
108
+ <div id="validator-badges">
109
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
110
+ </div>
111
+
112
+ </body>
113
+ </html>
@@ -0,0 +1,525 @@
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>Module: Atom::Tools</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>Module</strong></td>
53
+ <td class="class-name-in-header">Atom::Tools</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/atom/tools_rb.html">
59
+ lib/atom/tools.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ methods to make writing commandline Atom tools more convenient
78
+ </p>
79
+
80
+ </div>
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000033">atom_options</a>&nbsp;&nbsp;
90
+ <a href="#M000026">dir_to_entries</a>&nbsp;&nbsp;
91
+ <a href="#M000029">entries_to_dir</a>&nbsp;&nbsp;
92
+ <a href="#M000028">entries_to_http</a>&nbsp;&nbsp;
93
+ <a href="#M000030">entries_to_stdout</a>&nbsp;&nbsp;
94
+ <a href="#M000025">http_to_entries</a>&nbsp;&nbsp;
95
+ <a href="#M000034">obtain_password</a>&nbsp;&nbsp;
96
+ <a href="#M000031">parse_input</a>&nbsp;&nbsp;
97
+ <a href="#M000035">setup_http</a>&nbsp;&nbsp;
98
+ <a href="#M000027">stdin_to_entries</a>&nbsp;&nbsp;
99
+ <a href="#M000032">write_output</a>&nbsp;&nbsp;
100
+ </div>
101
+ </div>
102
+
103
+ </div>
104
+
105
+
106
+ <!-- if includes -->
107
+
108
+ <div id="section">
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ <!-- if method_list -->
118
+ <div id="methods">
119
+ <h3 class="section-bar">Public Instance methods</h3>
120
+
121
+ <div id="method-M000033" class="method-detail">
122
+ <a name="M000033"></a>
123
+
124
+ <div class="method-heading">
125
+ <a href="#M000033" class="method-signature">
126
+ <span class="method-name">atom_options</span><span class="method-args">(opts, options)</span>
127
+ </a>
128
+ </div>
129
+
130
+ <div class="method-description">
131
+ <p>
132
+ set up some common OptionParser settings
133
+ </p>
134
+ <p><a class="source-toggle" href="#"
135
+ onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
136
+ <div class="method-source-code" id="M000033-source">
137
+ <pre>
138
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 120</span>
139
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">atom_options</span> <span class="ruby-identifier">opts</span>, <span class="ruby-identifier">options</span>
140
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">'-u'</span>, <span class="ruby-value str">'--user NAME'</span>, <span class="ruby-value str">'username for HTTP auth'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:user</span>] = <span class="ruby-identifier">u</span> }
141
+
142
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>(<span class="ruby-value str">'-h'</span>, <span class="ruby-value str">'--help'</span>, <span class="ruby-value str">'show this usage statement'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>; <span class="ruby-identifier">exit</span> }
143
+
144
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>(<span class="ruby-value str">'-p'</span>, <span class="ruby-value str">'--password [PASSWORD]'</span>, <span class="ruby-value str">'password for HTTP auth'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
145
+ <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:pass</span>] = <span class="ruby-identifier">p</span>
146
+ <span class="ruby-keyword kw">end</span>
147
+ <span class="ruby-keyword kw">end</span>
148
+ </pre>
149
+ </div>
150
+ </div>
151
+ </div>
152
+
153
+ <div id="method-M000026" class="method-detail">
154
+ <a name="M000026"></a>
155
+
156
+ <div class="method-heading">
157
+ <a href="#M000026" class="method-signature">
158
+ <span class="method-name">dir_to_entries</span><span class="method-args">(path)</span>
159
+ </a>
160
+ </div>
161
+
162
+ <div class="method-description">
163
+ <p>
164
+ parse a directory of entries
165
+ </p>
166
+ <p><a class="source-toggle" href="#"
167
+ onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
168
+ <div class="method-source-code" id="M000026-source">
169
+ <pre>
170
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 20</span>
171
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dir_to_entries</span> <span class="ruby-identifier">path</span>
172
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;#{path} is not a directory&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">path</span>
173
+
174
+ <span class="ruby-constant">Dir</span>[<span class="ruby-identifier">path</span><span class="ruby-operator">+</span><span class="ruby-value str">'/*.atom'</span>].<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
175
+ <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-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">e</span>))
176
+ <span class="ruby-keyword kw">end</span>
177
+ <span class="ruby-keyword kw">end</span>
178
+ </pre>
179
+ </div>
180
+ </div>
181
+ </div>
182
+
183
+ <div id="method-M000029" class="method-detail">
184
+ <a name="M000029"></a>
185
+
186
+ <div class="method-heading">
187
+ <a href="#M000029" class="method-signature">
188
+ <span class="method-name">entries_to_dir</span><span class="method-args">(entries, path)</span>
189
+ </a>
190
+ </div>
191
+
192
+ <div class="method-description">
193
+ <p>
194
+ saves an Array of Atom::Entrys to a directory
195
+ </p>
196
+ <p><a class="source-toggle" href="#"
197
+ onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
198
+ <div class="method-source-code" id="M000029-source">
199
+ <pre>
200
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 41</span>
201
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">entries_to_dir</span> <span class="ruby-identifier">entries</span>, <span class="ruby-identifier">path</span>
202
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span> <span class="ruby-identifier">path</span>
203
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;directory #{path} already exists&quot;</span>
204
+ <span class="ruby-keyword kw">else</span>
205
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span> <span class="ruby-identifier">path</span>
206
+ <span class="ruby-keyword kw">end</span>
207
+
208
+ <span class="ruby-identifier">entries</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
209
+ <span class="ruby-identifier">e</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">to_s</span>
210
+
211
+ <span class="ruby-identifier">new_filename</span> = <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/0x'</span> <span class="ruby-operator">+</span> <span class="ruby-constant">MD5</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">e</span>).<span class="ruby-identifier">hexdigest</span>[<span class="ruby-value">0</span>,<span class="ruby-value">8</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">'.atom'</span>
212
+
213
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">new_filename</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">e</span> }
214
+ <span class="ruby-keyword kw">end</span>
215
+ <span class="ruby-keyword kw">end</span>
216
+ </pre>
217
+ </div>
218
+ </div>
219
+ </div>
220
+
221
+ <div id="method-M000028" class="method-detail">
222
+ <a name="M000028"></a>
223
+
224
+ <div class="method-heading">
225
+ <a href="#M000028" class="method-signature">
226
+ <span class="method-name">entries_to_http</span><span class="method-args">(entries, url, http = Atom::HTTP.new)</span>
227
+ </a>
228
+ </div>
229
+
230
+ <div class="method-description">
231
+ <p>
232
+ POSTs an Array of Atom::Entrys to an Atom <a
233
+ href="Collection.html">Collection</a>
234
+ </p>
235
+ <p><a class="source-toggle" href="#"
236
+ onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
237
+ <div class="method-source-code" id="M000028-source">
238
+ <pre>
239
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 34</span>
240
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">entries_to_http</span> <span class="ruby-identifier">entries</span>, <span class="ruby-identifier">url</span>, <span class="ruby-identifier">http</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>
241
+ <span class="ruby-identifier">coll</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Collection</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">http</span>
242
+
243
+ <span class="ruby-identifier">entries</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span> <span class="ruby-identifier">coll</span>.<span class="ruby-identifier">post!</span> <span class="ruby-identifier">entry</span> }
244
+ <span class="ruby-keyword kw">end</span>
245
+ </pre>
246
+ </div>
247
+ </div>
248
+ </div>
249
+
250
+ <div id="method-M000030" class="method-detail">
251
+ <a name="M000030"></a>
252
+
253
+ <div class="method-heading">
254
+ <a href="#M000030" class="method-signature">
255
+ <span class="method-name">entries_to_stdout</span><span class="method-args">(entries)</span>
256
+ </a>
257
+ </div>
258
+
259
+ <div class="method-description">
260
+ <p>
261
+ dumps an Array of Atom::Entrys into a Feed on stdout
262
+ </p>
263
+ <p><a class="source-toggle" href="#"
264
+ onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
265
+ <div class="method-source-code" id="M000030-source">
266
+ <pre>
267
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 58</span>
268
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">entries_to_stdout</span> <span class="ruby-identifier">entries</span>
269
+ <span class="ruby-identifier">feed</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Feed</span>.<span class="ruby-identifier">new</span>
270
+
271
+ <span class="ruby-identifier">entries</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
272
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">inspect</span>
273
+ <span class="ruby-identifier">feed</span>.<span class="ruby-identifier">entries</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">entry</span>
274
+ <span class="ruby-keyword kw">end</span>
275
+
276
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">feed</span>.<span class="ruby-identifier">to_s</span>
277
+ <span class="ruby-keyword kw">end</span>
278
+ </pre>
279
+ </div>
280
+ </div>
281
+ </div>
282
+
283
+ <div id="method-M000025" class="method-detail">
284
+ <a name="M000025"></a>
285
+
286
+ <div class="method-heading">
287
+ <a href="#M000025" class="method-signature">
288
+ <span class="method-name">http_to_entries</span><span class="method-args">(url, complete_feed = false, http = Atom::HTTP.new)</span>
289
+ </a>
290
+ </div>
291
+
292
+ <div class="method-description">
293
+ <p>
294
+ fetch and parse a Feed URL, returning the entries found
295
+ </p>
296
+ <p><a class="source-toggle" href="#"
297
+ onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
298
+ <div class="method-source-code" id="M000025-source">
299
+ <pre>
300
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 7</span>
301
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">http_to_entries</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">complete_feed</span> = <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">http</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>
302
+ <span class="ruby-identifier">feed</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Feed</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">http</span>
303
+
304
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">complete_feed</span>
305
+ <span class="ruby-identifier">feed</span>.<span class="ruby-identifier">get_everything!</span>
306
+ <span class="ruby-keyword kw">else</span>
307
+ <span class="ruby-identifier">feed</span>.<span class="ruby-identifier">update!</span>
308
+ <span class="ruby-keyword kw">end</span>
309
+
310
+ <span class="ruby-identifier">feed</span>.<span class="ruby-identifier">entries</span>
311
+ <span class="ruby-keyword kw">end</span>
312
+ </pre>
313
+ </div>
314
+ </div>
315
+ </div>
316
+
317
+ <div id="method-M000034" class="method-detail">
318
+ <a name="M000034"></a>
319
+
320
+ <div class="method-heading">
321
+ <a href="#M000034" class="method-signature">
322
+ <span class="method-name">obtain_password</span><span class="method-args">()</span>
323
+ </a>
324
+ </div>
325
+
326
+ <div class="method-description">
327
+ <p>
328
+ obtain a password from the TTY, hiding the user&#8216;s input this will
329
+ fail if you don&#8216;t have the program &#8216;stty&#8216;
330
+ </p>
331
+ <p><a class="source-toggle" href="#"
332
+ onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
333
+ <div class="method-source-code" id="M000034-source">
334
+ <pre>
335
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 133</span>
336
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">obtain_password</span>
337
+ <span class="ruby-identifier">i</span> = <span class="ruby-identifier">o</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-value str">'/dev/tty'</span>, <span class="ruby-value str">'w+'</span>)
338
+
339
+ <span class="ruby-identifier">o</span>.<span class="ruby-identifier">print</span> <span class="ruby-value str">'Password: '</span>
340
+
341
+ <span class="ruby-comment cmt"># store original settings</span>
342
+ <span class="ruby-identifier">state</span> = <span class="ruby-value">`stty -F /dev/tty -g`</span>
343
+
344
+ <span class="ruby-comment cmt"># don't echo input</span>
345
+ <span class="ruby-identifier">system</span> <span class="ruby-value str">&quot;stty -F /dev/tty -echo&quot;</span>
346
+
347
+ <span class="ruby-identifier">p</span> = <span class="ruby-identifier">i</span>.<span class="ruby-identifier">gets</span>.<span class="ruby-identifier">chomp</span>
348
+
349
+ <span class="ruby-comment cmt"># restore original settings</span>
350
+ <span class="ruby-identifier">system</span> <span class="ruby-node">&quot;stty -F /dev/tty #{state}&quot;</span>
351
+
352
+ <span class="ruby-identifier">p</span>
353
+ <span class="ruby-keyword kw">end</span>
354
+ </pre>
355
+ </div>
356
+ </div>
357
+ </div>
358
+
359
+ <div id="method-M000031" class="method-detail">
360
+ <a name="M000031"></a>
361
+
362
+ <div class="method-heading">
363
+ <a href="#M000031" class="method-signature">
364
+ <span class="method-name">parse_input</span><span class="method-args">(source, options)</span>
365
+ </a>
366
+ </div>
367
+
368
+ <div class="method-description">
369
+ <p>
370
+ turns a collection of Atom Entries into an Array of Atom::Entrys
371
+ </p>
372
+ <p>
373
+ source: a URL, a directory or &quot;-&quot; for an Atom Feed on stdin
374
+ options:
375
+ </p>
376
+ <pre>
377
+ :complete - whether to fetch the complete logical feed
378
+ :user - username to use for HTTP requests (if required)
379
+ :pass - password to use for HTTP requests (if required)
380
+ </pre>
381
+ <p><a class="source-toggle" href="#"
382
+ onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
383
+ <div class="method-source-code" id="M000031-source">
384
+ <pre>
385
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 76</span>
386
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_input</span> <span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span>
387
+ <span class="ruby-identifier">entries</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">match</span> <span class="ruby-regexp re">/^http/</span>
388
+ <span class="ruby-identifier">http</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>
389
+
390
+ <span class="ruby-identifier">setup_http</span> <span class="ruby-identifier">http</span>, <span class="ruby-identifier">options</span>
391
+
392
+ <span class="ruby-identifier">http_to_entries</span> <span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:complete</span>], <span class="ruby-identifier">http</span>
393
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">source</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'-'</span>
394
+ <span class="ruby-identifier">stdin_to_entries</span>
395
+ <span class="ruby-keyword kw">else</span>
396
+ <span class="ruby-identifier">dir_to_entries</span> <span class="ruby-identifier">source</span>
397
+ <span class="ruby-keyword kw">end</span>
398
+
399
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:verbose</span>]
400
+ <span class="ruby-identifier">entries</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
401
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;got #{entry.title}&quot;</span>
402
+ <span class="ruby-keyword kw">end</span>
403
+ <span class="ruby-keyword kw">end</span>
404
+
405
+ <span class="ruby-identifier">entries</span>
406
+ <span class="ruby-keyword kw">end</span>
407
+ </pre>
408
+ </div>
409
+ </div>
410
+ </div>
411
+
412
+ <div id="method-M000035" class="method-detail">
413
+ <a name="M000035"></a>
414
+
415
+ <div class="method-heading">
416
+ <a href="#M000035" class="method-signature">
417
+ <span class="method-name">setup_http</span><span class="method-args">(http, options)</span>
418
+ </a>
419
+ </div>
420
+
421
+ <div class="method-description">
422
+ <p><a class="source-toggle" href="#"
423
+ onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
424
+ <div class="method-source-code" id="M000035-source">
425
+ <pre>
426
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 152</span>
427
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup_http</span> <span class="ruby-identifier">http</span>, <span class="ruby-identifier">options</span>
428
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:user</span>]
429
+ <span class="ruby-identifier">http</span>.<span class="ruby-identifier">user</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:user</span>]
430
+
431
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:pass</span>]
432
+ <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:pass</span>] = <span class="ruby-identifier">obtain_password</span>
433
+ <span class="ruby-keyword kw">end</span>
434
+
435
+ <span class="ruby-identifier">http</span>.<span class="ruby-identifier">pass</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:pass</span>]
436
+ <span class="ruby-keyword kw">end</span>
437
+ <span class="ruby-keyword kw">end</span>
438
+ </pre>
439
+ </div>
440
+ </div>
441
+ </div>
442
+
443
+ <div id="method-M000027" class="method-detail">
444
+ <a name="M000027"></a>
445
+
446
+ <div class="method-heading">
447
+ <a href="#M000027" class="method-signature">
448
+ <span class="method-name">stdin_to_entries</span><span class="method-args">()</span>
449
+ </a>
450
+ </div>
451
+
452
+ <div class="method-description">
453
+ <p>
454
+ parse a Feed on stdin
455
+ </p>
456
+ <p><a class="source-toggle" href="#"
457
+ onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
458
+ <div class="method-source-code" id="M000027-source">
459
+ <pre>
460
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 29</span>
461
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdin_to_entries</span>
462
+ <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Feed</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">$stdin</span>).<span class="ruby-identifier">entries</span>
463
+ <span class="ruby-keyword kw">end</span>
464
+ </pre>
465
+ </div>
466
+ </div>
467
+ </div>
468
+
469
+ <div id="method-M000032" class="method-detail">
470
+ <a name="M000032"></a>
471
+
472
+ <div class="method-heading">
473
+ <a href="#M000032" class="method-signature">
474
+ <span class="method-name">write_output</span><span class="method-args">(entries, dest, options)</span>
475
+ </a>
476
+ </div>
477
+
478
+ <div class="method-description">
479
+ <p>
480
+ turns an Array of Atom::Entrys into a collection of Atom Entries
481
+ </p>
482
+ <p>
483
+ entries: an Array of Atom::Entrys pairs dest: a URL, a directory or
484
+ &quot;-&quot; for an Atom Feed on stdout options:
485
+ </p>
486
+ <pre>
487
+ :user - username to use for HTTP requests (if required)
488
+ :pass - password to use for HTTP requests (if required)
489
+ </pre>
490
+ <p><a class="source-toggle" href="#"
491
+ onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
492
+ <div class="method-source-code" id="M000032-source">
493
+ <pre>
494
+ <span class="ruby-comment cmt"># File lib/atom/tools.rb, line 105</span>
495
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_output</span> <span class="ruby-identifier">entries</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>
496
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dest</span>.<span class="ruby-identifier">match</span> <span class="ruby-regexp re">/^http/</span>
497
+ <span class="ruby-identifier">http</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>
498
+
499
+ <span class="ruby-identifier">setup_http</span> <span class="ruby-identifier">http</span>, <span class="ruby-identifier">options</span>
500
+
501
+ <span class="ruby-identifier">entries_to_http</span> <span class="ruby-identifier">entries</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">http</span>
502
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dest</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'-'</span>
503
+ <span class="ruby-identifier">entries_to_stdout</span> <span class="ruby-identifier">entries</span>
504
+ <span class="ruby-keyword kw">else</span>
505
+ <span class="ruby-identifier">entries_to_dir</span> <span class="ruby-identifier">entries</span>, <span class="ruby-identifier">dest</span>
506
+ <span class="ruby-keyword kw">end</span>
507
+ <span class="ruby-keyword kw">end</span>
508
+ </pre>
509
+ </div>
510
+ </div>
511
+ </div>
512
+
513
+
514
+ </div>
515
+
516
+
517
+ </div>
518
+
519
+
520
+ <div id="validator-badges">
521
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
522
+ </div>
523
+
524
+ </body>
525
+ </html>