xommelier 0.1.27 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/xommelier/core_ext/string.rb +1 -0
- data/lib/xommelier/version.rb +1 -1
- data/lib/xommelier/xml/element/serialization.rb +13 -14
- data/lib/xommelier/xml/element/structure/property.rb +12 -2
- data/lib/xommelier/xml.rb +2 -2
- data/spec/support/schema_validatable.rb +1 -0
- metadata +8 -27
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4824745889fca5cb98ea64de92f0546e01de2099
|
4
|
+
data.tar.gz: 2d29e5097a62566157d9269629feae898eb27d3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4f7e582c1b8a8f5ee0741d7c6301d1b8b82ee11739c173cfd3292ee7af0f7209ffbc8908765e4309b283308a5b7b391860f0c513f3fe2af38a766ebe2be7b69
|
7
|
+
data.tar.gz: 9a450f314e50ddde5648a5d6b17638de2d1805143850f7a54de0a81dd44c10cd1d04fd40d8f5768f74e6bf95b30304204b48a258b7bf5961232d759cc956bf07
|
data/lib/xommelier/version.rb
CHANGED
@@ -22,6 +22,7 @@ module Xommelier
|
|
22
22
|
doc.from_xml(xml, options)
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
25
26
|
alias_method :parse, :from_xml
|
26
27
|
alias_method :from_xommelier, :from_xml
|
27
28
|
|
@@ -61,6 +62,7 @@ module Xommelier
|
|
61
62
|
deserialize_element(element)
|
62
63
|
end
|
63
64
|
end
|
65
|
+
|
64
66
|
alias_method :from_xommelier, :from_xml
|
65
67
|
|
66
68
|
def to_xml(options = {})
|
@@ -93,17 +95,13 @@ module Xommelier
|
|
93
95
|
attribute = attribute_options(name)
|
94
96
|
attribute_name = attribute.attribute_name
|
95
97
|
ns = attribute.ns
|
96
|
-
if ns.uri != current_xmlns
|
97
|
-
|
98
|
-
attribute_name = "xml:#{attribute_name}"
|
99
|
-
elsif (attr_prefix = namespaces.key(ns.uri).try(:[], 6..-1).presence)
|
100
|
-
attribute_name = "#{attr_prefix}:#{attribute_name}"
|
101
|
-
end
|
98
|
+
if ns.uri != current_xmlns && (attr_prefix = namespaces.key(ns.uri).try(:[], 6..-1).presence)
|
99
|
+
attribute_name = "#{attr_prefix}:#{attribute_name}"
|
102
100
|
end
|
103
|
-
serialize_attribute(attribute_name, value, attribute_values)
|
101
|
+
serialize_attribute(attribute_name, value, attribute_values) if (value != nil) || attribute.required?
|
104
102
|
end
|
105
103
|
@_xml_node = (prefix ? builder[prefix] : builder).
|
106
|
-
|
104
|
+
send(element_name, attribute_values) do |xml|
|
107
105
|
self.class.elements.each do |name, element|
|
108
106
|
value = elements.fetch(name, options[:default])
|
109
107
|
unless value == nil
|
@@ -112,10 +110,11 @@ module Xommelier
|
|
112
110
|
end
|
113
111
|
end
|
114
112
|
end
|
115
|
-
xml.text(@text) if
|
113
|
+
xml.text(@text) if text?
|
116
114
|
end.instance_variable_get(:@node)
|
117
115
|
builder.to_xml(save_options)
|
118
116
|
end
|
117
|
+
|
119
118
|
alias_method :to_xommelier, :to_xml
|
120
119
|
|
121
120
|
def to_hash
|
@@ -217,7 +216,7 @@ module Xommelier
|
|
217
216
|
# @param [Xommelier::Xml::Element::Structure::Attribute] attribute
|
218
217
|
def deserialize_attribute(attribute)
|
219
218
|
ns = attribute.ns
|
220
|
-
if ns
|
219
|
+
if ns == xmlns || attribute.xml?
|
221
220
|
send(attribute.writer, @_xml_node[attribute.attribute_name])
|
222
221
|
else
|
223
222
|
send(attribute.writer, @_xml_node.attribute_with_ns(attribute.attribute_name, ns.uri.to_s).try(:value))
|
@@ -259,17 +258,17 @@ module Xommelier
|
|
259
258
|
end
|
260
259
|
end
|
261
260
|
else
|
262
|
-
xmlns
|
261
|
+
xmlns = element.overridden_xmlns || self.xmlns
|
263
262
|
prefix = if xmlns != xml.doc.namespaces['xmlns']
|
264
263
|
xml.doc.namespaces.key(element.ns.uri).try(:[], 6..-1).presence
|
265
264
|
end
|
266
265
|
case value
|
267
266
|
when Xommelier::Xml::Element
|
268
267
|
value.to_xommelier(
|
269
|
-
builder:
|
268
|
+
builder: xml,
|
270
269
|
element_name: element.element_name,
|
271
|
-
prefix:
|
272
|
-
ns:
|
270
|
+
prefix: prefix,
|
271
|
+
ns: element.ns
|
273
272
|
)
|
274
273
|
else
|
275
274
|
(prefix ? xml[prefix] : xml).send(element.serializable_element_name) do
|
@@ -105,7 +105,9 @@ module Xommelier
|
|
105
105
|
class Attribute < Property
|
106
106
|
DEFAULTS = {
|
107
107
|
type: String,
|
108
|
-
required: false
|
108
|
+
required: false,
|
109
|
+
optional: true,
|
110
|
+
xml: false
|
109
111
|
}
|
110
112
|
|
111
113
|
def node_type
|
@@ -116,8 +118,16 @@ module Xommelier
|
|
116
118
|
options[:required]
|
117
119
|
end
|
118
120
|
|
121
|
+
def xml?
|
122
|
+
options[:xml]
|
123
|
+
end
|
124
|
+
|
119
125
|
def attribute_name
|
120
|
-
@attribute_name ||=
|
126
|
+
@attribute_name ||= if xml?
|
127
|
+
"xml:#{name}"
|
128
|
+
else
|
129
|
+
options.delete(:as) { name }.to_s
|
130
|
+
end
|
121
131
|
end
|
122
132
|
end
|
123
133
|
|
data/lib/xommelier/xml.rb
CHANGED
@@ -35,8 +35,8 @@ module Xommelier
|
|
35
35
|
# Inject common XML attributes to every XML element
|
36
36
|
require 'xommelier/xml/element'
|
37
37
|
class Element
|
38
|
-
attribute :lang,
|
39
|
-
attribute :base, type: Uri,
|
38
|
+
attribute :lang, optional: true, xml: true
|
39
|
+
attribute :base, type: Uri, optional: true, xml: true
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xommelier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.28
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Alexander Semyonov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: activesupport
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: activemodel
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bundler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rspec
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -211,33 +198,26 @@ files:
|
|
211
198
|
- xommelier.gemspec
|
212
199
|
homepage: http://github.com/alsemyonov/xommelier
|
213
200
|
licenses: []
|
201
|
+
metadata: {}
|
214
202
|
post_install_message:
|
215
203
|
rdoc_options: []
|
216
204
|
require_paths:
|
217
205
|
- lib
|
218
206
|
required_ruby_version: !ruby/object:Gem::Requirement
|
219
|
-
none: false
|
220
207
|
requirements:
|
221
|
-
- -
|
208
|
+
- - '>='
|
222
209
|
- !ruby/object:Gem::Version
|
223
210
|
version: '0'
|
224
|
-
segments:
|
225
|
-
- 0
|
226
|
-
hash: 1200176832615114872
|
227
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
-
none: false
|
229
212
|
requirements:
|
230
|
-
- -
|
213
|
+
- - '>='
|
231
214
|
- !ruby/object:Gem::Version
|
232
215
|
version: '0'
|
233
|
-
segments:
|
234
|
-
- 0
|
235
|
-
hash: 1200176832615114872
|
236
216
|
requirements: []
|
237
217
|
rubyforge_project: xommelier
|
238
|
-
rubygems_version:
|
218
|
+
rubygems_version: 2.0.3
|
239
219
|
signing_key:
|
240
|
-
specification_version:
|
220
|
+
specification_version: 4
|
241
221
|
summary: Xommelier is an XML Sommelier
|
242
222
|
test_files:
|
243
223
|
- spec/fixtures/atom.rng.xml
|
@@ -268,3 +248,4 @@ test_files:
|
|
268
248
|
- spec/spec_helper.rb
|
269
249
|
- spec/support/fixtures.rb
|
270
250
|
- spec/support/schema_validatable.rb
|
251
|
+
has_rdoc:
|