roxml 1.2 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +18 -0
- data/README.rdoc +126 -0
- data/Rakefile +100 -0
- data/lib/roxml.rb +479 -485
- data/lib/roxml/extensions/active_support.rb +32 -0
- data/lib/roxml/extensions/array.rb +5 -0
- data/lib/roxml/extensions/array/conversions.rb +25 -0
- data/lib/roxml/extensions/deprecation.rb +28 -0
- data/lib/roxml/extensions/string.rb +21 -0
- data/lib/roxml/extensions/string/conversions.rb +44 -0
- data/lib/roxml/extensions/string/iterators.rb +12 -0
- data/lib/roxml/options.rb +266 -0
- data/lib/roxml/xml.rb +223 -0
- data/lib/roxml/xml/libxml.rb +63 -0
- data/lib/roxml/xml/rexml.rb +64 -0
- data/roxml.gemspec +105 -0
- data/test/fixtures/book_text_with_attribute.xml +1 -1
- data/test/fixtures/book_valid.xml +2 -2
- data/test/fixtures/book_with_authors.xml +7 -0
- data/test/fixtures/book_with_contributors_attrs.xml +7 -0
- data/test/fixtures/book_with_default_namespace.xml +9 -0
- data/test/fixtures/book_with_depth.xml +6 -0
- data/test/fixtures/book_with_wrapped_attr.xml +3 -0
- data/test/fixtures/dictionary_of_attr_name_clashes.xml +8 -0
- data/test/fixtures/dictionary_of_attrs.xml +6 -0
- data/test/fixtures/dictionary_of_guarded_names.xml +6 -0
- data/test/fixtures/dictionary_of_mixeds.xml +4 -0
- data/test/fixtures/dictionary_of_name_clashes.xml +10 -0
- data/test/fixtures/dictionary_of_names.xml +4 -0
- data/test/fixtures/dictionary_of_texts.xml +10 -0
- data/test/fixtures/library.xml +1 -1
- data/test/fixtures/library_uppercase.xml +30 -0
- data/test/fixtures/muffins.xml +3 -0
- data/test/fixtures/nameless_ageless_youth.xml +2 -0
- data/test/fixtures/node_with_attr_name_conflicts.xml +1 -0
- data/test/fixtures/node_with_name_conflicts.xml +4 -0
- data/test/fixtures/numerology.xml +4 -0
- data/test/fixtures/person_with_guarded_mothers.xml +13 -0
- data/test/fixtures/person_with_mothers.xml +10 -0
- data/test/mocks/dictionaries.rb +56 -0
- data/test/mocks/mocks.rb +244 -48
- data/test/release/dependencies_test.rb +32 -0
- data/test/test_helper.rb +44 -0
- data/test/unit/inheritance_test.rb +19 -0
- data/test/unit/options_test.rb +102 -0
- data/test/unit/roxml_test.rb +24 -0
- data/test/unit/string_test.rb +11 -0
- data/test/unit/to_xml_test.rb +52 -0
- data/test/unit/xml_attribute_test.rb +39 -0
- data/test/unit/xml_block_test.rb +81 -0
- data/test/unit/xml_bool_test.rb +105 -0
- data/test/unit/xml_construct_test.rb +77 -0
- data/test/unit/xml_hash_test.rb +65 -0
- data/test/unit/xml_initialize_test.rb +50 -0
- data/test/unit/xml_name_test.rb +108 -0
- data/test/unit/xml_namespace_test.rb +38 -0
- data/test/unit/xml_object_test.rb +116 -0
- data/test/unit/xml_required_test.rb +93 -0
- data/test/unit/xml_text_test.rb +68 -0
- metadata +138 -87
- data/MIT-LICENSE.txt +0 -9
- data/README +0 -2
- data/doc/classes/ROXML.html +0 -374
- data/doc/classes/ROXML.src/M000003.html +0 -19
- data/doc/classes/ROXML.src/M000004.html +0 -25
- data/doc/classes/ROXML.src/M000005.html +0 -22
- data/doc/classes/ROXML/ROXML_Class.html +0 -429
- data/doc/classes/ROXML/ROXML_Class.src/M000006.html +0 -27
- data/doc/classes/ROXML/ROXML_Class.src/M000007.html +0 -18
- data/doc/classes/ROXML/ROXML_Class.src/M000008.html +0 -19
- data/doc/classes/ROXML/ROXML_Class.src/M000009.html +0 -25
- data/doc/classes/ROXML/ROXML_Class.src/M000010.html +0 -24
- data/doc/classes/ROXML/ROXML_Class.src/M000011.html +0 -18
- data/doc/classes/ROXML/ROXML_Class.src/M000012.html +0 -18
- data/doc/classes/ROXML/XMLAttributeRef.html +0 -175
- data/doc/classes/ROXML/XMLAttributeRef.src/M000015.html +0 -19
- data/doc/classes/ROXML/XMLAttributeRef.src/M000016.html +0 -19
- data/doc/classes/ROXML/XMLObjectRef.html +0 -175
- data/doc/classes/ROXML/XMLObjectRef.src/M000013.html +0 -26
- data/doc/classes/ROXML/XMLObjectRef.src/M000014.html +0 -32
- data/doc/classes/ROXML/XMLRef.html +0 -166
- data/doc/classes/ROXML/XMLRef.src/M000017.html +0 -21
- data/doc/classes/ROXML/XMLTextRef.html +0 -198
- data/doc/classes/ROXML/XMLTextRef.src/M000018.html +0 -28
- data/doc/classes/ROXML/XMLTextRef.src/M000019.html +0 -34
- data/doc/classes/String.html +0 -165
- data/doc/classes/String.src/M000001.html +0 -23
- data/doc/classes/String.src/M000002.html +0 -23
- data/doc/created.rid +0 -1
- data/doc/files/lib/roxml_rb.html +0 -234
- data/doc/fr_class_index.html +0 -33
- data/doc/fr_file_index.html +0 -27
- data/doc/fr_method_index.html +0 -45
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
- data/test/fixture_helper.rb +0 -5
- data/test/test_roxml.rb +0 -105
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
|
2
|
+
|
|
3
|
+
class TestXMLText < Test::Unit::TestCase
|
|
4
|
+
# Test a simple mapping with no composition
|
|
5
|
+
def test_valid_simple
|
|
6
|
+
book = Book.from_xml(fixture(:book_valid))
|
|
7
|
+
assert_equal("The PickAxe", book.title)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_without_needed_from
|
|
11
|
+
assert !Library.from_xml(fixture(:library_uppercase)).name
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_with_needed_from
|
|
15
|
+
assert_equal "Ruby library", Library.from_xml(fixture(:library)).name
|
|
16
|
+
assert_equal "Ruby library", UppercaseLibrary.from_xml(fixture(:library_uppercase)).name
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_as_array
|
|
20
|
+
assert_equal ["David Thomas","Andrew Hunt","Dave Thomas"].sort,
|
|
21
|
+
BookWithAuthors.from_xml(fixture(:book_with_authors)).authors.sort
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_empty_array_result_returned_properly
|
|
25
|
+
empty_array = Class.new do
|
|
26
|
+
include ROXML
|
|
27
|
+
|
|
28
|
+
xml_reader :missing_array, [:text], :from => 'missing'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
obj = empty_array.from_xml('<empty_array></empty_array>')
|
|
32
|
+
assert_equal [], obj.missing_array
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_text_modification
|
|
36
|
+
person = Person.from_xml(fixture(:person))
|
|
37
|
+
assert_equal("Ben Franklin", person.name)
|
|
38
|
+
person.name = "Fred"
|
|
39
|
+
xml=person.to_xml.to_s
|
|
40
|
+
assert(/Fred/=~xml)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_default_initialization
|
|
44
|
+
person = PersonWithMotherOrMissing.from_xml(fixture(:nameless_ageless_youth))
|
|
45
|
+
assert_equal "Anonymous", person.name
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_default_initialization_of_content
|
|
49
|
+
person = Person.from_xml(fixture(:nameless_ageless_youth))
|
|
50
|
+
assert_equal "Unknown", person.name
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_recursive_with_default_initialization
|
|
54
|
+
p = PersonWithMotherOrMissing.from_xml(fixture(:person_with_mothers))
|
|
55
|
+
assert_equal 'Unknown', p.mother.mother.mother.name
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_get_with_block
|
|
59
|
+
p = Book.from_xml(fixture(:book_valid))
|
|
60
|
+
assert_equal 357, p.pages
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_no_name_clashes
|
|
64
|
+
n = NodeWithNameConflicts.from_xml(fixture(:node_with_name_conflicts))
|
|
65
|
+
assert_equal "Just junk... really", n.content
|
|
66
|
+
assert_equal "Cartwheel", n.name
|
|
67
|
+
end
|
|
68
|
+
end
|
metadata
CHANGED
|
@@ -1,103 +1,154 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
rubygems_version: 0.8.10
|
|
3
|
-
specification_version: 1
|
|
4
2
|
name: roxml
|
|
5
3
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version:
|
|
7
|
-
date: 2007-11-10
|
|
8
|
-
summary: Ruby Object to XML mapping library
|
|
9
|
-
require_paths:
|
|
10
|
-
- lib
|
|
11
|
-
email:
|
|
12
|
-
homepage: http://roxml.rubyforge.org
|
|
13
|
-
rubyforge_project:
|
|
14
|
-
description: ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML. Using simple annotations, it enables Ruby classes to be mapped to XML. ROXML takes care of the marshalling and unmarshalling of mapped attributes so that developers can focus on building first-class Ruby classes. As a result, ROXML simplifies the development of RESTful applications, Web Services, and XML-RPC.
|
|
15
|
-
autorequire: roxml
|
|
16
|
-
default_executable:
|
|
17
|
-
bindir: bin
|
|
18
|
-
has_rdoc: true
|
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
20
|
-
requirements:
|
|
21
|
-
- - ">"
|
|
22
|
-
- !ruby/object:Gem::Version
|
|
23
|
-
version: 0.0.0
|
|
24
|
-
version:
|
|
4
|
+
version: 2.3.2
|
|
25
5
|
platform: ruby
|
|
26
6
|
authors:
|
|
7
|
+
- Ben Woosley
|
|
27
8
|
- Zak Mandhro
|
|
9
|
+
- Anders Engstrom
|
|
10
|
+
- Russ Olsen
|
|
11
|
+
autorequire:
|
|
12
|
+
bindir: bin
|
|
13
|
+
cert_chain: []
|
|
14
|
+
|
|
15
|
+
date: 2008-12-27 00:00:00 -08:00
|
|
16
|
+
default_executable:
|
|
17
|
+
dependencies:
|
|
18
|
+
- !ruby/object:Gem::Dependency
|
|
19
|
+
name: extensions
|
|
20
|
+
type: :runtime
|
|
21
|
+
version_requirement:
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.6.0
|
|
27
|
+
version:
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: activesupport
|
|
30
|
+
type: :runtime
|
|
31
|
+
version_requirement:
|
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: 2.0.0
|
|
37
|
+
version:
|
|
38
|
+
description: ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML. Using simple annotations, it enables Ruby classes to be mapped to XML. ROXML takes care of the marshalling and unmarshalling of mapped attributes so that developers can focus on building first-class Ruby classes. As a result, ROXML simplifies the development of RESTful applications, Web Services, and XML-RPC.
|
|
39
|
+
email: ben.woosley@gmail.com
|
|
40
|
+
executables: []
|
|
41
|
+
|
|
42
|
+
extensions: []
|
|
43
|
+
|
|
44
|
+
extra_rdoc_files: []
|
|
45
|
+
|
|
28
46
|
files:
|
|
47
|
+
- README.rdoc
|
|
48
|
+
- MIT-LICENSE
|
|
49
|
+
- Rakefile
|
|
50
|
+
- roxml.gemspec
|
|
29
51
|
- lib/roxml.rb
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
52
|
+
- lib/roxml/extensions/active_support.rb
|
|
53
|
+
- lib/roxml/extensions/array.rb
|
|
54
|
+
- lib/roxml/extensions/array/conversions.rb
|
|
55
|
+
- lib/roxml/extensions/string.rb
|
|
56
|
+
- lib/roxml/extensions/string/conversions.rb
|
|
57
|
+
- lib/roxml/extensions/string/iterators.rb
|
|
58
|
+
- lib/roxml/extensions/deprecation.rb
|
|
59
|
+
- lib/roxml/options.rb
|
|
60
|
+
- lib/roxml/xml.rb
|
|
61
|
+
- lib/roxml/xml/libxml.rb
|
|
62
|
+
- lib/roxml/xml/rexml.rb
|
|
63
|
+
- test/fixtures/book_malformed.xml
|
|
64
|
+
- test/fixtures/book_pair.xml
|
|
65
|
+
- test/fixtures/book_text_with_attribute.xml
|
|
66
|
+
- test/fixtures/book_valid.xml
|
|
67
|
+
- test/fixtures/book_with_authors.xml
|
|
37
68
|
- test/fixtures/book_with_contributions.xml
|
|
69
|
+
- test/fixtures/book_with_contributors_attrs.xml
|
|
70
|
+
- test/fixtures/book_with_contributors.xml
|
|
71
|
+
- test/fixtures/book_with_default_namespace.xml
|
|
72
|
+
- test/fixtures/book_with_depth.xml
|
|
38
73
|
- test/fixtures/book_with_publisher.xml
|
|
74
|
+
- test/fixtures/book_with_wrapped_attr.xml
|
|
75
|
+
- test/fixtures/dictionary_of_attrs.xml
|
|
76
|
+
- test/fixtures/dictionary_of_attr_name_clashes.xml
|
|
77
|
+
- test/fixtures/dictionary_of_guarded_names.xml
|
|
78
|
+
- test/fixtures/dictionary_of_mixeds.xml
|
|
79
|
+
- test/fixtures/dictionary_of_names.xml
|
|
80
|
+
- test/fixtures/dictionary_of_name_clashes.xml
|
|
81
|
+
- test/fixtures/dictionary_of_texts.xml
|
|
82
|
+
- test/fixtures/library_uppercase.xml
|
|
39
83
|
- test/fixtures/library.xml
|
|
40
|
-
- test/fixtures/
|
|
41
|
-
- test/fixtures/
|
|
84
|
+
- test/fixtures/muffins.xml
|
|
85
|
+
- test/fixtures/node_with_attr_name_conflicts.xml
|
|
86
|
+
- test/fixtures/node_with_name_conflicts.xml
|
|
87
|
+
- test/fixtures/nameless_ageless_youth.xml
|
|
88
|
+
- test/fixtures/numerology.xml
|
|
89
|
+
- test/fixtures/person_with_guarded_mothers.xml
|
|
90
|
+
- test/fixtures/person_with_mothers.xml
|
|
42
91
|
- test/fixtures/person.xml
|
|
43
|
-
- test/
|
|
44
|
-
- test/
|
|
45
|
-
- test/
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- doc/classes/ROXML/XMLRef.src
|
|
67
|
-
- doc/classes/ROXML/XMLTextRef.html
|
|
68
|
-
- doc/classes/ROXML/XMLRef.html
|
|
69
|
-
- doc/classes/ROXML/XMLAttributeRef.src
|
|
70
|
-
- doc/classes/ROXML/ROXML_Class.html
|
|
71
|
-
- doc/classes/ROXML/XMLObjectRef.src/M000013.html
|
|
72
|
-
- doc/classes/ROXML/XMLObjectRef.src/M000014.html
|
|
73
|
-
- doc/classes/ROXML/ROXML_Class.src/M000008.html
|
|
74
|
-
- doc/classes/ROXML/ROXML_Class.src/M000009.html
|
|
75
|
-
- doc/classes/ROXML/ROXML_Class.src/M000010.html
|
|
76
|
-
- doc/classes/ROXML/ROXML_Class.src/M000011.html
|
|
77
|
-
- doc/classes/ROXML/ROXML_Class.src/M000012.html
|
|
78
|
-
- doc/classes/ROXML/ROXML_Class.src/M000006.html
|
|
79
|
-
- doc/classes/ROXML/ROXML_Class.src/M000007.html
|
|
80
|
-
- doc/classes/ROXML/XMLTextRef.src/M000018.html
|
|
81
|
-
- doc/classes/ROXML/XMLTextRef.src/M000019.html
|
|
82
|
-
- doc/classes/ROXML/XMLRef.src/M000017.html
|
|
83
|
-
- doc/classes/ROXML/XMLAttributeRef.src/M000015.html
|
|
84
|
-
- doc/classes/ROXML/XMLAttributeRef.src/M000016.html
|
|
85
|
-
- doc/classes/String.src/M000001.html
|
|
86
|
-
- doc/classes/String.src/M000002.html
|
|
87
|
-
- doc/classes/ROXML.src/M000003.html
|
|
88
|
-
- doc/classes/ROXML.src/M000004.html
|
|
89
|
-
- doc/classes/ROXML.src/M000005.html
|
|
90
|
-
test_files:
|
|
91
|
-
- test/test_roxml.rb
|
|
92
|
+
- test/mocks/mocks.rb
|
|
93
|
+
- test/mocks/dictionaries.rb
|
|
94
|
+
- test/release/dependencies_test.rb
|
|
95
|
+
- test/test_helper.rb
|
|
96
|
+
- test/unit/inheritance_test.rb
|
|
97
|
+
- test/unit/options_test.rb
|
|
98
|
+
- test/unit/roxml_test.rb
|
|
99
|
+
- test/unit/string_test.rb
|
|
100
|
+
- test/unit/to_xml_test.rb
|
|
101
|
+
- test/unit/xml_attribute_test.rb
|
|
102
|
+
- test/unit/xml_block_test.rb
|
|
103
|
+
- test/unit/xml_bool_test.rb
|
|
104
|
+
- test/unit/xml_construct_test.rb
|
|
105
|
+
- test/unit/xml_hash_test.rb
|
|
106
|
+
- test/unit/xml_initialize_test.rb
|
|
107
|
+
- test/unit/xml_name_test.rb
|
|
108
|
+
- test/unit/xml_namespace_test.rb
|
|
109
|
+
- test/unit/xml_object_test.rb
|
|
110
|
+
- test/unit/xml_required_test.rb
|
|
111
|
+
- test/unit/xml_text_test.rb
|
|
112
|
+
has_rdoc: true
|
|
113
|
+
homepage: http://roxml.rubyforge.org
|
|
114
|
+
post_install_message:
|
|
92
115
|
rdoc_options: []
|
|
93
116
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
117
|
+
require_paths:
|
|
118
|
+
- lib
|
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: "0"
|
|
124
|
+
version:
|
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: "0"
|
|
130
|
+
version:
|
|
100
131
|
requirements:
|
|
101
132
|
- none
|
|
102
|
-
|
|
103
|
-
|
|
133
|
+
rubyforge_project: roxml
|
|
134
|
+
rubygems_version: 1.3.1.xported
|
|
135
|
+
signing_key:
|
|
136
|
+
specification_version: 2
|
|
137
|
+
summary: Ruby Object to XML mapping library
|
|
138
|
+
test_files:
|
|
139
|
+
- test/unit/inheritance_test.rb
|
|
140
|
+
- test/unit/options_test.rb
|
|
141
|
+
- test/unit/roxml_test.rb
|
|
142
|
+
- test/unit/string_test.rb
|
|
143
|
+
- test/unit/to_xml_test.rb
|
|
144
|
+
- test/unit/xml_attribute_test.rb
|
|
145
|
+
- test/unit/xml_block_test.rb
|
|
146
|
+
- test/unit/xml_bool_test.rb
|
|
147
|
+
- test/unit/xml_construct_test.rb
|
|
148
|
+
- test/unit/xml_hash_test.rb
|
|
149
|
+
- test/unit/xml_initialize_test.rb
|
|
150
|
+
- test/unit/xml_name_test.rb
|
|
151
|
+
- test/unit/xml_namespace_test.rb
|
|
152
|
+
- test/unit/xml_object_test.rb
|
|
153
|
+
- test/unit/xml_required_test.rb
|
|
154
|
+
- test/unit/xml_text_test.rb
|
data/MIT-LICENSE.txt
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2006 by Zak Mandhro and Anders Engstrom
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
DELETED
data/doc/classes/ROXML.html
DELETED
|
@@ -1,374 +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</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</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
|
-
<a href="ROXML.html">ROXML</a> Ruby Object to XML mapping library. For more
|
|
78
|
-
information visit <a
|
|
79
|
-
href="http://roxml.rubyforge.org">roxml.rubyforge.org</a>
|
|
80
|
-
</p>
|
|
81
|
-
<p>
|
|
82
|
-
Copyright (c) 2004-2006 Zak Mandhro and Anders Engstrom
|
|
83
|
-
</p>
|
|
84
|
-
<p>
|
|
85
|
-
Permission is hereby granted, free of charge, to any person obtaining a
|
|
86
|
-
copy of this software and associated documentation files (the
|
|
87
|
-
"Software"), to deal in the Software without restriction,
|
|
88
|
-
including without limitation the rights to use, copy, modify, merge,
|
|
89
|
-
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
90
|
-
permit persons to whom the Software is furnished to do so, subject to the
|
|
91
|
-
following conditions:
|
|
92
|
-
</p>
|
|
93
|
-
<p>
|
|
94
|
-
The above copyright notice and this permission notice shall be <a
|
|
95
|
-
href="ROXML.html#M000003">included</a> in all copies or substantial
|
|
96
|
-
portions of the Software.
|
|
97
|
-
</p>
|
|
98
|
-
<p>
|
|
99
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
100
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
101
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
102
|
-
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
103
|
-
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
104
|
-
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
105
|
-
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
106
|
-
</p>
|
|
107
|
-
<h1>Quick Start Guide</h1>
|
|
108
|
-
<p>
|
|
109
|
-
This is a short usage example. See <a
|
|
110
|
-
href="ROXML/ROXML_Class.html">ROXML::ROXML_Class</a> and packaged test
|
|
111
|
-
cases for more information.
|
|
112
|
-
</p>
|
|
113
|
-
<p>
|
|
114
|
-
Consider an XML document representing a Library containing a number of
|
|
115
|
-
Books. You can map this structure to Ruby classes that provide addition
|
|
116
|
-
useful behavior. With <a href="ROXML.html">ROXML</a>, you can annotate the
|
|
117
|
-
Ruby classes as follows:
|
|
118
|
-
</p>
|
|
119
|
-
<pre>
|
|
120
|
-
class Book
|
|
121
|
-
include ROXML
|
|
122
|
-
|
|
123
|
-
xml_attribute :isbn, "ISBN"
|
|
124
|
-
xml_text :title
|
|
125
|
-
xml_text :description, nil, ROXML::TAG_CDATA
|
|
126
|
-
xml_text :author
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
class Library
|
|
130
|
-
include ROXML
|
|
131
|
-
|
|
132
|
-
xml_text :name, "NAME", ROXML::TAG_CDATA
|
|
133
|
-
xml_object :books, Book, ROXML::TAG_ARRAY, "books"
|
|
134
|
-
end
|
|
135
|
-
</pre>
|
|
136
|
-
<p>
|
|
137
|
-
To create a library and put a number of books in it we could run the
|
|
138
|
-
following code:
|
|
139
|
-
</p>
|
|
140
|
-
<pre>
|
|
141
|
-
book = Book.new()
|
|
142
|
-
book.isbn = "0201710897"
|
|
143
|
-
book.title = "The PickAxe"
|
|
144
|
-
book.description = "Best Ruby book out there!"
|
|
145
|
-
book.author = "David Thomas, Andrew Hunt, Dave Thomas"
|
|
146
|
-
|
|
147
|
-
lib = Library.new()
|
|
148
|
-
lib.name = "Favorite Books"
|
|
149
|
-
lib << book
|
|
150
|
-
</pre>
|
|
151
|
-
<p>
|
|
152
|
-
To save this information to an XML file:
|
|
153
|
-
</p>
|
|
154
|
-
<pre>
|
|
155
|
-
File.open("library.xml", "w") do |f|
|
|
156
|
-
lib.to_xml.write(f, 0)
|
|
157
|
-
end
|
|
158
|
-
</pre>
|
|
159
|
-
<p>
|
|
160
|
-
To later populate the library object from the XML file:
|
|
161
|
-
</p>
|
|
162
|
-
<pre>
|
|
163
|
-
lib = Library.parse(File.read("library.xml"))
|
|
164
|
-
</pre>
|
|
165
|
-
<p>
|
|
166
|
-
Similarly, to do a one-to-one mapping between XML objects, such as book and
|
|
167
|
-
publisher, you would use the <b>xml_object</b> annotation. For example:
|
|
168
|
-
</p>
|
|
169
|
-
<pre>
|
|
170
|
-
<book isbn="0974514055">
|
|
171
|
-
<title>Programming Ruby - 2nd Edition</title>
|
|
172
|
-
<description>Second edition of the great book.</description>
|
|
173
|
-
<publisher>
|
|
174
|
-
<name>Pragmatic Bookshelf</name>
|
|
175
|
-
</publisher>
|
|
176
|
-
</book>
|
|
177
|
-
</pre>
|
|
178
|
-
<p>
|
|
179
|
-
can be mapped using the following code:
|
|
180
|
-
</p>
|
|
181
|
-
<pre>
|
|
182
|
-
class BookWithPublisher
|
|
183
|
-
include ROXML
|
|
184
|
-
|
|
185
|
-
xml_name :book
|
|
186
|
-
xml_object :publisher, Publisher
|
|
187
|
-
end
|
|
188
|
-
</pre>
|
|
189
|
-
<p>
|
|
190
|
-
Note: In the above example, <em>xml_name</em> annotation tells <a
|
|
191
|
-
href="ROXML.html">ROXML</a> to set the element name to "book" for
|
|
192
|
-
mapping to XML. The default is XML element name is the class name in
|
|
193
|
-
lowercase; "bookwithpublisher" in this case.
|
|
194
|
-
</p>
|
|
195
|
-
<p>
|
|
196
|
-
For more information on available annotations, see <a
|
|
197
|
-
href="ROXML/ROXML_Class.html">ROXML::ROXML_Class</a>
|
|
198
|
-
</p>
|
|
199
|
-
|
|
200
|
-
</div>
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
</div>
|
|
204
|
-
|
|
205
|
-
<div id="method-list">
|
|
206
|
-
<h3 class="section-bar">Methods</h3>
|
|
207
|
-
|
|
208
|
-
<div class="name-list">
|
|
209
|
-
<a href="#M000003">included</a>
|
|
210
|
-
<a href="#M000005">method_missing</a>
|
|
211
|
-
<a href="#M000004">to_xml</a>
|
|
212
|
-
</div>
|
|
213
|
-
</div>
|
|
214
|
-
|
|
215
|
-
</div>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
<!-- if includes -->
|
|
219
|
-
|
|
220
|
-
<div id="section">
|
|
221
|
-
|
|
222
|
-
<div id="class-list">
|
|
223
|
-
<h3 class="section-bar">Classes and Modules</h3>
|
|
224
|
-
|
|
225
|
-
Module <a href="ROXML/ROXML_Class.html" class="link">ROXML::ROXML_Class</a><br />
|
|
226
|
-
Class <a href="ROXML/XMLAttributeRef.html" class="link">ROXML::XMLAttributeRef</a><br />
|
|
227
|
-
Class <a href="ROXML/XMLObjectRef.html" class="link">ROXML::XMLObjectRef</a><br />
|
|
228
|
-
Class <a href="ROXML/XMLRef.html" class="link">ROXML::XMLRef</a><br />
|
|
229
|
-
Class <a href="ROXML/XMLTextRef.html" class="link">ROXML::XMLTextRef</a><br />
|
|
230
|
-
|
|
231
|
-
</div>
|
|
232
|
-
|
|
233
|
-
<div id="constants-list">
|
|
234
|
-
<h3 class="section-bar">Constants</h3>
|
|
235
|
-
|
|
236
|
-
<div class="name-list">
|
|
237
|
-
<table summary="Constants">
|
|
238
|
-
<tr class="top-aligned-row context-row">
|
|
239
|
-
<td class="context-item-name">TAG_DEFAULT</td>
|
|
240
|
-
<td>=</td>
|
|
241
|
-
<td class="context-item-value">0</td>
|
|
242
|
-
<td width="3em"> </td>
|
|
243
|
-
<td class="context-item-desc">
|
|
244
|
-
Default tag behavior declaration with single read and write.
|
|
245
|
-
|
|
246
|
-
</td>
|
|
247
|
-
</tr>
|
|
248
|
-
<tr class="top-aligned-row context-row">
|
|
249
|
-
<td class="context-item-name">TAG_READONLY</td>
|
|
250
|
-
<td>=</td>
|
|
251
|
-
<td class="context-item-value">1</td>
|
|
252
|
-
<td width="3em"> </td>
|
|
253
|
-
<td class="context-item-desc">
|
|
254
|
-
Option that may be used to declare that a variable accessor should be
|
|
255
|
-
read-only (no "accessor=(val)" is generated).
|
|
256
|
-
|
|
257
|
-
</td>
|
|
258
|
-
</tr>
|
|
259
|
-
<tr class="top-aligned-row context-row">
|
|
260
|
-
<td class="context-item-name">TAG_CDATA</td>
|
|
261
|
-
<td>=</td>
|
|
262
|
-
<td class="context-item-value">2</td>
|
|
263
|
-
<td width="3em"> </td>
|
|
264
|
-
<td class="context-item-desc">
|
|
265
|
-
Option that declares that an XML text element‘s value should be
|
|
266
|
-
wrapped in a CDATA section.
|
|
267
|
-
|
|
268
|
-
</td>
|
|
269
|
-
</tr>
|
|
270
|
-
<tr class="top-aligned-row context-row">
|
|
271
|
-
<td class="context-item-name">TAG_ARRAY</td>
|
|
272
|
-
<td>=</td>
|
|
273
|
-
<td class="context-item-value">4</td>
|
|
274
|
-
<td width="3em"> </td>
|
|
275
|
-
<td class="context-item-desc">
|
|
276
|
-
Option that declares an accessor as an array (referencing "many"
|
|
277
|
-
items).
|
|
278
|
-
|
|
279
|
-
</td>
|
|
280
|
-
</tr>
|
|
281
|
-
<tr class="top-aligned-row context-row">
|
|
282
|
-
<td class="context-item-name">TEXT_CONTENT</td>
|
|
283
|
-
<td>=</td>
|
|
284
|
-
<td class="context-item-value">8</td>
|
|
285
|
-
<td width="3em"> </td>
|
|
286
|
-
<td class="context-item-desc">
|
|
287
|
-
Option that declares an xml_text annotation to define the text content of
|
|
288
|
-
the container tag
|
|
289
|
-
|
|
290
|
-
</td>
|
|
291
|
-
</tr>
|
|
292
|
-
</table>
|
|
293
|
-
</div>
|
|
294
|
-
</div>
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
<!-- if method_list -->
|
|
302
|
-
<div id="methods">
|
|
303
|
-
<h3 class="section-bar">Public Class methods</h3>
|
|
304
|
-
|
|
305
|
-
<div id="method-M000003" class="method-detail">
|
|
306
|
-
<a name="M000003"></a>
|
|
307
|
-
|
|
308
|
-
<div class="method-heading">
|
|
309
|
-
<a href="ROXML.src/M000003.html" target="Code" class="method-signature"
|
|
310
|
-
onclick="popupCode('ROXML.src/M000003.html');return false;">
|
|
311
|
-
<span class="method-name">included</span><span class="method-args">(klass)</span>
|
|
312
|
-
</a>
|
|
313
|
-
</div>
|
|
314
|
-
|
|
315
|
-
<div class="method-description">
|
|
316
|
-
<p>
|
|
317
|
-
Extends the klass with the <a href="ROXML/ROXML_Class.html">ROXML_Class</a>
|
|
318
|
-
module methods.
|
|
319
|
-
</p>
|
|
320
|
-
</div>
|
|
321
|
-
</div>
|
|
322
|
-
|
|
323
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
|
324
|
-
|
|
325
|
-
<div id="method-M000005" class="method-detail">
|
|
326
|
-
<a name="M000005"></a>
|
|
327
|
-
|
|
328
|
-
<div class="method-heading">
|
|
329
|
-
<a href="ROXML.src/M000005.html" target="Code" class="method-signature"
|
|
330
|
-
onclick="popupCode('ROXML.src/M000005.html');return false;">
|
|
331
|
-
<span class="method-name">method_missing</span><span class="method-args">(name, *args)</span>
|
|
332
|
-
</a>
|
|
333
|
-
</div>
|
|
334
|
-
|
|
335
|
-
<div class="method-description">
|
|
336
|
-
<p>
|
|
337
|
-
To make it easier to reference the class‘s attributes all method
|
|
338
|
-
calls to the instance that doesn‘t match an instance method are
|
|
339
|
-
forwarded to the class‘s singleton instance. Only methods starting
|
|
340
|
-
with ‘tag_’ are delegated.
|
|
341
|
-
</p>
|
|
342
|
-
</div>
|
|
343
|
-
</div>
|
|
344
|
-
|
|
345
|
-
<div id="method-M000004" class="method-detail">
|
|
346
|
-
<a name="M000004"></a>
|
|
347
|
-
|
|
348
|
-
<div class="method-heading">
|
|
349
|
-
<a href="ROXML.src/M000004.html" target="Code" class="method-signature"
|
|
350
|
-
onclick="popupCode('ROXML.src/M000004.html');return false;">
|
|
351
|
-
<span class="method-name">to_xml</span><span class="method-args">()</span>
|
|
352
|
-
</a>
|
|
353
|
-
</div>
|
|
354
|
-
|
|
355
|
-
<div class="method-description">
|
|
356
|
-
<p>
|
|
357
|
-
Returns an REXML::Element representing this object.
|
|
358
|
-
</p>
|
|
359
|
-
</div>
|
|
360
|
-
</div>
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
</div>
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
</div>
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
<div id="validator-badges">
|
|
370
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
371
|
-
</div>
|
|
372
|
-
|
|
373
|
-
</body>
|
|
374
|
-
</html>
|