gyoku 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,10 +8,10 @@ module Gyoku
8
8
 
9
9
  # Translates a given +array+ to XML. Accepts the XML +key+ to add the elements to,
10
10
  # whether to +escape_xml+ and an optional Hash of +attributes+.
11
- def self.to_xml(array, key, escape_xml = true, attributes = {})
11
+ def self.to_xml(array, key, escape_xml = true, attributes = {}, options = {})
12
12
  iterate_with_xml array, attributes do |xml, item, attrs, index|
13
13
  case item
14
- when ::Hash then xml.tag!(key, attrs) { xml << Hash.to_xml(item) }
14
+ when ::Hash then xml.tag!(key, attrs) { xml << Hash.to_xml(item, options) }
15
15
  when NilClass then xml.tag!(key, "xsi:nil" => "true")
16
16
  else xml.tag!(key, attrs) { xml << XMLValue.create(item, escape_xml) }
17
17
  end
@@ -15,7 +15,7 @@ module Gyoku
15
15
  xml_key = XMLKey.create key, options
16
16
 
17
17
  case
18
- when ::Array === value then xml << Array.to_xml(value, xml_key, escape_xml, attributes)
18
+ when ::Array === value then xml << Array.to_xml(value, xml_key, escape_xml, attributes, options)
19
19
  when ::Hash === value then xml.tag!(xml_key, attributes) { xml << Hash.to_xml(value, options) }
20
20
  when self_closing then xml.tag!(xml_key, attributes)
21
21
  when NilClass === value then xml.tag!(xml_key, "xsi:nil" => "true")
@@ -1,5 +1,5 @@
1
1
  module Gyoku
2
2
 
3
- VERSION = "0.4.1"
3
+ VERSION = "0.4.2"
4
4
 
5
5
  end
@@ -132,6 +132,16 @@ describe Gyoku::Hash do
132
132
  "<v2:third><v2:firstName>Danie</v2:firstName></v2:third>"
133
133
  )
134
134
  end
135
+
136
+ it "should add given :namespace to every element in an array" do
137
+ hash = { :array => [ :first => "Luvy", :second => "Anna" ]}
138
+ result = to_xml hash, :element_form_default => :qualified, :namespace => :v1
139
+
140
+ result.should include(
141
+ "<v1:array><v1:first>Luvy</v1:first><v1:second>Anna</v1:second></v1:array>"
142
+ )
143
+ end
144
+
135
145
  end
136
146
  end
137
147
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gyoku
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Harrington
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-05 00:00:00 +02:00
18
+ date: 2011-04-07 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency