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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 706fc3792c5b710724e7b4d0346cb281a734aade
4
- data.tar.gz: a2945a1e368642e9c7435865cc21ac8471f8597d
3
+ metadata.gz: 87b9117b8cf5daf06ccf0a70a1fd370bf1be2654
4
+ data.tar.gz: 6c5b611b97120f5c565751e128f7e5e877254f8c
5
5
  SHA512:
6
- metadata.gz: 41bfd990f33d899bae5191363138bfc11fdb6e986ef5ae3b490d9192d8d5c24de9ffe6f582171f065e40b494bf35e09a4c60261f763f45c8b7f193cd157ff940
7
- data.tar.gz: 66a9c732125e941ed0213706599d720e324ea5a54ab7d7d110a5d98566ae883bd1d33af3e9b9c27aa8081bb5ae23d53b13f46a300233431866c5c68ef58d90b4
6
+ metadata.gz: 74086f43fb9c956f06211f13776a9c83513fde77e68338550bf1438ad302ac993ba53862fc3add153a4cbdb4733f3a877e460280be3a9c448a4baf7b79175203
7
+ data.tar.gz: bf2a96fd3716a06c4c601bb0b8e30d77425a7a62b16d1fc8c40017e435308396b17e6b50d35d286740bcf91737b5c7b7ad21abf874ba4f51c91ab1a1b4d1f528
@@ -1,3 +1,7 @@
1
+ ## 1.3.1 (2015-04-05)
2
+
3
+ * Feature: [#53](https://github.com/savonrb/gyoku/pull/53) Improved serialization of hashes nested in arrays. Thanks to @riburkes for this!
4
+
1
5
  ## 1.3.0 (2015-03-30)
2
6
 
3
7
  * Formally drop support for ruby 1.8.7
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Gyoku
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -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.0
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-01 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder