tokamak 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,12 +50,15 @@ module Tokamak
50
50
  end
51
51
 
52
52
  def insert_value(name, prefix, *args, &block)
53
- node = create_element(name.to_s, prefix, *args)
54
- node.parent = @parent
55
- if block_given?
56
- @parent = node
57
- block.call
58
- @parent = node.parent
53
+ # Protected if empty array
54
+ unless args.size == 1 and args.first == []
55
+ node = create_element(name.to_s, prefix, *args)
56
+ node.parent = @parent
57
+ if block_given?
58
+ @parent = node
59
+ block.call
60
+ @parent = node.parent
61
+ end
59
62
  end
60
63
  end
61
64
 
@@ -2,7 +2,7 @@ module Tokamak
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 1
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
 
@@ -108,6 +108,30 @@ class Tokamak::Builder::XmlTest < Test::Unit::TestCase
108
108
  assert_equal "bar" , xml.css("root > foos > id").first.text
109
109
  assert_equal 2 , xml.css("root > foos > id").size
110
110
  end
111
+
112
+ def test_values_that_should_be_an_array
113
+ obj = [{ :foo => ["bar", "zoom"] }]
114
+ xml = Tokamak::Builder::Xml.build(obj) do |collection|
115
+ collection.values do |values|
116
+ values.id "an_id"
117
+ end
118
+
119
+ collection.members do |member, some_foos|
120
+ member.values do |values|
121
+ values.ids []
122
+ some_foos[:foo].each do |id|
123
+ values.ids id
124
+ end
125
+ end
126
+ end
127
+ end
128
+
129
+ xml = Nokogiri::XML::Document.parse(xml)
130
+
131
+ assert_equal "root" , xml.root.name
132
+ assert_equal "an_id", xml.css("root id").first.text
133
+ assert_equal ["bar", "zoom"], xml.css("root > member > ids").map { |id| id.text }
134
+ end
111
135
 
112
136
  def test_nested_crazy_values
113
137
  obj = [{ :foo => "bar" }, { :foo => "zue" }]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokamak
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 3
10
- version: 1.1.3
9
+ - 4
10
+ version: 1.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Luis Cipriani
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-16 00:00:00 -02:00
18
+ date: 2011-02-17 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency