to_simple_yaml 1.0.9 → 1.0.10

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
  SHA256:
3
- metadata.gz: c76270e331bbf7777a3d8cd3c30641190aa9d3b55f57f8ff98d5aedde4c33a98
4
- data.tar.gz: b5320876cecb59e36abd6796f182a25ab6f29304b3a57d3e56106ef532357191
3
+ metadata.gz: 4c8b25ea6a6795b751c6e0e76e01d969ae6a9a7843ac142072f31800932694ab
4
+ data.tar.gz: 80bf8a37f9d0b8498350d1764ca849e171b1791dba5eaa4de2a96a071a452ab3
5
5
  SHA512:
6
- metadata.gz: d9fdb6313015c8d41b298e9c7145eb41e7c9b1b4518b0bc8b4af2d31a8ff391f00a231e2d42928cadc96072374d4d772c98c2adfcd649c15df540043174f16e0
7
- data.tar.gz: ef0a04d7fa13d1555eb10ea846e5e6eeafd73694abf865d506f5a47b11c0851acf1c4e13e44422d48f12c2fcb4309f26aa864820c1b0f8ecee170f1afb3b0463
6
+ metadata.gz: 21a2473079aa1795e7c582d09adf2b068779981f636d6498149b7aefce91ce1bd152c685f3dc7fa655d667df8708983b253213d6eb2c6cd9eabb81a31cc2da23
7
+ data.tar.gz: b43b5ae0ac0254cd4389c13c03d79590284fdc8c3556597006ebcac1c025e14a4290e36d5f1b27a25c5fd66edf49009d6032bbdd3a60a88c45344d83780becbb
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- to_simple_yaml (1.0.9)
4
+ to_simple_yaml (1.0.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -21,7 +21,7 @@ class Object
21
21
 
22
22
  def generate_yaml(obj, indent: 0, array: false)
23
23
  if obj.is_a?(Hash)
24
- return template("#{array ? '- ' : ''}{}", indent) if obj.values.empty?
24
+ return template("#{array ? '- ' : ''}{}", indent) if obj.empty?
25
25
 
26
26
  yaml = ''
27
27
  obj.compact.keys.each_with_index do |key, index|
@@ -38,8 +38,12 @@ class Object
38
38
  elsif obj[key].is_a?(String) || obj[key].is_a?(Symbol) || obj[key].is_a?(Numeric) || obj[key].is_a?(TrueClass) || obj[key].is_a?(FalseClass)
39
39
  yaml << template("#{array_first ? '- ' : ''}#{text(key)}: #{text(obj[key])}", array_inline ? indent + 1 : indent)
40
40
  elsif obj[key].is_a?(Array)
41
- yaml << template("#{array_first ? '- ' : ''}#{text(key)}:", array_inline ? indent + 1 : indent)
42
- yaml << generate_yaml(obj[key], indent: array_inline ? indent + 2 : indent + 1)
41
+ if obj[key].empty?
42
+ yaml << template("#{array_first ? '- ' : ''}#{text(key)}: []", array_inline ? indent + 1 : indent)
43
+ else
44
+ yaml << template("#{array_first ? '- ' : ''}#{text(key)}:", array_inline ? indent + 1 : indent)
45
+ yaml << generate_yaml(obj[key], indent: array_inline ? indent + 2 : indent + 1)
46
+ end
43
47
  else
44
48
  yaml << template("#{array_first ? '- ' : ''}#{text(key)}:", array_inline ? indent + 1 : indent)
45
49
  yaml << generate_yaml(obj[key], indent: array_inline || array_first ? indent + 2 : indent + 1)
@@ -1,3 +1,3 @@
1
1
  module ToSimpleYaml
2
- VERSION = "1.0.9"
2
+ VERSION = "1.0.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_simple_yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - tanmen