atom-tools 0.9.0 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. data/COPYING +3 -3
  2. data/README +9 -49
  3. data/Rakefile +65 -62
  4. data/bin/atom-cp +159 -0
  5. data/bin/atom-grep +78 -0
  6. data/bin/atom-post +73 -0
  7. data/bin/atom-purge +82 -0
  8. data/doc/classes/Atom/AttrEl.html +163 -0
  9. data/doc/classes/Atom/Author.html +2 -19
  10. data/doc/classes/Atom/AutodiscoveryFailure.html +111 -0
  11. data/doc/classes/Atom/Categories.html +168 -0
  12. data/doc/classes/Atom/Category.html +10 -1
  13. data/doc/classes/Atom/Collection.html +194 -91
  14. data/doc/classes/Atom/Content.html +42 -1
  15. data/doc/classes/Atom/Contributor.html +2 -8
  16. data/doc/classes/Atom/Control.html +126 -0
  17. data/doc/classes/Atom/Converters.html +571 -0
  18. data/doc/classes/Atom/DigestAuth.html +285 -0
  19. data/doc/classes/Atom/Element.html +673 -106
  20. data/doc/classes/Atom/FileCache.html +287 -0
  21. data/doc/classes/Atom/HTTP.html +211 -95
  22. data/doc/classes/Atom/HTTPResponse.html +190 -0
  23. data/doc/classes/Atom/HasCategories.html +187 -0
  24. data/doc/classes/Atom/HasLinks.html +168 -0
  25. data/doc/classes/Atom/Link.html +80 -3
  26. data/doc/classes/Atom/NilCache.html +202 -0
  27. data/doc/classes/Atom/ParseError.html +111 -0
  28. data/doc/classes/Atom/Parsers.html +311 -0
  29. data/doc/classes/Atom/Person.html +130 -0
  30. data/doc/classes/Atom/Rights.html +113 -0
  31. data/doc/classes/Atom/Service.html +298 -0
  32. data/doc/{files/lib/atom/yaml_rb.html → classes/Atom/Source.html} +26 -24
  33. data/doc/classes/Atom/Subtitle.html +113 -0
  34. data/doc/classes/Atom/Summary.html +113 -0
  35. data/doc/classes/Atom/Text.html +196 -53
  36. data/doc/classes/Atom/Title.html +113 -0
  37. data/doc/classes/Atom/Tools.html +525 -0
  38. data/doc/classes/Atom/Workspace.html +121 -0
  39. data/doc/classes/Object.html +204 -0
  40. data/doc/created.rid +1 -1
  41. data/doc/files/README.html +9 -49
  42. data/doc/files/lib/atom/cache_rb.html +302 -0
  43. data/doc/files/lib/atom/collection_rb.html +1 -2
  44. data/doc/files/lib/atom/element_rb.html +2 -1
  45. data/doc/files/lib/atom/entry_rb.html +2 -2
  46. data/doc/files/lib/atom/feed_rb.html +1 -2
  47. data/doc/files/lib/atom/http_rb.html +6 -1
  48. data/doc/files/lib/atom/{xml_rb.html → service_rb.html} +8 -6
  49. data/doc/files/lib/atom/text_rb.html +2 -1
  50. data/doc/files/lib/atom/{app_rb.html → tools_rb.html} +4 -6
  51. data/doc/fr_class_index.html +23 -3
  52. data/doc/fr_file_index.html +3 -3
  53. data/doc/fr_method_index.html +111 -36
  54. data/lib/atom/cache.rb +178 -0
  55. data/lib/atom/collection.rb +90 -40
  56. data/lib/atom/element.rb +569 -161
  57. data/lib/atom/entry.rb +63 -89
  58. data/lib/atom/feed.rb +65 -67
  59. data/lib/atom/http.rb +421 -49
  60. data/lib/atom/service.rb +106 -0
  61. data/lib/atom/text.rb +138 -61
  62. data/lib/atom/tools.rb +163 -0
  63. data/spec/entry_spec.rb +364 -0
  64. data/spec/ext_spec.rb +42 -0
  65. data/spec/feed_spec.rb +39 -0
  66. data/spec/fixtures/contacts-feed.xml +34 -0
  67. data/spec/fixtures/entry-w-ext.xml +15 -0
  68. data/spec/fixtures/entry-w-xml.xml +24 -0
  69. data/spec/fixtures/entry.xml +42 -0
  70. data/spec/fixtures/feed-w-ext.xml +33 -0
  71. data/spec/fixtures/service-w-xhtml-ns.xml +21 -0
  72. data/spec/fixtures/service.xml +36 -0
  73. data/spec/service_spec.rb +108 -0
  74. data/spec/spec_helper.rb +9 -0
  75. data/test/conformance/order.rb +11 -10
  76. data/test/conformance/title.rb +9 -9
  77. data/test/conformance/updated.rb +2 -1
  78. data/test/runtests.rb +0 -0
  79. data/test/test_constructs.rb +78 -8
  80. data/test/test_feed.rb +35 -29
  81. data/test/test_general.rb +3 -30
  82. data/test/test_http.rb +248 -34
  83. data/test/test_protocol.rb +143 -24
  84. data/test/test_xml.rb +145 -53
  85. metadata +116 -62
  86. data/bin/atom-client.rb +0 -246
  87. data/bin/atom-server.rb~ +0 -71
  88. data/doc/classes/Atom/App.html +0 -217
  89. data/doc/classes/Atom/Entry.html +0 -365
  90. data/doc/classes/Atom/Feed.html +0 -585
  91. data/lib/atom/app.rb +0 -87
  92. data/lib/atom/xml.rb +0 -200
  93. data/lib/atom/yaml.rb +0 -101
@@ -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::Subtitle</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::Subtitle</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,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::Summary</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::Summary</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>
@@ -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/yaml_rb.html">
59
- lib/atom/yaml.rb
60
- </a>
61
- <br />
62
58
  <a href="../../files/lib/atom/text_rb.html">
63
59
  lib/atom/text.rb
64
60
  </a>
@@ -87,8 +83,29 @@
87
83
  <div id="description">
88
84
  <p>
89
85
  An <a href="Element.html">Atom::Element</a> representing a text construct.
90
- It has a single attribute, &quot;type&quot;, which accepts values
91
- &quot;text&quot;, &quot;html&quot; and &quot;xhtml&quot;
86
+ It has a single attribute, &quot;<a
87
+ href="Text.html#M000052">type</a>&quot;, which specifies how to interpret
88
+ the element&#8216;s content. Different types are:
89
+ </p>
90
+ <table>
91
+ <tr><td valign="top">text:</td><td>a plain string, without any markup (default)
92
+
93
+ </td></tr>
94
+ <tr><td valign="top"><a href="Text.html#M000054">html</a>:</td><td>a chunk of HTML
95
+
96
+ </td></tr>
97
+ <tr><td valign="top">xhtml:</td><td>a chunk of *well-formed* <a href="../XHTML.html">XHTML</a>
98
+
99
+ </td></tr>
100
+ </table>
101
+ <p>
102
+ You should set this attribute appropriately after you set a <a
103
+ href="Text.html">Text</a> element (entry.content, entry.title or
104
+ entry.summary).
105
+ </p>
106
+ <p>
107
+ This content of this element can be retrieved in different formats, see <a
108
+ href="Text.html#M000054">html</a> and <a href="Text.html#M000055">xml</a>
92
109
  </p>
93
110
 
94
111
  </div>
@@ -100,9 +117,12 @@ It has a single attribute, &quot;type&quot;, which accepts values
100
117
  <h3 class="section-bar">Methods</h3>
101
118
 
102
119
  <div class="name-list">
103
- <a href="#M000017">html</a>&nbsp;&nbsp;
104
- <a href="#M000016">to_s</a>&nbsp;&nbsp;
105
- <a href="#M000018">xml</a>&nbsp;&nbsp;
120
+ <a href="#M000054">html</a>&nbsp;&nbsp;
121
+ <a href="#M000051">new</a>&nbsp;&nbsp;
122
+ <a href="#M000053">to_s</a>&nbsp;&nbsp;
123
+ <a href="#M000052">type</a>&nbsp;&nbsp;
124
+ <a href="#M000056">type=</a>&nbsp;&nbsp;
125
+ <a href="#M000055">xml</a>&nbsp;&nbsp;
106
126
  </div>
107
127
  </div>
108
128
 
@@ -110,6 +130,13 @@ It has a single attribute, &quot;type&quot;, which accepts values
110
130
 
111
131
 
112
132
  <!-- if includes -->
133
+ <div id="includes">
134
+ <h3 class="section-bar">Included Modules</h3>
135
+
136
+ <div id="includes-list">
137
+ <span class="include-name"><a href="AttrEl.html">AttrEl</a></span>
138
+ </div>
139
+ </div>
113
140
 
114
141
  <div id="section">
115
142
 
@@ -122,93 +149,209 @@ It has a single attribute, &quot;type&quot;, which accepts values
122
149
 
123
150
  <!-- if method_list -->
124
151
  <div id="methods">
152
+ <h3 class="section-bar">Public Class methods</h3>
153
+
154
+ <div id="method-M000051" class="method-detail">
155
+ <a name="M000051"></a>
156
+
157
+ <div class="method-heading">
158
+ <a href="#M000051" class="method-signature">
159
+ <span class="method-name">new</span><span class="method-args">(value = nil)</span>
160
+ </a>
161
+ </div>
162
+
163
+ <div class="method-description">
164
+ <p><a class="source-toggle" href="#"
165
+ onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
166
+ <div class="method-source-code" id="M000051-source">
167
+ <pre>
168
+ <span class="ruby-comment cmt"># File lib/atom/text.rb, line 73</span>
169
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>
170
+ <span class="ruby-keyword kw">super</span>()
171
+
172
+ <span class="ruby-ivar">@content</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:to_xml</span>
173
+ <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_xml</span>[<span class="ruby-value">0</span>]
174
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">value</span>
175
+ <span class="ruby-identifier">value</span>
176
+ <span class="ruby-keyword kw">else</span>
177
+ <span class="ruby-value str">''</span>
178
+ <span class="ruby-keyword kw">end</span>
179
+ <span class="ruby-keyword kw">end</span>
180
+ </pre>
181
+ </div>
182
+ </div>
183
+ </div>
184
+
125
185
  <h3 class="section-bar">Public Instance methods</h3>
126
186
 
127
- <div id="method-M000017" class="method-detail">
128
- <a name="M000017"></a>
187
+ <div id="method-M000054" class="method-detail">
188
+ <a name="M000054"></a>
129
189
 
130
190
  <div class="method-heading">
131
- <a href="#M000017" class="method-signature">
191
+ <a href="#M000054" class="method-signature">
132
192
  <span class="method-name">html</span><span class="method-args">()</span>
133
193
  </a>
134
194
  </div>
135
195
 
136
196
  <div class="method-description">
137
197
  <p>
