gyoku 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -5
- data/CHANGELOG.md +6 -0
- data/Gemfile +7 -0
- data/gyoku.gemspec +2 -2
- data/lib/gyoku/array.rb +3 -0
- data/lib/gyoku/hash.rb +3 -2
- data/lib/gyoku/version.rb +1 -1
- data/spec/gyoku/array_spec.rb +7 -0
- data/spec/gyoku/hash_spec.rb +36 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdaf80a00de09a2fcb18c9dd5ef5b0bcd1491437
|
4
|
+
data.tar.gz: 8ef2ffc7a90fac372189b3968aed3003bde0f7c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26ed05f6ae3fde1a51daf47727454a8b279d5041846662608229a1ea2e82c7a0952101fb0a7828e1878df0df23e675001928d0fbdb702d657d242cb4f1369603
|
7
|
+
data.tar.gz: ccf273c1e402883e71570be64ad57ab7ea0a46e0c8abf7b22d952785a35baa49b0c6fbd6c0db1e6d8d701e711fcec5a0f206c5530d7eb157a3aa40bca5324280
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 1.1.1 (2014-01-02)
|
2
|
+
|
3
|
+
* Feature: [#38](https://github.com/savonrb/gyoku/pull/38) support for building nested Arrays
|
4
|
+
* Feature: [#36](https://github.com/savonrb/gyoku/pull/36) allow setting any objects content with :content!
|
5
|
+
* Deprecation: Support for ree and ruby 1.8.7 will be going away soon.
|
6
|
+
|
1
7
|
## 1.1.0 (2013-07-26)
|
2
8
|
|
3
9
|
* Feature: [#30](https://github.com/savonrb/gyoku/pull/30) support for building Arrays
|
data/Gemfile
CHANGED
data/gyoku.gemspec
CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_dependency "builder", ">= 2.1.2"
|
18
18
|
|
19
|
-
s.add_development_dependency "rake"
|
20
|
-
s.add_development_dependency "rspec"
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
s.add_development_dependency "rspec"
|
21
21
|
|
22
22
|
s.files = `git ls-files`.split("\n")
|
23
23
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/gyoku/array.rb
CHANGED
@@ -6,6 +6,8 @@ require "gyoku/xml_value"
|
|
6
6
|
module Gyoku
|
7
7
|
class Array
|
8
8
|
|
9
|
+
NESTED_ELEMENT_NAME = "element"
|
10
|
+
|
9
11
|
# Translates a given +array+ to XML. Accepts the XML +key+ to add the elements to,
|
10
12
|
# whether to +escape_xml+ and an optional Hash of +attributes+.
|
11
13
|
def self.to_xml(array, key, escape_xml = true, attributes = {}, options = {})
|
@@ -17,6 +19,7 @@ module Gyoku
|
|
17
19
|
else
|
18
20
|
case item
|
19
21
|
when ::Hash then xml.tag!(key, attrs) { xml << Hash.to_xml(item, options) }
|
22
|
+
when ::Array then xml.tag!(key, attrs) { xml << Array.to_xml(item, NESTED_ELEMENT_NAME) }
|
20
23
|
when NilClass then xml.tag!(key, "xsi:nil" => "true")
|
21
24
|
else xml.tag!(key, attrs) { xml << XMLValue.create(item, escape_xml) }
|
22
25
|
end
|
data/lib/gyoku/hash.rb
CHANGED
@@ -51,8 +51,9 @@ module Gyoku
|
|
51
51
|
node_attr.merge!(explicit_attr)
|
52
52
|
explicit_keys.each{|k| node_value.delete(k) }
|
53
53
|
|
54
|
-
|
55
|
-
node_value =
|
54
|
+
tmp_node_value = node_value.delete(:content!)
|
55
|
+
node_value = tmp_node_value unless tmp_node_value.nil?
|
56
|
+
node_value = "" if node_value.respond_to?(:empty?) && node_value.empty?
|
56
57
|
end
|
57
58
|
|
58
59
|
yield xml, key, node_value, node_attr
|
data/lib/gyoku/version.rb
CHANGED
data/spec/gyoku/array_spec.rb
CHANGED
@@ -51,6 +51,13 @@ describe Gyoku::Array do
|
|
51
51
|
|
52
52
|
to_xml(array, "value", :escape_xml, :id => [1, 2]).should == result
|
53
53
|
end
|
54
|
+
|
55
|
+
it "handles nested Arrays" do
|
56
|
+
array = [["one", "two"]]
|
57
|
+
result = "<value><element>one</element><element>two</element></value>"
|
58
|
+
|
59
|
+
to_xml(array, "value").should == result
|
60
|
+
end
|
54
61
|
end
|
55
62
|
|
56
63
|
def to_xml(*args)
|
data/spec/gyoku/hash_spec.rb
CHANGED
@@ -198,6 +198,42 @@ describe Gyoku::Hash do
|
|
198
198
|
to_xml(hash).should == "<category>users</category>"
|
199
199
|
end
|
200
200
|
|
201
|
+
it "recognizes :content! => value as tag content with value Fixnum" do
|
202
|
+
hash = {
|
203
|
+
"category" => {
|
204
|
+
:content! => 666
|
205
|
+
}
|
206
|
+
}
|
207
|
+
to_xml(hash).should == "<category>666</category>"
|
208
|
+
end
|
209
|
+
|
210
|
+
it "recognizes :content! => value as tag content with value true" do
|
211
|
+
hash = {
|
212
|
+
"category" => {
|
213
|
+
:content! => true
|
214
|
+
}
|
215
|
+
}
|
216
|
+
to_xml(hash).should == "<category>true</category>"
|
217
|
+
end
|
218
|
+
|
219
|
+
it "recognizes :content! => value as tag content with value false" do
|
220
|
+
hash = {
|
221
|
+
"category" => {
|
222
|
+
:content! => false
|
223
|
+
}
|
224
|
+
}
|
225
|
+
to_xml(hash).should == "<category>false</category>"
|
226
|
+
end
|
227
|
+
|
228
|
+
it "recognizes :content! => value as tag content with value DateTime" do
|
229
|
+
hash = {
|
230
|
+
"before" => {
|
231
|
+
:content! => DateTime.new(2012, 03, 22, 16, 22, 33)
|
232
|
+
}
|
233
|
+
}
|
234
|
+
to_xml(hash).should == "<before>2012-03-22T16:22:33+00:00</before>"
|
235
|
+
end
|
236
|
+
|
201
237
|
it "ignores :content! if self-closing mark present" do
|
202
238
|
hash = {
|
203
239
|
"category/" => {
|
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.1.
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2014-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
description: Gyoku translates Ruby Hashes to XML
|
56
56
|
email: me@rubiii.com
|
57
57
|
executables: []
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project: gyoku
|
102
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.1.11
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: Translates Ruby Hashes to XML
|