xommelier 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/xommelier/schemas/atom.xsd +240 -0
- data/lib/xommelier/version.rb +1 -1
- data/lib/xommelier/xml/element/serialization.rb +15 -12
- data/lib/xommelier/xml/element/structure.rb +7 -0
- data/lib/xommelier/xml/element.rb +18 -3
- data/lib/xommelier/xml/namespace.rb +8 -0
- data/lib/xommelier/xml.rb +40 -1
- data/spec/functional/atom_feed_building_spec.rb +2 -0
- data/spec/lib/xommelier/xml_spec.rb +1 -0
- data/spec/lib/xommelier_spec.rb +1 -1
- metadata +25 -10
- data/lib/xommelier/xml/class_methods.rb +0 -21
data/README.md
CHANGED
@@ -182,7 +182,7 @@ will output
|
|
182
182
|
|
183
183
|
## TODO
|
184
184
|
|
185
|
-
* Validating built XML against RelaxNG
|
185
|
+
* Validating built XML against RelaxNG
|
186
186
|
* Converting XML Schema, RelaxNG, RelaxNG Compact and DTD into Xommelier Ruby DSL
|
187
187
|
* ActiveRecord-like automatic loading of XML Schema, RelaxNG, RelaxNG Compact and DTD without needing to write it down into ruby code
|
188
188
|
|
@@ -0,0 +1,240 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<xs:schema targetNamespace="http://www.w3.org/2005/Atom" elementFormDefault="qualified"
|
3
|
+
attributeFormDefault="unqualified"
|
4
|
+
xmlns:atom="http://www.w3.org/2005/Atom"
|
5
|
+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
6
|
+
xmlns:xml="http://www.w3.org/XML/1998/namespace">
|
7
|
+
<xs:annotation>
|
8
|
+
<xs:documentation>
|
9
|
+
This version of the Atom schema is based on version 1.0 of the format specifications,
|
10
|
+
found here http://www.atomenabled.org/developers/syndication/atom-format-spec.php.
|
11
|
+
</xs:documentation>
|
12
|
+
</xs:annotation>
|
13
|
+
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd" />
|
14
|
+
<xs:annotation>
|
15
|
+
<xs:documentation>
|
16
|
+
An Atom document may have two root elements, feed and entry, as defined in section 2.
|
17
|
+
</xs:documentation>
|
18
|
+
</xs:annotation>
|
19
|
+
<xs:element name="feed" type="atom:feedType"/>
|
20
|
+
<xs:element name="entry" type="atom:entryType"/>
|
21
|
+
<xs:complexType name="textType" mixed="true">
|
22
|
+
<xs:annotation>
|
23
|
+
<xs:documentation>
|
24
|
+
The Atom text construct is defined in section 3.1 of the format spec.
|
25
|
+
</xs:documentation>
|
26
|
+
</xs:annotation>
|
27
|
+
<xs:sequence>
|
28
|
+
<xs:any namespace="http://www.w3.org/1999/xhtml" minOccurs="0"/>
|
29
|
+
</xs:sequence>
|
30
|
+
<xs:attribute name="type" >
|
31
|
+
<xs:simpleType>
|
32
|
+
<xs:restriction base="xs:token">
|
33
|
+
<xs:enumeration value="text"/>
|
34
|
+
<xs:enumeration value="html"/>
|
35
|
+
<xs:enumeration value="xhtml"/>
|
36
|
+
</xs:restriction>
|
37
|
+
</xs:simpleType>
|
38
|
+
</xs:attribute>
|
39
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
40
|
+
</xs:complexType>
|
41
|
+
<xs:complexType name="personType">
|
42
|
+
<xs:annotation>
|
43
|
+
<xs:documentation>
|
44
|
+
The Atom person construct is defined in section 3.2 of the format spec.
|
45
|
+
</xs:documentation>
|
46
|
+
</xs:annotation>
|
47
|
+
<xs:choice minOccurs="1" maxOccurs="unbounded">
|
48
|
+
<xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1" />
|
49
|
+
<xs:element name="uri" type="atom:uriType" minOccurs="0" maxOccurs="1" />
|
50
|
+
<xs:element name="email" type="atom:emailType" minOccurs="0" maxOccurs="1" />
|
51
|
+
<xs:any namespace="##other"/>
|
52
|
+
</xs:choice>
|
53
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
54
|
+
</xs:complexType>
|
55
|
+
<xs:simpleType name="emailType">
|
56
|
+
<xs:annotation>
|
57
|
+
<xs:documentation>
|
58
|
+
Schema definition for an email address.
|
59
|
+
</xs:documentation>
|
60
|
+
</xs:annotation>
|
61
|
+
<xs:restriction base="xs:normalizedString">
|
62
|
+
<xs:pattern value="\w+@(\w+\.)+\w+" />
|
63
|
+
</xs:restriction>
|
64
|
+
</xs:simpleType>
|
65
|
+
<xs:complexType name="feedType">
|
66
|
+
<xs:annotation>
|
67
|
+
<xs:documentation>
|
68
|
+
The Atom feed construct is defined in section 4.1.1 of the format spec.
|
69
|
+
</xs:documentation>
|
70
|
+
</xs:annotation>
|
71
|
+
<xs:choice minOccurs="3" maxOccurs="unbounded">
|
72
|
+
<xs:element name="author" type="atom:personType" minOccurs="0" maxOccurs="unbounded" />
|
73
|
+
<xs:element name="category" type="atom:categoryType" minOccurs="0" maxOccurs="unbounded" />
|
74
|
+
<xs:element name="contributor" type="atom:personType" minOccurs="0" maxOccurs="unbounded" />
|
75
|
+
<xs:element name="generator" type="atom:generatorType" minOccurs="0" maxOccurs="1" />
|
76
|
+
<xs:element name="icon" type="atom:iconType" minOccurs="0" maxOccurs="1" />
|
77
|
+
<xs:element name="id" type="atom:idType" minOccurs="1" maxOccurs="1" />
|
78
|
+
<xs:element name="link" type="atom:linkType" minOccurs="0" maxOccurs="unbounded" />
|
79
|
+
<xs:element name="logo" type="atom:logoType" minOccurs="0" maxOccurs="1" />
|
80
|
+
<xs:element name="rights" type="atom:textType" minOccurs="0" maxOccurs="1" />
|
81
|
+
<xs:element name="subtitle" type="atom:textType" minOccurs="0" maxOccurs="1" />
|
82
|
+
<xs:element name="title" type="atom:textType" minOccurs="1" maxOccurs="1" />
|
83
|
+
<xs:element name="updated" type="atom:dateTimeType" minOccurs="1" maxOccurs="1" />
|
84
|
+
<xs:element name="entry" type="atom:entryType" minOccurs="0" maxOccurs="unbounded" />
|
85
|
+
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
|
86
|
+
</xs:choice>
|
87
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
88
|
+
</xs:complexType>
|
89
|
+
<xs:complexType name="entryType">
|
90
|
+
<xs:annotation>
|
91
|
+
<xs:documentation>
|
92
|
+
The Atom entry construct is defined in section 4.1.2 of the format spec.
|
93
|
+
</xs:documentation>
|
94
|
+
</xs:annotation>
|
95
|
+
<xs:choice maxOccurs="unbounded">
|
96
|
+
<xs:element name="author" type="atom:personType" minOccurs="0" maxOccurs="unbounded" />
|
97
|
+
<xs:element name="category" type="atom:categoryType" minOccurs="0" maxOccurs="unbounded" />
|
98
|
+
<xs:element name="content" type="atom:contentType" minOccurs="0" maxOccurs="1" />
|
99
|
+
<xs:element name="contributor" type="atom:personType" minOccurs="0" maxOccurs="unbounded" />
|
100
|
+
<xs:element name="id" type="atom:idType" minOccurs="1" maxOccurs="1" />
|
101
|
+
<xs:element name="link" type="atom:linkType" minOccurs="0" maxOccurs="unbounded" />
|
102
|
+
<xs:element name="published" type="atom:dateTimeType" minOccurs="0" maxOccurs="1" />
|
103
|
+
<xs:element name="rights" type="atom:textType" minOccurs="0" maxOccurs="1" />
|
104
|
+
<xs:element name="source" type="atom:textType" minOccurs="0" maxOccurs="1" />
|
105
|
+
<xs:element name="summary" type="atom:textType" minOccurs="0" maxOccurs="1" />
|
106
|
+
<xs:element name="title" type="atom:textType" minOccurs="1" maxOccurs="1" />
|
107
|
+
<xs:element name="updated" type="atom:dateTimeType" minOccurs="1" maxOccurs="1" />
|
108
|
+
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
|
109
|
+
</xs:choice>
|
110
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
111
|
+
</xs:complexType>
|
112
|
+
<xs:complexType name="contentType" mixed="true">
|
113
|
+
<xs:annotation>
|
114
|
+
<xs:documentation>
|
115
|
+
The Atom content construct is defined in section 4.1.3 of the format spec.
|
116
|
+
</xs:documentation>
|
117
|
+
</xs:annotation>
|
118
|
+
<xs:sequence>
|
119
|
+
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" />
|
120
|
+
</xs:sequence>
|
121
|
+
<xs:attribute name="type" type="xs:string"/>
|
122
|
+
<xs:attribute name="src" type="xs:anyURI"/>
|
123
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
124
|
+
</xs:complexType>
|
125
|
+
<xs:complexType name="categoryType">
|
126
|
+
<xs:annotation>
|
127
|
+
<xs:documentation>
|
128
|
+
The Atom cagegory construct is defined in section 4.2.2 of the format spec.
|
129
|
+
</xs:documentation>
|
130
|
+
</xs:annotation>
|
131
|
+
<xs:attribute name="term" type="xs:string" use="required"/>
|
132
|
+
<xs:attribute name="scheme" type="xs:anyURI" use="optional"/>
|
133
|
+
<xs:attribute name="label" type="xs:string" use="optional"/>
|
134
|
+
<xs:attributeGroup ref="atom:commonAttributes" />
|
135
|
+
</xs:complexType>
|
136
|
+
<xs:complexType name="generatorType">
|
137
|
+
<xs:annotation>
|
138
|
+
<xs:documentation>
|
139
|
+
The Atom generator element is defined in section 4.2.4 of the format spec.
|
140
|
+
</xs:documentation>
|
141
|
+
</xs:annotation>
|
142
|
+
<xs:simpleContent>
|
143
|
+
<xs:extension base="xs:string">
|
144
|
+
<xs:attribute name="uri" use="optional" type="xs:anyURI" />
|
145
|
+
<xs:attribute name="version" use="optional" type="xs:string" />
|
146
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
147
|
+
</xs:extension>
|
148
|
+
</xs:simpleContent>
|
149
|
+
</xs:complexType>
|
150
|
+
<xs:complexType name="iconType">
|
151
|
+
<xs:annotation>
|
152
|
+
<xs:documentation>
|
153
|
+
The Atom icon construct is defined in section 4.2.5 of the format spec.
|
154
|
+
</xs:documentation>
|
155
|
+
</xs:annotation>
|
156
|
+
<xs:simpleContent>
|
157
|
+
<xs:extension base="xs:anyURI">
|
158
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
159
|
+
</xs:extension>
|
160
|
+
</xs:simpleContent>
|
161
|
+
</xs:complexType>
|
162
|
+
<xs:complexType name="idType">
|
163
|
+
<xs:annotation>
|
164
|
+
<xs:documentation>
|
165
|
+
The Atom id construct is defined in section 4.2.6 of the format spec.
|
166
|
+
</xs:documentation>
|
167
|
+
</xs:annotation>
|
168
|
+
<xs:simpleContent>
|
169
|
+
<xs:extension base="xs:anyURI">
|
170
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
171
|
+
</xs:extension>
|
172
|
+
</xs:simpleContent>
|
173
|
+
</xs:complexType>
|
174
|
+
<xs:complexType name="linkType" mixed="true">
|
175
|
+
<xs:annotation>
|
176
|
+
<xs:documentation>
|
177
|
+
The Atom link construct is defined in section 3.4 of the format spec.
|
178
|
+
</xs:documentation>
|
179
|
+
</xs:annotation>
|
180
|
+
<xs:attribute name="href" use="required" type="xs:anyURI" />
|
181
|
+
<xs:attribute name="rel" type="xs:string" use="optional"/>
|
182
|
+
<xs:attribute name="type" use="optional" type="xs:string" />
|
183
|
+
<xs:attribute name="hreflang" use="optional" type="xs:NMTOKEN" />
|
184
|
+
<xs:attribute name="title" use="optional" type="xs:string" />
|
185
|
+
<xs:attribute name="length" use="optional" type="xs:positiveInteger" />
|
186
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
187
|
+
</xs:complexType>
|
188
|
+
<xs:complexType name="logoType">
|
189
|
+
<xs:annotation>
|
190
|
+
<xs:documentation>
|
191
|
+
The Atom logo construct is defined in section 4.2.8 of the format spec.
|
192
|
+
</xs:documentation>
|
193
|
+
</xs:annotation>
|
194
|
+
<xs:simpleContent>
|
195
|
+
<xs:extension base="xs:anyURI">
|
196
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
197
|
+
</xs:extension>
|
198
|
+
</xs:simpleContent>
|
199
|
+
</xs:complexType>
|
200
|
+
<xs:complexType name="sourceType">
|
201
|
+
<xs:annotation>
|
202
|
+
<xs:documentation>
|
203
|
+
The Atom source construct is defined in section 4.2.11 of the format spec.
|
204
|
+
</xs:documentation>
|
205
|
+
</xs:annotation>
|
206
|
+
<xs:choice maxOccurs="unbounded">
|
207
|
+
<xs:element name="author" type="atom:personType" minOccurs="0" maxOccurs="unbounded"/>
|
208
|
+
<xs:element name="category" type="atom:categoryType" minOccurs="0" maxOccurs="unbounded"/>
|
209
|
+
<xs:element name="contributor" type="atom:personType" minOccurs="0" maxOccurs="unbounded"/>
|
210
|
+
<xs:element name="generator" type="atom:generatorType" minOccurs="0" maxOccurs="1"/>
|
211
|
+
<xs:element name="icon" type="atom:iconType" minOccurs="0" maxOccurs="1"/>
|
212
|
+
<xs:element name="id" type="atom:idType" minOccurs="0" maxOccurs="1"/>
|
213
|
+
<xs:element name="link" type="atom:linkType" minOccurs="0" maxOccurs="unbounded"/>
|
214
|
+
<xs:element name="logo" type="atom:logoType" minOccurs="0" maxOccurs="1"/>
|
215
|
+
<xs:element name="rights" type="atom:textType" minOccurs="0" maxOccurs="1"/>
|
216
|
+
<xs:element name="subtitle" type="atom:textType" minOccurs="0" maxOccurs="1"/>
|
217
|
+
<xs:element name="title" type="atom:textType" minOccurs="0" maxOccurs="1"/>
|
218
|
+
<xs:element name="updated" type="atom:dateTimeType" minOccurs="0" maxOccurs="1"/>
|
219
|
+
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
|
220
|
+
</xs:choice>
|
221
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
222
|
+
</xs:complexType>
|
223
|
+
<xs:complexType name="uriType">
|
224
|
+
<xs:simpleContent>
|
225
|
+
<xs:extension base="xs:anyURI">
|
226
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
227
|
+
</xs:extension>
|
228
|
+
</xs:simpleContent>
|
229
|
+
</xs:complexType>
|
230
|
+
<xs:complexType name="dateTimeType">
|
231
|
+
<xs:simpleContent>
|
232
|
+
<xs:extension base="xs:dateTime">
|
233
|
+
<xs:attributeGroup ref="atom:commonAttributes"/>
|
234
|
+
</xs:extension>
|
235
|
+
</xs:simpleContent>
|
236
|
+
</xs:complexType>
|
237
|
+
<xs:attributeGroup name="commonAttributes">
|
238
|
+
<xs:anyAttribute namespace="##other"/>
|
239
|
+
</xs:attributeGroup>
|
240
|
+
</xs:schema>
|
data/lib/xommelier/version.rb
CHANGED
@@ -15,8 +15,7 @@ module Xommelier
|
|
15
15
|
|
16
16
|
module ClassMethods
|
17
17
|
def from_xml(xml, options = {})
|
18
|
-
new.tap do |doc|
|
19
|
-
doc.options = options
|
18
|
+
new({}, options).tap do |doc|
|
20
19
|
doc.from_xml(xml, options)
|
21
20
|
end
|
22
21
|
end
|
@@ -43,6 +42,7 @@ module Xommelier
|
|
43
42
|
xml = Nokogiri::XML(xml)
|
44
43
|
end
|
45
44
|
@_xml_node = options.delete(:node) { xml.at_xpath(element_xpath(xml.document, element_name)) }
|
45
|
+
validate if options[:validate]
|
46
46
|
|
47
47
|
if text? && @_xml_node.text?
|
48
48
|
self.text = @_xml_node.text
|
@@ -72,7 +72,7 @@ module Xommelier
|
|
72
72
|
hash["xmlns:#{ns.as}"] = ns.uri
|
73
73
|
hash
|
74
74
|
end
|
75
|
-
attribute_values.delete("xmlns:#{xmlns.as
|
75
|
+
attribute_values.delete("xmlns:#{xmlns.as}")
|
76
76
|
attribute_values.delete('xmlns:xml')
|
77
77
|
namespaces = attribute_values
|
78
78
|
prefix = nil
|
@@ -90,15 +90,18 @@ module Xommelier
|
|
90
90
|
end
|
91
91
|
serialize_attribute(attribute_name, value, attribute_values)
|
92
92
|
end
|
93
|
-
(prefix ? builder[prefix] : builder).
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
xml
|
100
|
-
|
93
|
+
@_xml_node = (prefix ? builder[prefix] : builder).
|
94
|
+
send(element_name, attribute_values) do |xml|
|
95
|
+
elements.each do |name, value|
|
96
|
+
serialize_element(
|
97
|
+
name,
|
98
|
+
value,
|
99
|
+
xml,
|
100
|
+
element_options(name).merge(parent_ns_prefix: prefix)
|
101
|
+
)
|
101
102
|
end
|
103
|
+
xml.text(@text) if respond_to?(:text)
|
104
|
+
end.instance_variable_get(:@node)
|
102
105
|
builder.to_xml
|
103
106
|
end
|
104
107
|
alias_method :to_xommelier, :to_xml
|
@@ -143,7 +146,7 @@ module Xommelier
|
|
143
146
|
end
|
144
147
|
|
145
148
|
def xml_document
|
146
|
-
@_xml_node.document
|
149
|
+
@_xml_node.try(:document)
|
147
150
|
end
|
148
151
|
|
149
152
|
def xmlns_xpath(xml_document = self.xml_document)
|
@@ -176,6 +176,13 @@ module Xommelier
|
|
176
176
|
|
177
177
|
protected
|
178
178
|
|
179
|
+
def options=(options = {})
|
180
|
+
if @options.key?(:element_name)
|
181
|
+
element_name(@options.delete(:element_name))
|
182
|
+
end
|
183
|
+
super(options)
|
184
|
+
end
|
185
|
+
|
179
186
|
def element_name(value = nil)
|
180
187
|
if value
|
181
188
|
@element_name = value
|
@@ -26,6 +26,7 @@ module Xommelier
|
|
26
26
|
@elements = {}
|
27
27
|
@attributes = {}
|
28
28
|
@text = nil
|
29
|
+
@errors = []
|
29
30
|
|
30
31
|
self.class.attributes.each do |name, options|
|
31
32
|
send("#{name}=", options[:default]) if options[:default]
|
@@ -47,11 +48,15 @@ module Xommelier
|
|
47
48
|
|
48
49
|
def options=(options = {})
|
49
50
|
@options = options
|
51
|
+
unless @options[:validate]
|
52
|
+
@options[:validate] = !!xmlns.schema
|
53
|
+
end
|
50
54
|
@options.delete(:type)
|
55
|
+
end
|
51
56
|
|
52
|
-
|
53
|
-
|
54
|
-
|
57
|
+
def valid?
|
58
|
+
validate
|
59
|
+
@errors.empty? || @errors
|
55
60
|
end
|
56
61
|
|
57
62
|
def inspect
|
@@ -60,6 +65,16 @@ module Xommelier
|
|
60
65
|
|
61
66
|
private
|
62
67
|
|
68
|
+
def validate
|
69
|
+
@errors = []
|
70
|
+
to_xml unless xml_document
|
71
|
+
if xmlns.schema
|
72
|
+
xmlns.schema.validate(xml_document).each do |error|
|
73
|
+
@errors << error
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
63
78
|
def inspect_contents
|
64
79
|
[inspect_attributes, inspect_elements, inspect_text].compact.join(' ')
|
65
80
|
end
|
data/lib/xommelier/xml.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'xommelier'
|
2
|
-
require '
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'xommelier/xml/namespace'
|
3
4
|
require 'active_support/concern'
|
4
5
|
|
5
6
|
module Xommelier
|
@@ -8,6 +9,44 @@ module Xommelier
|
|
8
9
|
|
9
10
|
DEFAULT_NS = 'http://www.w3.org/XML/1998/namespace'
|
10
11
|
|
12
|
+
module ClassMethods
|
13
|
+
def ns
|
14
|
+
Xommelier::Xml::Namespace.registry
|
15
|
+
end
|
16
|
+
|
17
|
+
# Defines namespace used in formats
|
18
|
+
def xmlns(uri = nil, options = {}, &block)
|
19
|
+
if uri
|
20
|
+
options[:module] ||= self
|
21
|
+
instance_variable_set(:@_xmlns, Xommelier::Xml::Namespace.new(uri, options, &block))
|
22
|
+
end
|
23
|
+
instance_variable_get(:@_xmlns)
|
24
|
+
end
|
25
|
+
|
26
|
+
def schema(schema = nil)
|
27
|
+
if schema
|
28
|
+
# If schema or schema path provided, set schema
|
29
|
+
schema = Nokogiri::XML::Schema(open(schema).read) unless schema.is_a?(Nokogiri::XML::Node)
|
30
|
+
instance_variable_set(:@_schema, schema)
|
31
|
+
elsif !instance_variable_defined?(:@_schema)
|
32
|
+
# Unless schema exists, try to autoload schema
|
33
|
+
available_schema = available_schemas.find { |path| path =~ /#{xmlns.as}\.xsd/ }
|
34
|
+
self.schema(available_schema) if available_schema
|
35
|
+
else
|
36
|
+
instance_variable_set(:@schema, nil)
|
37
|
+
end
|
38
|
+
instance_variable_get(:@_schema)
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def available_schemas
|
44
|
+
@_available_schemas ||= $:.map do |path|
|
45
|
+
Dir[File.join(path, 'xommelier/schemas', '*.xsd')]
|
46
|
+
end.flatten.uniq
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
11
50
|
included do
|
12
51
|
instance_variable_set :@_xmlns, nil
|
13
52
|
end
|
@@ -26,6 +26,8 @@ describe 'Atom feed building' do
|
|
26
26
|
|
27
27
|
subject { built_xml }
|
28
28
|
|
29
|
+
it { feed.should be_valid }
|
30
|
+
|
29
31
|
it { should == load_xml_file('simple_feed.atom').read }
|
30
32
|
it('should conform to RelaxNG schema') { rng.valid?(parsed_xml).should == true }
|
31
33
|
it('should conform to XML Schema') { xsd.valid?(parsed_xml).should == true }
|
data/spec/lib/xommelier_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xommelier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 1.5.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.5.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: activesupport
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 3.2.0
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.2.0
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: activemodel
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: 3.2.0
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.2.0
|
47
62
|
description: XML-Object Mapper with many built-in XML formats supported
|
48
63
|
email:
|
49
64
|
- al@semyonov.us
|
@@ -87,9 +102,9 @@ files:
|
|
87
102
|
- lib/xommelier/core_ext/time.rb
|
88
103
|
- lib/xommelier/core_ext/uri.rb
|
89
104
|
- lib/xommelier/open_search.rb
|
105
|
+
- lib/xommelier/schemas/atom.xsd
|
90
106
|
- lib/xommelier/version.rb
|
91
107
|
- lib/xommelier/xml.rb
|
92
|
-
- lib/xommelier/xml/class_methods.rb
|
93
108
|
- lib/xommelier/xml/element.rb
|
94
109
|
- lib/xommelier/xml/element/serialization.rb
|
95
110
|
- lib/xommelier/xml/element/structure.rb
|
@@ -134,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
149
|
version: '0'
|
135
150
|
requirements: []
|
136
151
|
rubyforge_project: xommelier
|
137
|
-
rubygems_version: 1.8.
|
152
|
+
rubygems_version: 1.8.20
|
138
153
|
signing_key:
|
139
154
|
specification_version: 3
|
140
155
|
summary: Xommelier is an XML Sommelier
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'xommelier/xml'
|
2
|
-
require 'xommelier/xml/namespace'
|
3
|
-
|
4
|
-
module Xommelier
|
5
|
-
module Xml
|
6
|
-
module ClassMethods
|
7
|
-
def ns
|
8
|
-
Xommelier::Xml::Namespace.registry
|
9
|
-
end
|
10
|
-
|
11
|
-
# Defines namespace used in formats
|
12
|
-
def xmlns(uri = nil, options = {}, &block)
|
13
|
-
if uri
|
14
|
-
options[:module] ||= self
|
15
|
-
instance_variable_set :@_xmlns, Xommelier::Xml::Namespace.new(uri, options, &block)
|
16
|
-
end
|
17
|
-
instance_variable_get :@_xmlns
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|