Empact-roxml 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/History.txt +17 -0
  2. data/MIT-LICENSE +1 -1
  3. data/Manifest.txt +27 -6
  4. data/Rakefile +1 -1
  5. data/TODO +33 -14
  6. data/config/website.yml +2 -0
  7. data/examples/amazon.rb +33 -0
  8. data/examples/current_weather.rb +27 -0
  9. data/examples/dashed_elements.rb +20 -0
  10. data/examples/posts.rb +27 -0
  11. data/examples/twitter.rb +37 -0
  12. data/examples/xml/amazon.xml +133 -0
  13. data/examples/xml/current_weather.xml +89 -0
  14. data/examples/xml/dashed_elements.xml +52 -0
  15. data/examples/xml/posts.xml +23 -0
  16. data/examples/xml/twitter.xml +422 -0
  17. data/lib/roxml.rb +31 -5
  18. data/lib/roxml/{options.rb → definition.rb} +60 -88
  19. data/lib/roxml/extensions.rb +3 -0
  20. data/lib/roxml/hash_definition.rb +59 -0
  21. data/lib/roxml/xml.rb +15 -272
  22. data/lib/roxml/xml/{libxml.rb → parsers/libxml.rb} +13 -5
  23. data/lib/roxml/xml/{rexml.rb → parsers/rexml.rb} +13 -4
  24. data/lib/roxml/xml/references.rb +290 -0
  25. data/roxml.gemspec +4 -4
  26. data/spec/examples/amazon_spec.rb +53 -0
  27. data/spec/examples/current_weather_spec.rb +37 -0
  28. data/spec/examples/dashed_elements_spec.rb +20 -0
  29. data/spec/examples/post_spec.rb +24 -0
  30. data/spec/examples/twitter_spec.rb +32 -0
  31. data/spec/spec.opts +1 -0
  32. data/spec/spec_helper.rb +12 -0
  33. data/tasks/rspec.rake +21 -0
  34. data/test/unit/definition_test.rb +160 -0
  35. data/test/unit/inheritance_test.rb +22 -1
  36. data/test/unit/roxml_test.rb +30 -1
  37. data/test/unit/xml_name_test.rb +29 -0
  38. data/test/unit/xml_namespace_test.rb +38 -1
  39. data/website/index.html +98 -0
  40. metadata +30 -9
  41. data/html/index.html +0 -278
  42. data/html/style.css +0 -79
  43. data/test/unit/options_test.rb +0 -103
@@ -0,0 +1,98 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+
8
+ <title>Empact/roxml @ GitHub</title>
9
+
10
+ <style type="text/css">
11
+ body {
12
+ margin-top: 1.0em;
13
+ background-color: #baafdb;
14
+ font-family: "helvetica";
15
+ color: #000000;
16
+ }
17
+ #container {
18
+ margin: 0 auto;
19
+ width: 700px;
20
+ }
21
+ h1 { font-size: 3.8em; color: #455024; margin-bottom: 3px; }
22
+ h1 .small { font-size: 0.4em; }
23
+ h1 a { text-decoration: none }
24
+ h2 { font-size: 1.5em; color: #455024; }
25
+ h3 { text-align: center; color: #455024; }
26
+ a { color: #455024; }
27
+ .description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;}
28
+ .download { float: right; }
29
+ pre { background: #000; color: #fff; padding: 15px;}
30
+ hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
31
+ .footer { text-align:center; padding-top:30px; font-style: italic; }
32
+ </style>
33
+
34
+ </head>
35
+
36
+ <body>
37
+ <a href="http://github.com/Empact/roxml"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
38
+
39
+ <div id="container">
40
+
41
+ <div class="download">
42
+ <a href="http://github.com/Empact/roxml/zipball/master">
43
+ <img border="0" width="90" src="http://github.com/images/modules/download/zip.png"></a>
44
+ <a href="http://github.com/Empact/roxml/tarball/master">
45
+ <img border="0" width="90" src="http://github.com/images/modules/download/tar.png"></a>
46
+ </div>
47
+
48
+ <h1><a href="http://github.com/Empact/roxml">roxml</a>
49
+ <span class="small">by <a href="http://github.com/Empact">Empact</a></small></h1>
50
+
51
+ <div class="description">
52
+ ROXML is a module for binding Ruby classes to XML. It supports custom mapping and bidirectional marshaling between Ruby and XML using annotation-style class methods. ROXML supports the LibXML and REXML XML processors.
53
+ </div>
54
+
55
+ <p>We may not want to work with XML, but we don't always get to pick just how our data comes. If you do need to do serious work with XML, ROXML is here to make it nice.
56
+
57
+ Use xpath-based xml declarations to map an XML response into an extensible object, use that object, and then ouput it back to xml as it came.
58
+
59
+ Aside from the basics, ROXML has a lot of little goodies to make these definitions minimal and readable, which are worth digging in for. See the 'xml_convention' method for easily referencing xml which uses other naming conventions. See the handling of '?' in accessor names, the application of blocks and such for other manipulations.
60
+
61
+ And finally, if you use this library, feel free to push code back my way. I'll be looking forward to it.</p><h2>Dependencies</h2>
62
+ <p>activesupport >= 2.1.0</p>
63
+ <h2>Install</h2>
64
+ <p>'gem install roxml' will install the latest stable <a href="http://rubyforge.org/frs/?group_id=305">rubyforge version</a></p>
65
+ <h2>License</h2>
66
+ <p>MIT License</p>
67
+ <h2>Authors</h2>
68
+ <p>Ben Woosley (ben.woosley@gmail.com)
69
+ <br/>Anders Engström (anders.engstrom@gnejs.net)
70
+ <br/>James Thompson (james@plainprograms.com)
71
+ <br/>James Healy (jimmy@deefa.com)
72
+ <br/>Zak Mandhro (mandhro@yahoo.com)
73
+ <br/>Russ Olsen (russell.olsen@gmail.com)</p>
74
+ <h2>Contact</h2>
75
+ <p>Ben Woosley (Ben.Woosley@gmail.com)
76
+ <br/> </p>
77
+
78
+
79
+ <h2>Download</h2>
80
+ <p>
81
+ You can download this project in either
82
+ <a href="http://github.com/Empact/roxml/zipball/master">zip</a> or
83
+ <a href="http://github.com/Empact/roxml/tarball/master">tar</a> formats.
84
+ </p>
85
+ <p>You can also clone the project with <a href="http://git-scm.com">Git</a>
86
+ by running:
87
+ <pre>$ git clone git://github.com/Empact/roxml</pre>
88
+ </p>
89
+
90
+ <div class="footer">
91
+ get the source code on GitHub : <a href="http://github.com/Empact/roxml">Empact/roxml</a>
92
+ </div>
93
+
94
+ </div>
95
+
96
+
97
+ </body>
98
+ </html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Empact-roxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Woosley
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-01-28 00:00:00 -08:00
15
+ date: 2009-01-31 00:00:00 -08:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -59,9 +59,20 @@ files:
59
59
  - README.rdoc
60
60
  - Rakefile
61
61
  - TODO
62
- - html/index.html
63
- - html/style.css
62
+ - config/website.yml
63
+ - examples/amazon.rb
64
+ - examples/current_weather.rb
65
+ - examples/dashed_elements.rb
66
+ - examples/posts.rb
67
+ - examples/twitter.rb
68
+ - examples/xml/amazon.xml
69
+ - examples/xml/current_weather.xml
70
+ - examples/xml/dashed_elements.xml
71
+ - examples/xml/posts.xml
72
+ - examples/xml/twitter.xml
64
73
  - lib/roxml.rb
74
+ - lib/roxml/definition.rb
75
+ - lib/roxml/extensions.rb
65
76
  - lib/roxml/extensions/active_support.rb
66
77
  - lib/roxml/extensions/array.rb
67
78
  - lib/roxml/extensions/array/conversions.rb
@@ -69,11 +80,20 @@ files:
69
80
  - lib/roxml/extensions/string.rb
70
81
  - lib/roxml/extensions/string/conversions.rb
71
82
  - lib/roxml/extensions/string/iterators.rb
72
- - lib/roxml/options.rb
83
+ - lib/roxml/hash_definition.rb
73
84
  - lib/roxml/xml.rb
74
- - lib/roxml/xml/libxml.rb
75
- - lib/roxml/xml/rexml.rb
85
+ - lib/roxml/xml/parsers/libxml.rb
86
+ - lib/roxml/xml/parsers/rexml.rb
87
+ - lib/roxml/xml/references.rb
76
88
  - roxml.gemspec
89
+ - spec/examples/amazon_spec.rb
90
+ - spec/examples/current_weather_spec.rb
91
+ - spec/examples/dashed_elements_spec.rb
92
+ - spec/examples/post_spec.rb
93
+ - spec/examples/twitter_spec.rb
94
+ - spec/spec.opts
95
+ - spec/spec_helper.rb
96
+ - tasks/rspec.rake
77
97
  - tasks/test.rake
78
98
  - test/bugs/rexml_bugs.rb
79
99
  - test/fixtures/book_malformed.xml
@@ -111,9 +131,9 @@ files:
111
131
  - test/release/dependencies_test.rb
112
132
  - test/test_helper.rb
113
133
  - test/unit/array_test.rb
134
+ - test/unit/definition_test.rb
114
135
  - test/unit/freeze_test.rb
115
136
  - test/unit/inheritance_test.rb
116
- - test/unit/options_test.rb
117
137
  - test/unit/overriden_output_test.rb
118
138
  - test/unit/roxml_test.rb
119
139
  - test/unit/string_test.rb
@@ -134,6 +154,7 @@ files:
134
154
  - vendor/override_rake_task/init.rb
135
155
  - vendor/override_rake_task/install.rb
136
156
  - vendor/override_rake_task/lib/override_rake_task.rb
157
+ - website/index.html
137
158
  has_rdoc: true
138
159
  homepage: http://roxml.rubyforge.org
139
160
  post_install_message:
@@ -170,8 +191,8 @@ test_files:
170
191
  - test/unit/xml_bool_test.rb
171
192
  - test/unit/roxml_test.rb
172
193
  - test/unit/xml_name_test.rb
194
+ - test/unit/definition_test.rb
173
195
  - test/unit/xml_construct_test.rb
174
- - test/unit/options_test.rb
175
196
  - test/unit/string_test.rb
176
197
  - test/unit/xml_namespace_test.rb
177
198
  - test/unit/xml_text_test.rb
data/html/index.html DELETED
@@ -1,278 +0,0 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
- <html>
3
- <head>
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
- <link rel="stylesheet" type="text/css" media="screen" href="style.css">
12
-
13
-
14
-
15
-
16
-
17
-
18
- <title>ROXML - Ruby Object to XML Mapping Library</title>
19
- </head>
20
-
21
-
22
- <body>
23
-
24
-
25
-
26
-
27
- <div id="header" class="contentBlock">
28
- <h1>ROXML - Ruby Object to XML Mapping Library</h1>
29
-
30
-
31
-
32
-
33
- </div>
34
-
35
-
36
-
37
-
38
- <div class="quickLinks"> <a href="#download">Download</a>
39
- <a href="#quickstart">Quick Start Guide</a> <a href="http://rubyforge.org/projects/roxml">RubyForge Project
40
- Site</a>
41
- </div>
42
-
43
-
44
-
45
-
46
- <div class="contentBlock">
47
- <p>ROXML is a <a href="http://ruby-lang.org/" title="Main Ruby Website">Ruby</a>&nbsp;library
48
- designed to make it easier for Ruby developers to work with <a href="http://en.wikipedia.org/wiki/XML">XML</a>.
49
- Using
50
- simple annotations, it enables Ruby classes to be custom-mapped to XML. ROXML
51
- takes care of the marshalling and unmarshalling of mapped attributes so
52
- that developers can focus on building first-class Ruby classes. As a
53
- result, ROXML <span class="highlight">simplifies the
54
- development of <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">RESTful</a>&nbsp;applications,
55
- <a href="http://en.wikipedia.org/wiki/Web_Services">Web
56
- Services</a>, and <a href="http://en.wikipedia.org/wiki/XML-RPC">XML-RPC</a>.</span></p>
57
-
58
-
59
-
60
-
61
- <p>ROXML leverages the <a href="http://www.germane-software.com/software/rexml/">REXML</a>
62
- Ruby XML processor. ROXML powers the <a href="http://rubyforge.org/projects/uddi4r">uddi4r -
63
- UDDI&nbsp;for Ruby</a> project.</p>
64
-
65
-
66
-
67
-
68
- <h2>ROXML 1.0 Features</h2>
69
-
70
-
71
-
72
-
73
- ROXML 1.0 provides the following capabilities:<br>
74
-
75
-
76
-
77
-
78
- <ul>
79
-
80
-
81
-
82
-
83
- <li>Read Ruby objects from XML (marshal)</li>
84
-
85
-
86
-
87
-
88
- <li>Write Ruby objects to XML (unmarshal)</li>
89
-
90
-
91
-
92
-
93
- <li>Smart defaults for XML mapping</li>
94
-
95
-
96
-
97
-
98
- <li>Annotation-style methods (also known as macros) for XML
99
- mapping</li>
100
-
101
-
102
-
103
-
104
- <li>One-to-one (composition) Ruby to XML</li>
105
-
106
-
107
-
108
-
109
- <li>One-to-many (aggregation) Ruby with array to XML</li>
110
-
111
-
112
-
113
-
114
- <li>UTF-8 support for multi-lingual documents</li>
115
-
116
-
117
-
118
-
119
- </ul>
120
-
121
-
122
- <h2>ROXML 1.1 Features</h2>
123
-
124
-
125
-
126
-
127
- ROXML 1.1&nbsp;adds the following new capabilities:
128
- <ul>
129
- <li>Handling text elements with attributes</li>
130
- <li>Support for mapped Ruby objects in modules</li>
131
- </ul>
132
- <p><a name="download"></a> </p>
133
-
134
-
135
-
136
-
137
- <h2>Download</h2>
138
-
139
-
140
-
141
-
142
- <p>You can download source and library releases on the <a href="http://rubyforge.org/frs/?group_id=305">RubyForge
143
- downloads</a> page. Alternatively, you can checkout the latest
144
- source&nbsp;from <a href="http://rubyforge.org/scm/?group_id=305">CVS</a>.</p>
145
-
146
-
147
-
148
-
149
- <p> <a name="quickstart"></a> </p>
150
-
151
-
152
-
153
-
154
- <h2>Quick Start Guide</h2>
155
-
156
-
157
-
158
-
159
- <p>
160
- This is a short usage example. See <a href="../doc/classes/ROXML/ROXML_Class.html">ROXML::ROXML_Class</a> and
161
- packaged test cases for more information.</p>
162
-
163
-
164
-
165
-
166
-
167
- <p>
168
- Consider an XML document representing a Library containing a number of
169
- Books. You can map this structure to Ruby classes that provide addition
170
- useful behavior. With ROXML, you can
171
- annotate the Ruby classes as follows:</p>
172
-
173
-
174
-
175
-
176
- <pre><code><span style="font-weight: bold;">class</span> Book<br> <span style="font-weight: bold;">include</span> ROXML<br><br> xml_attribute :isbn, "ISBN"<br> xml_text :title<br> xml_text :description, <span style="font-weight: bold;">nil</span>, ROXML::TAG_CDATA<br> xml_text :author<span style="font-weight: bold;"></span><br><span style="font-weight: bold;">end</span><br><br><span style="font-weight: bold;">class</span> Library<br> <span style="font-weight: bold;">include</span> ROXML<br><br> xml_text :name, "NAME", ROXML::TAG_CDATA<br> xml_object :books, Book, ROXML::TAG_ARRAY, "books"<br><span style="font-weight: bold;">end</span><br></code><br></pre>
177
-
178
-
179
-
180
-
181
- <p>To create a library and put a number of books in it, we could
182
- run the following code:</p>
183
-
184
-
185
- <pre> book = Book.<span style="font-weight: bold;">new</span>()<br> book.isbn = "0201710897"<br> book.title = "The PickAxe"<br> book.description = "Best Ruby book out there!"<br> book.author = "David Thomas, Andrew Hunt, Dave Thomas"<br><br> lib = Library.<span style="font-weight: bold;">new</span>()<br> lib.name = "Favorite Books"<br> lib.books &lt;&lt; book</pre>
186
-
187
-
188
- <p>To save this information to an XML file:</p>
189
-
190
-
191
-
192
-
193
- <pre><code>File.open("library.xml", "w") <span style="font-weight: bold;">do</span> |f|<br> lib.to_xml.write(f, 0)<br><span style="font-weight: bold;">end</span><br></code><br></pre>
194
-
195
-
196
-
197
-
198
- <p>This would put the following XML into <em>library.xml</em>:</p>
199
-
200
-
201
-
202
-
203
- <pre><code>&lt;library&gt;<br> &lt;NAME&gt;&lt;![CDATA[Favorite Books]]&gt;&lt;/NAME&gt;<br> &lt;books&gt;<br> &lt;book ISBN='0201710897'&gt;<br> &lt;title&gt;The PickAxe&lt;/title&gt;<br> &lt;description&gt;&lt;![CDATA[Best Ruby book out there!]]&gt;&lt;/description&gt;<br> &lt;author&gt;David Thomas, Andrew Hunt, Dave Thomas&lt;/author&gt;<br> &lt;/book&gt;<br> &lt;/books&gt;<br>&lt;/library&gt;</code><br></pre>
204
-
205
-
206
-
207
-
208
- <p>To later populate the library object from the XML file:</p>
209
-
210
-
211
-
212
-
213
- <pre> <code>lib = Library.parse(File.read("library.xml"))<br></code><br></pre>
214
-
215
-
216
-
217
-
218
- <p>To do a one-to-one mapping between XML objects, such as book
219
- and publisher,
220
- you would use the <em>xml_object</em> annotation. For
221
- example:</p>
222
-
223
-
224
-
225
-
226
- <pre><code>&lt;book isbn="0974514055"&gt;<br> &lt;title&gt;Programming Ruby - 2nd Edition&lt;/title&gt;<br> &lt;description&gt;Second edition of the great book&lt;/description&gt;<br> &lt;publisher&gt;<br> &lt;name&gt;Pragmatic Bookshelf&lt;/name&gt;<br> &lt;/publisher&gt;<br>&lt;/book&gt;<br></code><br></pre>
227
-
228
-
229
-
230
-
231
- <p>Can be mapped using the following code:</p>
232
-
233
-
234
-
235
-
236
- <pre><code><span style="font-weight: bold;">class</span> BookWithPublisher<br> <span style="font-weight: bold;">include</span> ROXML<br><br> xml_name :book<br> xml_object :publisher, Publisher<br><span style="font-weight: bold;">end</span><br></code><br></pre>
237
-
238
-
239
-
240
-
241
- <p>Note: In the above example, <em>xml_name</em>
242
- annotation tells ROXML to set the element
243
- name to "book" for mapping to XML. The default is XML element name is
244
- the class name in lowercase; "bookwithpublisher"
245
- in this case.</p>
246
-
247
-
248
-
249
-
250
- </div>
251
-
252
-
253
-
254
-
255
- <div id="footer" class="contentBlock">
256
- <p>ROXML&nbsp;is licensed under the MIT License. See
257
- bundled MIT-LICENSE.txt for details.&nbsp;ROXML was created by <a href="http://rubyforge.org/users/andersengstrom">Anders
258
- Engstrom</a> and is being developed and maintained by <a href="http://rubyforge.org/users/zakmandhro">Zak Mandhro</a>.&nbsp;For
259
- project tracking, downloads, and other information, visit
260
- the <a href="http://rubyforge.org/projects/roxml">ROXML
261
- RubyForge Project</a> page.</p>
262
-
263
-
264
-
265
-
266
- </div>
267
-
268
-
269
-
270
-
271
- <div id="cvs_id">$Id: INDEX,v 1.6 2006/06/28 03:52:38
272
- zakmandhro Exp $</div>
273
-
274
-
275
-
276
-
277
- </body>
278
- </html>