representable 0.0.1.alpha1 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +58 -153
- data/lib/representable.rb +18 -42
- data/lib/representable/bindings/json_bindings.rb +69 -0
- data/lib/representable/bindings/xml_bindings.rb +152 -0
- data/lib/representable/definition.rb +1 -12
- data/lib/representable/json.rb +66 -0
- data/lib/representable/version.rb +1 -1
- data/lib/representable/xml.rb +32 -38
- data/representable.gemspec +3 -2
- data/test/bindings_test.rb +110 -0
- data/test/json_test.rb +130 -0
- data/test/{roxml_test.rb → representable_test.rb} +28 -9
- data/test/test_helper.rb +2 -0
- data/test/xml_test.rb +192 -0
- metadata +32 -105
- data/History.txt +0 -354
- data/TODO +0 -37
- data/VERSION +0 -1
- data/examples/amazon.rb +0 -35
- data/examples/current_weather.rb +0 -27
- data/examples/dashed_elements.rb +0 -20
- data/examples/library.rb +0 -40
- data/examples/posts.rb +0 -27
- data/examples/rails.rb +0 -70
- data/examples/twitter.rb +0 -37
- data/examples/xml/active_record.xml +0 -70
- data/examples/xml/amazon.xml +0 -133
- data/examples/xml/current_weather.xml +0 -89
- data/examples/xml/dashed_elements.xml +0 -52
- data/examples/xml/posts.xml +0 -23
- data/examples/xml/twitter.xml +0 -422
- data/lib/representable/references.rb +0 -153
- data/spec/definition_spec.rb +0 -495
- data/spec/examples/active_record_spec.rb +0 -41
- data/spec/examples/amazon_spec.rb +0 -54
- data/spec/examples/current_weather_spec.rb +0 -37
- data/spec/examples/dashed_elements_spec.rb +0 -20
- data/spec/examples/library_spec.rb +0 -46
- data/spec/examples/post_spec.rb +0 -24
- data/spec/examples/twitter_spec.rb +0 -32
- data/spec/roxml_integration_test.rb +0 -289
- data/spec/roxml_spec.rb +0 -372
- data/spec/shared_specs.rb +0 -15
- data/spec/spec_helper.rb +0 -5
- data/spec/support/libxml.rb +0 -3
- data/spec/support/nokogiri.rb +0 -3
- data/spec/xml/array_spec.rb +0 -36
- data/spec/xml/attributes_spec.rb +0 -71
- data/spec/xml/encoding_spec.rb +0 -53
- data/spec/xml/namespace_spec.rb +0 -270
- data/spec/xml/namespaces_spec.rb +0 -67
- data/spec/xml/object_spec.rb +0 -82
- data/spec/xml/parser_spec.rb +0 -21
- data/spec/xml/text_spec.rb +0 -71
- data/test/fixtures/book_malformed.xml +0 -5
- data/test/fixtures/book_pair.xml +0 -8
- data/test/fixtures/book_text_with_attribute.xml +0 -5
- data/test/fixtures/book_valid.xml +0 -5
- data/test/fixtures/book_with_authors.xml +0 -7
- data/test/fixtures/book_with_contributions.xml +0 -9
- data/test/fixtures/book_with_contributors.xml +0 -7
- data/test/fixtures/book_with_contributors_attrs.xml +0 -7
- data/test/fixtures/book_with_default_namespace.xml +0 -9
- data/test/fixtures/book_with_depth.xml +0 -6
- data/test/fixtures/book_with_octal_pages.xml +0 -4
- data/test/fixtures/book_with_publisher.xml +0 -7
- data/test/fixtures/book_with_wrapped_attr.xml +0 -3
- data/test/fixtures/dictionary_of_attr_name_clashes.xml +0 -8
- data/test/fixtures/dictionary_of_attrs.xml +0 -6
- data/test/fixtures/dictionary_of_guarded_names.xml +0 -6
- data/test/fixtures/dictionary_of_mixeds.xml +0 -4
- data/test/fixtures/dictionary_of_name_clashes.xml +0 -10
- data/test/fixtures/dictionary_of_names.xml +0 -4
- data/test/fixtures/dictionary_of_texts.xml +0 -10
- data/test/fixtures/library.xml +0 -30
- data/test/fixtures/library_uppercase.xml +0 -30
- data/test/fixtures/muffins.xml +0 -3
- data/test/fixtures/nameless_ageless_youth.xml +0 -2
- data/test/fixtures/node_with_attr_name_conflicts.xml +0 -1
- data/test/fixtures/node_with_name_conflicts.xml +0 -4
- data/test/fixtures/numerology.xml +0 -4
- data/test/fixtures/person.xml +0 -1
- data/test/fixtures/person_with_guarded_mothers.xml +0 -13
- data/test/fixtures/person_with_mothers.xml +0 -10
- data/test/mocks/dictionaries.rb +0 -57
- data/test/mocks/mocks.rb +0 -279
- data/test/support/fixtures.rb +0 -11
- data/test/unit/definition_test.rb +0 -235
- data/test/unit/deprecations_test.rb +0 -24
- data/test/unit/to_xml_test.rb +0 -81
- data/test/unit/xml_attribute_test.rb +0 -39
- data/test/unit/xml_block_test.rb +0 -81
- data/test/unit/xml_bool_test.rb +0 -122
- data/test/unit/xml_convention_test.rb +0 -150
- data/test/unit/xml_hash_test.rb +0 -115
- data/test/unit/xml_initialize_test.rb +0 -49
- data/test/unit/xml_name_test.rb +0 -141
- data/test/unit/xml_namespace_test.rb +0 -31
- data/test/unit/xml_object_test.rb +0 -206
- data/test/unit/xml_required_test.rb +0 -94
- data/test/unit/xml_text_test.rb +0 -71
- data/website/index.html +0 -98
@@ -1,31 +0,0 @@
|
|
1
|
-
require_relative './../test_helper'
|
2
|
-
|
3
|
-
class TestDefaultXMLNamespaces < ActiveSupport::TestCase
|
4
|
-
def setup
|
5
|
-
@book = BookWithContributions.from_xml(fixture(:book_with_default_namespace))
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_default_namespace_doesnt_interfere_with_normal_operation
|
9
|
-
assert_equal("Programming Ruby - 2nd Edition", @book.title)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_default_namespace_is_applied_to_in_element
|
13
|
-
expected_authors = ["David Thomas","Andrew Hunt","Chad Fowler"]
|
14
|
-
assert !@book.contributions.empty?
|
15
|
-
@book.contributions.each do |contributor|
|
16
|
-
assert expected_authors.include?(contributor.name)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_default_namespace_on_root_node_should_be_found
|
21
|
-
require 'libxml'
|
22
|
-
xml = LibXML::XML::Parser.string(
|
23
|
-
'<container xmlns="http://defaultnamespace.org"><node>Yeah, content</node><node><subnode>Another</subnode></node></container>').parse
|
24
|
-
|
25
|
-
assert_equal nil, xml.find_first('node')
|
26
|
-
assert_equal "Yeah, content", xml.find_first('ns:node', 'ns:http://defaultnamespace.org').content
|
27
|
-
assert_equal nil, xml.find_first('ns:node/subnode', 'ns:http://defaultnamespace.org')
|
28
|
-
assert_equal "Another", xml.find_first('ns:node/ns:subnode', 'ns:http://defaultnamespace.org').content
|
29
|
-
rescue LoadError
|
30
|
-
end
|
31
|
-
end
|
@@ -1,206 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require_relative './../test_helper'
|
3
|
-
|
4
|
-
class EmptyCart
|
5
|
-
include ROXML
|
6
|
-
|
7
|
-
xml_reader :id
|
8
|
-
|
9
|
-
def empty?
|
10
|
-
true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class CartHolder
|
15
|
-
include ROXML
|
16
|
-
|
17
|
-
xml_reader :cart, :as => EmptyCart, :required => true
|
18
|
-
end
|
19
|
-
|
20
|
-
class TestXMLObject < ActiveSupport::TestCase
|
21
|
-
# Test book with text and attribute
|
22
|
-
def test_book_author_text_attribute
|
23
|
-
book = BookWithAuthorTextAttribute.from_xml(fixture(:book_text_with_attribute))
|
24
|
-
assert_equal("primary",book.author.role)
|
25
|
-
assert_equal("David Thomas",book.author.text)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Test XML object containing list of other XML objects (one-to-many)
|
29
|
-
# In this case, book with contibutions
|
30
|
-
def test_one_to_many_with_container
|
31
|
-
expected_authors = ["David Thomas","Andrew Hunt","Chad Fowler"]
|
32
|
-
book = BookWithContributions.from_xml(fixture(:book_with_contributions))
|
33
|
-
assert_equal("Programming Ruby - 2nd Edition", book.title)
|
34
|
-
book.contributions.each do |contributor|
|
35
|
-
assert expected_authors.include?(contributor.name)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Test XML object containing 1-n other XML objects without container (one-to-many)
|
40
|
-
# In this case, book with contibutions
|
41
|
-
def test_one_to_many_without_container
|
42
|
-
expected_contributors = ["David Thomas","Andrew Hunt","Chad Fowler"]
|
43
|
-
book = BookWithContributors.from_xml(fixture(:book_with_contributors))
|
44
|
-
assert_equal("Programming Ruby - 2nd Edition", book.title)
|
45
|
-
book.contributors.each do |contributor|
|
46
|
-
assert(expected_contributors.include?(contributor.name))
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# when building objects that contain arrays, the second object seems to
|
51
|
-
# inherit data from the first
|
52
|
-
#
|
53
|
-
def test_one_to_many_without_container_sequence
|
54
|
-
contrib = WriteableContributor.new
|
55
|
-
contrib.name = "David Thomas"
|
56
|
-
|
57
|
-
book_one = WriteableBookWithContributors.new
|
58
|
-
book_one.isbn = "9781843549161"
|
59
|
-
book_one.title = "Anathem"
|
60
|
-
book_one.description = "A new title from Neal Stephenson"
|
61
|
-
book_one.contributors = [contrib]
|
62
|
-
|
63
|
-
# this book should be completely empty
|
64
|
-
book_two = WriteableBookWithContributors.new
|
65
|
-
|
66
|
-
assert_equal(nil, book_two.isbn)
|
67
|
-
assert_equal(nil, book_two.title)
|
68
|
-
assert_equal(nil, book_two.description)
|
69
|
-
assert_equal(nil, book_two.contributors)
|
70
|
-
end
|
71
|
-
|
72
|
-
# Test XML object containing one other XML object (one-to-one)
|
73
|
-
# In this case, book with publisher
|
74
|
-
def test_one_to_one
|
75
|
-
book = BookWithPublisher.from_xml(fixture(:book_with_publisher))
|
76
|
-
assert_equal("Programming Ruby - 2nd Edition", book.title)
|
77
|
-
assert_equal("Pragmatic Bookshelf", book.publisher.name)
|
78
|
-
end
|
79
|
-
|
80
|
-
# Test XML object containing type of self (self-reference)
|
81
|
-
def test_self_reference
|
82
|
-
book = BookPair.from_xml(fixture(:book_pair))
|
83
|
-
assert_equal("Programming Ruby - 2nd Edition", book.title)
|
84
|
-
assert_equal("Agile Web Development with Rails", book.book.title)
|
85
|
-
end
|
86
|
-
|
87
|
-
# Test three-level composition (one-to-many-to-many)
|
88
|
-
def test_one_to_many_to_many
|
89
|
-
expected_contributors = ["David Thomas","Andrew Hunt","Chad Fowler", "David Heinemeier Hansson"]
|
90
|
-
expected_books = ["Programming Ruby - 2nd Edition", "Agile Web Development with Rails"]
|
91
|
-
library = Library.from_xml(fixture(:library))
|
92
|
-
assert_equal("Ruby library", library.name)
|
93
|
-
assert !library.books.empty?
|
94
|
-
library.books.each do |book|
|
95
|
-
assert expected_books.include?(book.title)
|
96
|
-
book.contributions.each do |contributor|
|
97
|
-
assert(expected_contributors.include?(contributor.name))
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_without_needed_from
|
103
|
-
assert_equal [], UppercaseLibrary.from_xml(fixture(:library)).books
|
104
|
-
assert_equal [], Library.from_xml(fixture(:library_uppercase)).books
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_with_needed_from
|
108
|
-
assert Library.from_xml(fixture(:library)).books
|
109
|
-
assert UppercaseLibrary.from_xml(fixture(:library_uppercase)).books
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_with_recursion
|
113
|
-
p = PersonWithMother.from_xml(fixture(:person_with_mothers))
|
114
|
-
assert_equal 'Ben Franklin', p.name
|
115
|
-
assert_equal 'Abiah Folger', p.mother.name
|
116
|
-
assert_equal 'Madeup Mother', p.mother.mother.name
|
117
|
-
assert_equal nil, p.mother.mother.mother
|
118
|
-
end
|
119
|
-
|
120
|
-
class Node
|
121
|
-
include ROXML
|
122
|
-
|
123
|
-
xml_reader :name, :from => 'node_name'
|
124
|
-
xml_reader :nodes, :as => [Node]
|
125
|
-
end
|
126
|
-
|
127
|
-
class Taxonomy
|
128
|
-
include ROXML
|
129
|
-
|
130
|
-
xml_reader :name, :from => 'taxonomy_name'
|
131
|
-
xml_reader :nodes, :as => [Node]
|
132
|
-
end
|
133
|
-
|
134
|
-
class Taxonomies
|
135
|
-
include ROXML
|
136
|
-
xml_reader :taxonomies, :as => [Taxonomy]
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_more_recursion
|
140
|
-
taxonomies = Taxonomies.from_xml(<<HERE)
|
141
|
-
<?xml version="1.0" encoding="UTF-8" ?>
|
142
|
-
<!DOCTYPE taxonomies SYSTEM "taxonomy.dtd">
|
143
|
-
<taxonomies>
|
144
|
-
<taxonomy>
|
145
|
-
<taxonomy_name>World</taxonomy_name>
|
146
|
-
<node node_id="2" content_object_id="82534" object_type_id="2">
|
147
|
-
<node_name lang_iso="eng">Africa</node_name>
|
148
|
-
<node node_id="331" content_object_id="11" object_type_id="4">
|
149
|
-
<node_name lang_iso="eng">Algeria</node_name>
|
150
|
-
<node node_id="7271" content_object_id="117629" object_type_id="8">
|
151
|
-
<node_name lang_iso="eng">Algiers</node_name>
|
152
|
-
</node>
|
153
|
-
<node node_id="7272" content_object_id="117630" object_type_id="8">
|
154
|
-
<node_name lang_iso="eng">Ghardaïa</node_name>
|
155
|
-
</node>
|
156
|
-
<node node_id="7871" content_object_id="1000713999" object_type_id="8">
|
157
|
-
<node_name lang_iso="eng">El Oued</node_name>
|
158
|
-
</node>
|
159
|
-
<node node_id="7872" content_object_id="1000714008" object_type_id="8">
|
160
|
-
<node_name lang_iso="eng">Timimoun</node_name>
|
161
|
-
</node>
|
162
|
-
<node node_id="8903" content_object_id="1000565565" object_type_id="8">
|
163
|
-
<node_name lang_iso="eng">Annaba</node_name>
|
164
|
-
</node>
|
165
|
-
</node>
|
166
|
-
</node>
|
167
|
-
</taxonomy>
|
168
|
-
</taxonomies>
|
169
|
-
HERE
|
170
|
-
assert_equal 1, taxonomies.taxonomies.size
|
171
|
-
assert_equal 'World', taxonomies.taxonomies.first.name
|
172
|
-
node = taxonomies.taxonomies.first.nodes.first
|
173
|
-
assert_equal 'Africa', node.name
|
174
|
-
assert_equal 'Algeria', node.nodes.first.name
|
175
|
-
assert_equal ['Algiers', "Ghardaïa", 'El Oued', 'Timimoun', 'Annaba'],
|
176
|
-
node.nodes.first.nodes.map(&:name)
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_with_guarded_recursion
|
180
|
-
p = PersonWithGuardedMother.from_xml(fixture(:person_with_guarded_mothers))
|
181
|
-
assert_equal 'Ben "Benji" Franklin', p.name
|
182
|
-
assert_equal 'Abiah \'Abby\' Folger', p.mother.name
|
183
|
-
assert_equal 'Madeup Mother < the third >', p.mother.mother.name
|
184
|
-
assert_equal nil, p.mother.mother.mother
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_recursive_with_default_initialization
|
188
|
-
p = PersonWithMotherOrMissing.from_xml(fixture(:person_with_mothers))
|
189
|
-
assert_equal 'Unknown', p.mother.mother.mother.name
|
190
|
-
assert_equal Person, p.mother.mother.mother.class
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_defining_empty_on_object_doesnt_cause_it_to_be_seen_as_absent
|
194
|
-
# absent means defaulting, failing required
|
195
|
-
|
196
|
-
holder = CartHolder.from_xml(%{
|
197
|
-
<cartholder>
|
198
|
-
<cart>
|
199
|
-
<id>111111</id>
|
200
|
-
</cart>
|
201
|
-
</cartholder>
|
202
|
-
})
|
203
|
-
|
204
|
-
assert_equal "111111", holder.cart.id
|
205
|
-
end
|
206
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require_relative './../test_helper'
|
2
|
-
|
3
|
-
class TestXMLRequired < ActiveSupport::TestCase
|
4
|
-
def setup
|
5
|
-
@full_book = <<BOOK
|
6
|
-
<book ISBN="1234">
|
7
|
-
<title>This & that</title>
|
8
|
-
<contributor_array>
|
9
|
-
<contributor role="Author">
|
10
|
-
<name>Johnny</name>
|
11
|
-
</contributor>
|
12
|
-
</contributor_array>
|
13
|
-
<contributor_hash>
|
14
|
-
<contributor role="Author" name="Johnny" />
|
15
|
-
</contributor_hash>
|
16
|
-
</book>
|
17
|
-
BOOK
|
18
|
-
|
19
|
-
@book_missing_attr = <<BOOK
|
20
|
-
<book>
|
21
|
-
<title>This & that</title>
|
22
|
-
<contributor_array>
|
23
|
-
<contributor role="Author">
|
24
|
-
<name>Johnny</name>
|
25
|
-
</contributor>
|
26
|
-
</contributor_array>
|
27
|
-
<contributor_hash>
|
28
|
-
<contributor role="Author" name="Johnny" />
|
29
|
-
</contributor_hash>
|
30
|
-
</book>
|
31
|
-
BOOK
|
32
|
-
|
33
|
-
@book_missing_text = <<BOOK
|
34
|
-
<book ISBN="1234">
|
35
|
-
<contributor_array>
|
36
|
-
<contributor role="Author">
|
37
|
-
<name>Johnny</name>
|
38
|
-
</contributor>
|
39
|
-
</contributor_array>
|
40
|
-
<contributor_hash>
|
41
|
-
<contributor role="Author" name="Johnny" />
|
42
|
-
</contributor_hash>
|
43
|
-
</book>
|
44
|
-
BOOK
|
45
|
-
|
46
|
-
@book_missing_array = <<BOOK
|
47
|
-
<book ISBN="1234">
|
48
|
-
<title>This & that</title>
|
49
|
-
<contributor_hash>
|
50
|
-
<contributor role="Author" name="Johnny" />
|
51
|
-
</contributor_hash>
|
52
|
-
</book>
|
53
|
-
BOOK
|
54
|
-
|
55
|
-
@book_missing_hash = <<BOOK
|
56
|
-
<book ISBN="1234">
|
57
|
-
<title>This & that</title>
|
58
|
-
<contributor_array>
|
59
|
-
<contributor role="Author">
|
60
|
-
<name>Johnny</name>
|
61
|
-
</contributor>
|
62
|
-
</contributor_array>
|
63
|
-
</book>
|
64
|
-
BOOK
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_required_passes_on_prescence
|
68
|
-
BookWithRequired.from_xml(@full_book)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_required_throws_on_attr_absence
|
72
|
-
assert_raise ROXML::RequiredElementMissing do
|
73
|
-
BookWithRequired.from_xml(@book_missing_attr)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_required_throws_on_text_absence
|
78
|
-
assert_raise ROXML::RequiredElementMissing do
|
79
|
-
BookWithRequired.from_xml(@book_missing_text)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_required_throws_on_array_absence
|
84
|
-
assert_raise ROXML::RequiredElementMissing do
|
85
|
-
BookWithRequired.from_xml(@book_missing_array)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_required_throws_on_hash_absence
|
90
|
-
assert_raise ROXML::RequiredElementMissing do
|
91
|
-
BookWithRequired.from_xml(@book_missing_hash)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
data/test/unit/xml_text_test.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require_relative './../test_helper'
|
2
|
-
|
3
|
-
class TestXMLText < ActiveSupport::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
|
-
assert_equal("David Thomas, Andrew Hunt & Dave Thomas", book.author)
|
9
|
-
|
10
|
-
assert_equal xml_fixture(:book_valid).to_s.gsub("\n", ''), book.to_xml.to_s.gsub("\n", '')
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_without_needed_from
|
14
|
-
assert !Library.from_xml(fixture(:library_uppercase)).name
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_with_needed_from
|
18
|
-
assert_equal "Ruby library", Library.from_xml(fixture(:library)).name
|
19
|
-
assert_equal "Ruby library", UppercaseLibrary.from_xml(fixture(:library_uppercase)).name
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_as_array
|
23
|
-
assert_equal ["David Thomas","Andrew Hunt","Dave Thomas"].sort,
|
24
|
-
BookWithAuthors.from_xml(fixture(:book_with_authors)).authors.sort
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_empty_array_result_returned_properly
|
28
|
-
empty_array = Class.new do
|
29
|
-
include ROXML
|
30
|
-
|
31
|
-
xml_reader :missing_array, :as => [], :from => 'missing'
|
32
|
-
end
|
33
|
-
|
34
|
-
obj = empty_array.from_xml('<empty_array></empty_array>')
|
35
|
-
assert_equal [], obj.missing_array
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_text_modification
|
39
|
-
person = Person.from_xml(fixture(:person))
|
40
|
-
assert_equal("Ben Franklin", person.name)
|
41
|
-
person.name = "Fred"
|
42
|
-
xml=person.to_xml.to_s
|
43
|
-
assert(/Fred/=~xml)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_default_initialization
|
47
|
-
person = PersonWithMotherOrMissing.from_xml(fixture(:nameless_ageless_youth))
|
48
|
-
assert_equal "Anonymous", person.name
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_default_initialization_of_content
|
52
|
-
person = Person.from_xml(fixture(:nameless_ageless_youth))
|
53
|
-
assert_equal "Unknown", person.name
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_recursive_with_default_initialization
|
57
|
-
p = PersonWithMotherOrMissing.from_xml(fixture(:person_with_mothers))
|
58
|
-
assert_equal 'Unknown', p.mother.mother.mother.name
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_get_with_block
|
62
|
-
p = Book.from_xml(fixture(:book_valid))
|
63
|
-
assert_equal 357, p.pages
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_no_name_clashes
|
67
|
-
n = NodeWithNameConflicts.from_xml(fixture(:node_with_name_conflicts))
|
68
|
-
assert_equal "Just junk... really", n.content
|
69
|
-
assert_equal "Cartwheel", n.name
|
70
|
-
end
|
71
|
-
end
|
data/website/index.html
DELETED
@@ -1,98 +0,0 @@
|
|
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 Nokogiri and LibXML 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>
|