roxml 1.0 → 1.1

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 (42) hide show
  1. data/MIT-LICENSE.txt +1 -1
  2. data/README +2 -0
  3. data/lib/roxml.rb +35 -33
  4. data/test/fixtures/book_text_with_attribute.xml +5 -0
  5. data/test/mocks/mocks.rb +12 -0
  6. data/test/test_roxml.rb +7 -0
  7. metadata +6 -49
  8. data/doc/classes/ROXML.html +0 -352
  9. data/doc/classes/ROXML.src/M000003.html +0 -19
  10. data/doc/classes/ROXML.src/M000004.html +0 -25
  11. data/doc/classes/ROXML.src/M000005.html +0 -22
  12. data/doc/classes/ROXML/ROXML_Class.html +0 -422
  13. data/doc/classes/ROXML/ROXML_Class.src/M000006.html +0 -27
  14. data/doc/classes/ROXML/ROXML_Class.src/M000007.html +0 -18
  15. data/doc/classes/ROXML/ROXML_Class.src/M000008.html +0 -19
  16. data/doc/classes/ROXML/ROXML_Class.src/M000009.html +0 -24
  17. data/doc/classes/ROXML/ROXML_Class.src/M000010.html +0 -24
  18. data/doc/classes/ROXML/ROXML_Class.src/M000011.html +0 -18
  19. data/doc/classes/ROXML/ROXML_Class.src/M000012.html +0 -18
  20. data/doc/classes/ROXML/XMLAttributeRef.html +0 -175
  21. data/doc/classes/ROXML/XMLAttributeRef.src/M000015.html +0 -19
  22. data/doc/classes/ROXML/XMLAttributeRef.src/M000016.html +0 -19
  23. data/doc/classes/ROXML/XMLObjectRef.html +0 -175
  24. data/doc/classes/ROXML/XMLObjectRef.src/M000013.html +0 -26
  25. data/doc/classes/ROXML/XMLObjectRef.src/M000014.html +0 -32
  26. data/doc/classes/ROXML/XMLRef.html +0 -212
  27. data/doc/classes/ROXML/XMLRef.src/M000017.html +0 -21
  28. data/doc/classes/ROXML/XMLRef.src/M000018.html +0 -18
  29. data/doc/classes/ROXML/XMLRef.src/M000019.html +0 -18
  30. data/doc/classes/ROXML/XMLTextRef.html +0 -193
  31. data/doc/classes/ROXML/XMLTextRef.src/M000020.html +0 -26
  32. data/doc/classes/ROXML/XMLTextRef.src/M000021.html +0 -33
  33. data/doc/classes/String.html +0 -165
  34. data/doc/classes/String.src/M000001.html +0 -23
  35. data/doc/classes/String.src/M000002.html +0 -23
  36. data/doc/created.rid +0 -1
  37. data/doc/files/lib/roxml_rb.html +0 -234
  38. data/doc/fr_class_index.html +0 -33
  39. data/doc/fr_file_index.html +0 -27
  40. data/doc/fr_method_index.html +0 -47
  41. data/doc/index.html +0 -24
  42. data/doc/rdoc-style.css +0 -208
@@ -1,19 +0,0 @@
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>
7
- <head>
8
- <title>included (ROXML)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/roxml.rb, line 443</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">included</span>(<span class="ruby-identifier">klass</span>)
15
- <span class="ruby-keyword kw">super</span>
16
- <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">:extend</span>, <span class="ruby-constant">ROXML_Class</span>)
17
- <span class="ruby-keyword kw">end</span></pre>
18
- </body>
19
- </html>
@@ -1,25 +0,0 @@
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>
7
- <head>
8
- <title>to_xml (ROXML)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/roxml.rb, line 452</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_xml</span>
15
- <span class="ruby-identifier">root</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-identifier">tag_name</span>)
16
- <span class="ruby-identifier">tag_refs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ref</span><span class="ruby-operator">|</span>
17
- <span class="ruby-identifier">v</span> = <span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">ref</span>.<span class="ruby-identifier">accessor</span>)
18
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>
19
- <span class="ruby-identifier">root</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">update_xml</span>(<span class="ruby-identifier">root</span>, <span class="ruby-identifier">v</span>)
20
- <span class="ruby-keyword kw">end</span>
21
- <span class="ruby-keyword kw">end</span>
22
- <span class="ruby-identifier">root</span>
23
- <span class="ruby-keyword kw">end</span></pre>
24
- </body>
25
- </html>
@@ -1,22 +0,0 @@
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>
7
- <head>
8
- <title>method_missing (ROXML)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/roxml.rb, line 468</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
15
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">id2name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^tag_/</span>
16
- <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
17
- <span class="ruby-keyword kw">else</span>
18
- <span class="ruby-keyword kw">super</span>
19
- <span class="ruby-keyword kw">end</span>
20
- <span class="ruby-keyword kw">end</span></pre>
21
- </body>
22
- </html>
@@ -1,422 +0,0 @@
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: ROXML::ROXML_Class</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">ROXML::ROXML_Class</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/roxml_rb.html">
59
- lib/roxml.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
- This class defines the annotation methods that are mixed into your Ruby
78
- classes for XML mapping information and behavior.
79
- </p>
80
- <p>
81
- See <a href="ROXML_Class.html#M000007">xml_name</a>, <a
82
- href="ROXML_Class.html#M000009">xml_text</a>, <a
83
- href="ROXML_Class.html#M000008">xml_attribute</a> and <a
84
- href="ROXML_Class.html#M000010">xml_object</a> for available annotations.
85
- </p>
86
-
87
- </div>
88
-
89
-
90
- </div>
91
-
92
- <div id="method-list">
93
- <h3 class="section-bar">Methods</h3>
94
-
95
- <div class="name-list">
96
- <a href="#M000006">parse</a>&nbsp;&nbsp;
97
- <a href="#M000011">tag_name</a>&nbsp;&nbsp;
98
- <a href="#M000012">tag_refs</a>&nbsp;&nbsp;
99
- <a href="#M000008">xml_attribute</a>&nbsp;&nbsp;
100
- <a href="#M000007">xml_name</a>&nbsp;&nbsp;
101
- <a href="#M000010">xml_object</a>&nbsp;&nbsp;
102
- <a href="#M000009">xml_text</a>&nbsp;&nbsp;
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 Instance methods</h3>
123
-
124
- <div id="method-M000006" class="method-detail">
125
- <a name="M000006"></a>
126
-
127
- <div class="method-heading">
128
- <a href="ROXML_Class.src/M000006.html" target="Code" class="method-signature"
129
- onclick="popupCode('ROXML_Class.src/M000006.html');return false;">
130
- <span class="method-name">parse</span><span class="method-args">(data)</span>
131
- </a>
132
- </div>
133
-
134
- <div class="method-description">
135
- <p>
136
- Creates a new Ruby object from XML using mapping information annotated in
137
- the class.
138
- </p>
139
- <p>
140
- The input data is either a REXML::Element or a <a
141
- href="../String.html">String</a> representing the XML document.
142
- </p>
143
- <p>
144
- Example
145
- </p>
146
- <pre>
147
- book = Book.parse(File.read(&quot;book.xml&quot;))
148
- </pre>
149
- <p>
150
- or
151
- </p>
152
- <pre>
153
- book = Book.parse(&quot;&lt;book&gt;&lt;name&gt;Beyond Java&lt;/name&gt;&lt;/book&gt;&quot;)
154
- </pre>
155
- </div>
156
- </div>
157
-
158
- <div id="method-M000011" class="method-detail">
159
- <a name="M000011"></a>
160
-
161
- <div class="method-heading">
162
- <a href="ROXML_Class.src/M000011.html" target="Code" class="method-signature"
163
- onclick="popupCode('ROXML_Class.src/M000011.html');return false;">
164
- <span class="method-name">tag_name</span><span class="method-args">()</span>
165
- </a>
166
- </div>
167
-
168
- <div class="method-description">
169
- <p>
170
- Returns the tag name (also known as <a
171
- href="ROXML_Class.html#M000007">xml_name</a>) of the class. If no tag name
172
- is set with <a href="ROXML_Class.html#M000007">xml_name</a> method, returns
173
- default class name in lowercase.
174
- </p>
175
- </div>
176
- </div>
177
-
178
- <div id="method-M000012" class="method-detail">
179
- <a name="M000012"></a>
180
-
181
- <div class="method-heading">
182
- <a href="ROXML_Class.src/M000012.html" target="Code" class="method-signature"
183
- onclick="popupCode('ROXML_Class.src/M000012.html');return false;">
184
- <span class="method-name">tag_refs</span><span class="method-args">()</span>
185
- </a>
186
- </div>
187
-
188
- <div class="method-description">
189
- <p>
190
- Returns array of internal reference objects, such as attributes and
191
- composed XML objects
192
- </p>
193
- </div>
194
- </div>
195
-
196
- <div id="method-M000008" class="method-detail">
197
- <a name="M000008"></a>
198
-
199
- <div class="method-heading">
200
- <a href="ROXML_Class.src/M000008.html" target="Code" class="method-signature"
201
- onclick="popupCode('ROXML_Class.src/M000008.html');return false;">
202
- <span class="method-name">xml_attribute</span><span class="method-args">(sym, name = nil, options = 0)</span>
203
- </a>
204
- </div>
205
-
206
- <div class="method-description">
207
- <p>
208
- Declare an accessor for the included class that should be represented as an
209
- XML attribute.
210
- </p>
211
- <dl>
212
- <dt>sym</dt><dd>Symbol representing the name of the accessor
213
-
214
- </dd>
215
- <dt>name</dt><dd>An optional name that should be used for the attribute in XML. Default is
216
- sym.id2name.
217
-
218
- </dd>
219
- <dt>options</dt><dd>Valid options are TAG_READONLY to attribute as read-only
220
-
221
- </dd>
222
- </dl>
223
- <p>
224
- Example:
225
- </p>
226
- <pre>
227
- class Book
228
- xml_attribute :isbn, &quot;ISBN&quot;
229
- end
230
- </pre>
231
- <p>
232
- To map:
233
- </p>
234
- <pre>
235
- &lt;book ISBN=&quot;0974514055&quot;&gt;&lt;/book&gt;
236
- </pre>
237
- </div>
238
- </div>
239
-
240
- <div id="method-M000007" class="method-detail">
241
- <a name="M000007"></a>
242
-
243
- <div class="method-heading">
244
- <a href="ROXML_Class.src/M000007.html" target="Code" class="method-signature"
245
- onclick="popupCode('ROXML_Class.src/M000007.html');return false;">
246
- <span class="method-name">xml_name</span><span class="method-args">(name)</span>
247
- </a>
248
- </div>
249
-
250
- <div class="method-description">
251
- <p>
252
- Sets the name of the XML element that represents this class. Use this to
253
- override the default lowercase class name.
254
- </p>
255
- <p>
256
- Example:
257
- </p>
258
- <pre>
259
- class BookWithPublisher
260
- xml_name :book
261
- end
262
- </pre>
263
- <p>
264
- Without the <a href="ROXML_Class.html#M000007">xml_name</a> annotation, the
265
- XML mapped tag would have been &quot;bookwithpublisher&quot;.
266
- </p>
267
- </div>
268
- </div>
269
-
270
- <div id="method-M000010" class="method-detail">
271
- <a name="M000010"></a>
272
-
273
- <div class="method-heading">
274
- <a href="ROXML_Class.src/M000010.html" target="Code" class="method-signature"
275
- onclick="popupCode('ROXML_Class.src/M000010.html');return false;">
276
- <span class="method-name">xml_object</span><span class="method-args">(sym, klass, options = 0, wrapper = nil)</span>
277
- </a>
278
- </div>
279
-
280
- <div class="method-description">
281
- <p>
282
- Declares an accessor that represents another <a
283
- href="../ROXML.html">ROXML</a> class as child XML element (one-to-one or
284
- composition) or array of child elements (one-to-many or aggregation).
285
- Default is one-to-one. Use TAG_ARRAY option for one-to-many.
286
- </p>
287
- <dl>
288
- <dt>sym</dt><dd>Symbol representing the name of the accessor.
289
-
290
- </dd>
291
- <dt>name</dt><dd>An optional name that should be used for the attribute in XML. Default is
292
- sym.id2name.
293
-
294
- </dd>
295
- <dt>options</dt><dd>TAG_ARRAY for one-to-many, and TAG_READONLY for read-only access.
296
-
297
- </dd>
298
- <dt>wrapper</dt><dd>An optional name of a wrapping tag for this XML accessor.
299
-
300
- </dd>
301
- </dl>
302
- <p>
303
- Composition example:
304
- </p>
305
- <pre>
306
- &lt;book&gt;
307
- &lt;publisher&gt;
308
- &lt;name&gt;Pragmatic Bookshelf&lt;/name&gt;
309
- &lt;/publisher&gt;
310
- &lt;/book&gt;
311
- </pre>
312
- <p>
313
- Can be mapped using the following code:
314
- </p>
315
- <pre>
316
- class Book
317
- xml_object :publisher, Publisher
318
- end
319
- </pre>
320
- <p>
321
- Aggregation example:
322
- </p>
323
- <pre>
324
- &lt;library&gt;
325
- &lt;name&gt;Ruby books&lt;/name&gt;
326
- &lt;books&gt;
327
- &lt;book/&gt;
328
- &lt;book/&gt;
329
- &lt;/books&gt;
330
- &lt;/library&gt;
331
- </pre>
332
- <p>
333
- Can be mapped using the following code:
334
- </p>
335
- <pre>
336
- class Library
337
- xml_text :name, nil, ROXML::TAG_CDATA
338
- xml_object :books, Book, ROXML::TAG_ARRAY, &quot;books&quot;
339
- end
340
- </pre>
341
- <p>
342
- If you don&#8217;t have the &lt;books&gt; tag to wrap around the list of
343
- &lt;book&gt; tags:
344
- </p>
345
- <pre>
346
- &lt;library&gt;
347
- &lt;name&gt;Ruby books&lt;/name&gt;
348
- &lt;book/&gt;
349
- &lt;book/&gt;
350
- &lt;/library&gt;
351
- </pre>
352
- <p>
353
- You can skip the wrapper argument:
354
- </p>
355
- <pre>
356
- xml_object :books, Book, ROXML::TAG_ARRAY
357
- </pre>
358
- </div>
359
- </div>
360
-
361
- <div id="method-M000009" class="method-detail">
362
- <a name="M000009"></a>
363
-
364
- <div class="method-heading">
365
- <a href="ROXML_Class.src/M000009.html" target="Code" class="method-signature"
366
- onclick="popupCode('ROXML_Class.src/M000009.html');return false;">
367
- <span class="method-name">xml_text</span><span class="method-args">(sym, name = nil, options = 0, wrapper = nil)</span>
368
- </a>
369
- </div>
370
-
371
- <div class="method-description">
372
- <p>
373
- Declares an accessor that represents one or more XML text elements.
374
- </p>
375
- <dl>
376
- <dt>sym</dt><dd>Symbol representing the name of the accessor.
377
-
378
- </dd>
379
- <dt>name</dt><dd>An optional name that should be used for the attribute in XML. Default is
380
- sym.id2name.
381
-
382
- </dd>
383
- <dt>options</dt><dd>TAG_CDATA for character data, TAG_ARRAY for one-to-many, and TAG_READONLY
384
- for read-only access.
385
-
386
- </dd>
387
- <dt>wrapper</dt><dd>An optional name of a wrapping tag for this XML accessor.
388
-
389
- </dd>
390
- </dl>
391
- <p>
392
- Example:
393
- </p>
394
- <pre>
395
- class Book
396
- xml_text :description, nil, ROXML::TAG_CDATA
397
- end
398
- </pre>
399
- <p>
400
- To map:
401
- </p>
402
- <pre>
403
- &lt;book&gt;
404
- &lt;description&gt;&lt;![CDATA[Probably the best Ruby book out there]]&gt;&lt;/description&gt;
405
- &lt;/book&gt;
406
- </pre>
407
- </div>
408
- </div>
409
-
410
-
411
- </div>
412
-
413
-
414
- </div>
415
-
416
-
417
- <div id="validator-badges">
418
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
419
- </div>
420
-
421
- </body>
422
- </html>