toml-rb 0.3.8 → 0.3.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11774e9a1e1bd854ecbea270f7783170d696106f
4
- data.tar.gz: 8361a9754caf4fe566d41211b41e891b2cdbf5cf
3
+ metadata.gz: 53c8bc0a9cbb23e1d7f74b114ccb9b562ddc5925
4
+ data.tar.gz: 6e1545aca165045cb3fbf22221c0779765335724
5
5
  SHA512:
6
- metadata.gz: 8e441abc30fffeb1b8415049b9eea7a9ce792ccce114c1ded571836ce5aaa2df21df6b23dfb081426d1dfc1ce0a50c0796a9967779e8bdba74df83ff695aeadc
7
- data.tar.gz: 9939ef352941011861a7b1f15966b181ed34e87d24928d47ae2be677a5c90ff9995277181eb8418b5e43961dba71280ab45e0c127dca125205bcb105a467ead9
6
+ metadata.gz: fe091042c32d0c1bcfab2750711822e3914bc1d35b4a45a2cb28f7bd8ea64d4e86b589e6000c8f31299256138dcd209c74ecfa6e5b9ade7698051bb31b4fae09
7
+ data.tar.gz: 94c3033f5fc157f236d7586306e2b7d6e1d33ab38133651cfbf9ef78ac8e58afd02c98636f3702252e26df7e6d06e147037d49c53fbf6e6b0e9dc089d2b2e202
@@ -11,16 +11,20 @@ module TOML
11
11
  private
12
12
 
13
13
  def visit(hash, prefix, extra_brackets = false)
14
- simple_pairs, nested_pairs, table_array_pairs = sort_pairs hash
15
-
16
- unless prefix.empty? || simple_pairs.empty?
14
+ if hash.empty? && !prefix.empty?
17
15
  print_prefix prefix, extra_brackets
18
- end
16
+ else
17
+ simple_pairs, nested_pairs, table_array_pairs = sort_pairs hash
19
18
 
20
- # First add simple pairs, under the prefix
21
- dump_simple_pairs simple_pairs
22
- dump_nested_pairs nested_pairs, prefix
23
- dump_table_array_pairs table_array_pairs, prefix
19
+ unless prefix.empty? || simple_pairs.empty?
20
+ print_prefix prefix, extra_brackets
21
+ end
22
+
23
+ # First add simple pairs, under the prefix
24
+ dump_simple_pairs simple_pairs
25
+ dump_nested_pairs nested_pairs, prefix
26
+ dump_table_array_pairs table_array_pairs, prefix
27
+ end
24
28
  end
25
29
 
26
30
  def sort_pairs(hash)
@@ -62,4 +62,18 @@ class DumperTest < Minitest::Test
62
62
  dumped = TOML.dump(hash)
63
63
  assert_equal("[[hola]]\nchau = 4\n[[hola]]\nchau = 3\n", dumped)
64
64
  end
65
+
66
+ def test_print_empty_tables
67
+ hash = { plugins: { cpu: { foo: "bar", baz: 1234 }, disk: {}, io: {} } }
68
+ dumped = TOML.dump(hash)
69
+ toml = <<-EOS.gsub(/^ {6}/, '')
70
+ [plugins.cpu]
71
+ baz = 1234
72
+ foo = "bar"
73
+ [plugins.disk]
74
+ [plugins.io]
75
+ EOS
76
+
77
+ assert_equal toml, dumped
78
+ end
65
79
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'toml-rb'
3
- s.version = '0.3.8'
3
+ s.version = '0.3.9'
4
4
  s.date = Time.now.strftime('%Y-%m-%d')
5
5
  s.summary = 'TOML parser in ruby, for ruby.'
6
6
  s.description = 'A TOML parser using Citrus parsing library. '
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toml-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emiliano Mancuso
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-12 00:00:00.000000000 Z
12
+ date: 2015-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: citrus
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.4.5
88
+ rubygems_version: 2.4.8
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: TOML parser in ruby, for ruby.