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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86c09dfdeb5eacb718d25f139c3adfd7ac6689b2
4
- data.tar.gz: 1e319e7f75f041a0b4896b2d16985c49a4aa408c
3
+ metadata.gz: cdaf80a00de09a2fcb18c9dd5ef5b0bcd1491437
4
+ data.tar.gz: 8ef2ffc7a90fac372189b3968aed3003bde0f7c4
5
5
  SHA512:
6
- metadata.gz: e81eccda0f368004b95d6a5f6aff630b82d2ac6c677bfa1295cb5eec69a2b41c34a9ff818087a58e77cc20cb4a4ca3397f90e4aa528db97e793f717fa0547c75
7
- data.tar.gz: 946a0e3ed65e4eda0b2fb2fef501229cd57f00b548443be5d4d7219ce6d2bfeec04d9b7b6b0d6329386d601d0c1497ddf509ce0e27fbd3587f6bbb84e751fcc0
6
+ metadata.gz: 26ed05f6ae3fde1a51daf47727454a8b279d5041846662608229a1ea2e82c7a0952101fb0a7828e1878df0df23e675001928d0fbdb702d657d242cb4f1369603
7
+ data.tar.gz: ccf273c1e402883e71570be64ad57ab7ea0a46e0c8abf7b22d952785a35baa49b0c6fbd6c0db1e6d8d701e711fcec5a0f206c5530d7eb157a3aa40bca5324280
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ tmp
8
8
  *.gem
9
9
  .bundle
10
10
  Gemfile.lock
11
+ .rvmrc
@@ -1,12 +1,8 @@
1
1
  language: "ruby"
2
2
  script: "bundle exec rake"
3
3
  rvm:
4
- - 1.8.7
5
4
  - 1.9.2
6
5
  - 1.9.3
7
6
  - 2.0.0
8
- - jruby-18mode
9
7
  - jruby-19mode
10
- - rbx-18mode
11
- - rbx-19mode
12
- - ree
8
+ - rbx
@@ -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
@@ -3,3 +3,10 @@ gemspec
3
3
 
4
4
  gem 'simplecov', :require => false
5
5
  gem 'coveralls', :require => false
6
+
7
+ platform :rbx do
8
+ gem 'json'
9
+ gem 'racc'
10
+ gem 'rubysl'
11
+ gem 'rubinius-coverage'
12
+ end
@@ -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", "~> 0.9"
20
- s.add_development_dependency "rspec", "~> 2.10"
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")
@@ -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
@@ -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
- node_value = node_value.delete(:content!) || node_value
55
- node_value = "" if node_value.empty?
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
@@ -1,5 +1,5 @@
1
1
  module Gyoku
2
2
 
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
 
5
5
  end
@@ -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)
@@ -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.0
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: 2013-07-26 00:00:00.000000000 Z
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.9'
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.9'
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: '2.10'
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: '2.10'
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.0.6
102
+ rubygems_version: 2.1.11
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Translates Ruby Hashes to XML