138
- returns a string suitable for dumping into an HTML document
198
+ returns a string suitable for dumping into an HTML document.
199
+ </p>
200
+ <pre>
201
+ (or nil if that's impossible)
202
+ </pre>
203
+ <p>
204
+ if you&#8216;re storing the content of a <a href="Text.html">Text</a>
205
+ construct, you probably want this representation.
139
206
  </p>
140
207
  <p><a class="source-toggle" href="#"
141
- onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
142
- <div class="method-source-code" id="M000017-source">
208
+ onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
209
+ <div class="method-source-code" id="M000054-source">
143
210
  <pre>
144
- <span class="ruby-comment cmt"># File lib/atom/text.rb, line 32</span>
145
- 32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">html</span>
146
- 33: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span> <span class="ruby-keyword kw">or</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;html&quot;</span>
147
- 34: <span class="ruby-identifier">to_s</span>
148
- 35: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;text&quot;</span>
149
- 36: <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_s</span>
150
- 37: <span class="ruby-keyword kw">end</span>
151
- 38: <span class="ruby-keyword kw">end</span>
211
+ <span class="ruby-comment cmt"># File lib/atom/text.rb, line 102</span>
212
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">html</span>
213
+ <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span> <span class="ruby-keyword kw">or</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;html&quot;</span>
214
+ <span class="ruby-identifier">to_s</span>
215
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;text&quot;</span>
216
+ <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_s</span>
217
+ <span class="ruby-keyword kw">end</span>
218
+ <span class="ruby-keyword kw">end</span>
152
219
  </pre>
153
220
  </div>
154
221
  </div>
155
222
  </div>
156
223
 
157
- <div id="method-M000016" class="method-detail">
158
- <a name="M000016"></a>
224
+ <div id="method-M000053" class="method-detail">
225
+ <a name="M000053"></a>
159
226
 
160
227
  <div class="method-heading">
161
- <a href="#M000016" class="method-signature">
228
+ <a href="#M000053" class="method-signature">
162
229
  <span class="method-name">to_s</span><span class="method-args">()</span>
163
230
  </a>
164
231
  </div>
165
232
 
166
233
  <div class="method-description">
167
234
  <p><a class="source-toggle" href="#"
168
- onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
169
- <div class="method-source-code" id="M000016-source">
235
+ onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
236
+ <div class="method-source-code" id="M000053-source">
170
237
  <pre>
171
- <span class="ruby-comment cmt"># File lib/atom/text.rb, line 23</span>
172
- 23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
173
- 24: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span>
174
- 25: <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">to_s</span>
175
- 26: <span class="ruby-keyword kw">else</span>
176
- 27: <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">to_s</span>
177
- 28: <span class="ruby-keyword kw">end</span>
178
- 29: <span class="ruby-keyword kw">end</span>
238
+ <span class="ruby-comment cmt"># File lib/atom/text.rb, line 89</span>
239
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
240
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'xhtml'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@content</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'div'</span>
241
+ <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">to_s</span>
242
+ <span class="ruby-keyword kw">else</span>
243
+ <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">to_s</span>
244
+ <span class="ruby-keyword kw">end</span>
245
+ <span class="ruby-keyword kw">end</span>
179
246
  </pre>
180
247
  </div>
181
248
  </div>
182
249
  </div>
183
250
 
184
- <div id="method-M000018" class="method-detail">
185
- <a name="M000018"></a>
251
+ <div id="method-M000052" class="method-detail">
252
+ <a name="M000052"></a>
186
253
 
187
254
  <div class="method-heading">
188
- <a href="#M000018" class="method-signature">
255
+ <a href="#M000052" class="method-signature">
256
+ <span class="method-name">type</span><span class="method-args">()</span>
257
+ </a>
258
+ </div>
259
+
260
+ <div class="method-description">
261
+ <p><a class="source-toggle" href="#"
262
+ onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
263
+ <div class="method-source-code" id="M000052-source">
264
+ <pre>
265
+ <span class="ruby-comment cmt"># File lib/atom/text.rb, line 85</span>
266
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">type</span>
267
+ <span class="ruby-ivar">@type</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@type</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'text'</span>
268
+ <span class="ruby-keyword kw">end</span>
269
+ </pre>
270
+ </div>
271
+ </div>
272
+ </div>
273
+
274
+ <div id="method-M000056" class="method-detail">
275
+ <a name="M000056"></a>
276
+
277
+ <div class="method-heading">
278
+ <a href="#M000056" class="method-signature">
279
+ <span class="method-name">type=</span><span class="method-args">(value)</span>
280
+ </a>
281
+ </div>
282
+
283
+ <div class="method-description">
284
+ <p><a class="source-toggle" href="#"
285
+ onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
286
+ <div class="method-source-code" id="M000056-source">
287
+ <pre>
288
+ <span class="ruby-comment cmt"># File lib/atom/text.rb, line 143</span>
289
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">type=</span> <span class="ruby-identifier">value</span>
290
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_type?</span> <span class="ruby-identifier">value</span>
291
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span>, <span class="ruby-node">&quot;atomTextConstruct type '#{value}' is meaningless&quot;</span>
292
+ <span class="ruby-keyword kw">end</span>
293
+
294
+ <span class="ruby-ivar">@type</span> = <span class="ruby-identifier">value</span>
295
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span>
296
+ <span class="ruby-keyword kw">begin</span>
297
+ <span class="ruby-identifier">parse_xhtml_content</span>
298
+ <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseException</span>
299
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span>, <span class="ruby-node">&quot;#{@content.inspect} can't be parsed as XML&quot;</span>
300
+ <span class="ruby-keyword kw">end</span>
301
+ <span class="ruby-keyword kw">end</span>
302
+ <span class="ruby-keyword kw">end</span>
303
+ </pre>
304
+ </div>
305
+ </div>
306
+ </div>
307
+
308
+ <div id="method-M000055" class="method-detail">
309
+ <a name="M000055"></a>
310
+
311
+ <div class="method-heading">
312
+ <a href="#M000055" class="method-signature">
189
313
  <span class="method-name">xml</span><span class="method-args">()</span>
190
314
  </a>
191
315
  </div>
192
316
 
193
317
  <div class="method-description">
194
318
  <p>
195
- attepts to parse the content and return it as an array of REXML::Elements
319
+ attempts to parse the content of this element as XML and return it as an
320
+ array of REXML::Elements.
321
+ </p>
322
+ <p>
323
+ If self[&quot;<a href="Text.html#M000052">type</a>&quot;] is &quot;<a
324
+ href="Text.html#M000054">html</a>&quot; and Hpricot is installed, it will
325
+ be converted to <a href="../XHTML.html">XHTML</a> first.
196
326
  </p>
197
327
  <p><a class="source-toggle" href="#"
198
- onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
199
- <div class="method-source-code" id="M000018-source">
328
+ onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
329
+ <div class="method-source-code" id="M000055-source">
200
330
  <pre>
201
- <span class="ruby-comment cmt"># File lib/atom/text.rb, line 41</span>
202
- 41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">xml</span>
203
- 42: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span>
204
- 43: <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">children</span>
205
- 44: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;text&quot;</span>
206
- 45: [<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>]
207
- 46: <span class="ruby-keyword kw">else</span>
208
- 47: <span class="ruby-comment cmt"># XXX - hpricot goes here?</span>
209
- 48: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;I haven't implemented this yet&quot;</span>
210
- 49: <span class="ruby-keyword kw">end</span>
211
- 50: <span class="ruby-keyword kw">end</span>
331
+ <span class="ruby-comment cmt"># File lib/atom/text.rb, line 115</span>
332
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">xml</span>
333
+ <span class="ruby-identifier">xml</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span> <span class="ruby-value str">'div'</span>
334
+
335
+ <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xhtml&quot;</span>
336
+ <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">child</span> }
337
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;text&quot;</span>
338
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">text</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
339
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;html&quot;</span>
340
+ <span class="ruby-keyword kw">begin</span>
341
+ <span class="ruby-identifier">require</span> <span class="ruby-value str">&quot;hpricot&quot;</span>
342
+ <span class="ruby-keyword kw">rescue</span>
343
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Turning HTML content into XML requires Hpricot.&quot;</span>
344
+ <span class="ruby-keyword kw">end</span>
345
+
346
+ <span class="ruby-identifier">fixed</span> = <span class="ruby-constant">Hpricot</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">:xhtml_strict</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>)
347
+ <span class="ruby-identifier">xml</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;&lt;div&gt;#{fixed}&lt;/div&gt;&quot;</span>).<span class="ruby-identifier">root</span>
348
+ <span class="ruby-keyword kw">else</span>
349
+ <span class="ruby-comment cmt"># Not XHTML, HTML, or text - return the REXML::Element, leave it up to the user to parse the content</span>
350
+ <span class="ruby-identifier">xml</span> = <span class="ruby-ivar">@content</span>
351
+ <span class="ruby-keyword kw">end</span>
352
+
353
+ <span class="ruby-identifier">xml</span>
354
+ <span class="ruby-keyword kw">end</span>
212
355
  </pre>
213
356
  </div>
214
357
  </div>