to_simple_yaml 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/to_simple_yaml/core.rb +5 -1
- data/lib/to_simple_yaml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c76270e331bbf7777a3d8cd3c30641190aa9d3b55f57f8ff98d5aedde4c33a98
|
4
|
+
data.tar.gz: b5320876cecb59e36abd6796f182a25ab6f29304b3a57d3e56106ef532357191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9fdb6313015c8d41b298e9c7145eb41e7c9b1b4518b0bc8b4af2d31a8ff391f00a231e2d42928cadc96072374d4d772c98c2adfcd649c15df540043174f16e0
|
7
|
+
data.tar.gz: ef0a04d7fa13d1555eb10ea846e5e6eeafd73694abf865d506f5a47b11c0851acf1c4e13e44422d48f12c2fcb4309f26aa864820c1b0f8ecee170f1afb3b0463
|
data/Gemfile.lock
CHANGED
data/lib/to_simple_yaml/core.rb
CHANGED
@@ -21,6 +21,8 @@ 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?
|
25
|
+
|
24
26
|
yaml = ''
|
25
27
|
obj.compact.keys.each_with_index do |key, index|
|
26
28
|
array_first = array && index == 0
|
@@ -45,6 +47,8 @@ class Object
|
|
45
47
|
end
|
46
48
|
yaml
|
47
49
|
elsif obj.is_a?(Array)
|
50
|
+
return template('[]', indent) if obj.empty?
|
51
|
+
|
48
52
|
yaml = ''
|
49
53
|
obj.compact.each do |value|
|
50
54
|
if value.is_a?(String) && value.include?("\n")
|
@@ -77,7 +81,7 @@ class Object
|
|
77
81
|
end
|
78
82
|
|
79
83
|
def text(value)
|
80
|
-
if value.to_s.start_with?('#', '*')
|
84
|
+
if value.to_s.start_with?('#', '*', '[', '{')
|
81
85
|
"'#{value}'"
|
82
86
|
else
|
83
87
|
value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_simple_yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tanmen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|