gyoku 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/gyoku/hash.rb +2 -2
- data/lib/gyoku/version.rb +1 -1
- data/lib/gyoku/xml_value.rb +3 -1
- data/spec/gyoku/xml_value_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87b9117b8cf5daf06ccf0a70a1fd370bf1be2654
|
4
|
+
data.tar.gz: 6c5b611b97120f5c565751e128f7e5e877254f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74086f43fb9c956f06211f13776a9c83513fde77e68338550bf1438ad302ac993ba53862fc3add153a4cbdb4733f3a877e460280be3a9c448a4baf7b79175203
|
7
|
+
data.tar.gz: bf2a96fd3716a06c4c601bb0b8e30d77425a7a62b16d1fc8c40017e435308396b17e6b50d35d286740bcf91737b5c7b7ad21abf874ba4f51c91ab1a1b4d1f528
|
data/CHANGELOG.md
CHANGED
data/lib/gyoku/hash.rb
CHANGED
@@ -15,12 +15,12 @@ module Gyoku
|
|
15
15
|
xml_key = XMLKey.create key, options
|
16
16
|
|
17
17
|
case
|
18
|
-
when :content! === key then xml << XMLValue.create(value, escape_xml)
|
18
|
+
when :content! === key then xml << XMLValue.create(value, escape_xml, options)
|
19
19
|
when ::Array === value then xml << Array.to_xml(value, xml_key, escape_xml, attributes, options.merge(:self_closing => self_closing))
|
20
20
|
when ::Hash === value then xml.tag!(xml_key, attributes) { xml << Hash.to_xml(value, options) }
|
21
21
|
when self_closing then xml.tag!(xml_key, attributes)
|
22
22
|
when NilClass === value then xml.tag!(xml_key, "xsi:nil" => "true")
|
23
|
-
else xml.tag!(xml_key, attributes) { xml << XMLValue.create(value, escape_xml) }
|
23
|
+
else xml.tag!(xml_key, attributes) { xml << XMLValue.create(value, escape_xml, options) }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/gyoku/version.rb
CHANGED
data/lib/gyoku/xml_value.rb
CHANGED
@@ -15,7 +15,7 @@ module Gyoku
|
|
15
15
|
XS_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S%Z"
|
16
16
|
|
17
17
|
# Converts a given +object+ to an XML value.
|
18
|
-
def create(object, escape_xml = true)
|
18
|
+
def create(object, escape_xml = true, options = {})
|
19
19
|
if Time === object
|
20
20
|
object.strftime XS_TIME_FORMAT
|
21
21
|
elsif DateTime === object
|
@@ -28,6 +28,8 @@ module Gyoku
|
|
28
28
|
create object.to_datetime
|
29
29
|
elsif object.respond_to?(:call)
|
30
30
|
create object.call
|
31
|
+
elsif ::Hash === object
|
32
|
+
Gyoku::Hash.to_xml(object, options)
|
31
33
|
else
|
32
34
|
object.to_s
|
33
35
|
end
|
@@ -46,6 +46,11 @@ describe Gyoku::XMLValue do
|
|
46
46
|
expect(create(object)).to eq("2012-03-22T16:22:33+00:00")
|
47
47
|
end
|
48
48
|
|
49
|
+
it "hash objects get converted to xml" do
|
50
|
+
object = { document!: { "@version" => "2.0", content!: { key!: "value", other_key: { "@attribute" => 'value', content!: { key: "value" } } } } }
|
51
|
+
expect(create(object)).to eq("<document version=\"2.0\"><key>value</key><otherKey attribute=\"value\"><key>value</key></otherKey></document>")
|
52
|
+
end
|
53
|
+
|
49
54
|
it "calls #to_s unless the Object responds to #to_datetime" do
|
50
55
|
expect(create("value")).to eq("value")
|
51
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gyoku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|