to_simple_yaml 1.0.6 → 1.0.7
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 +10 -2
- 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: 2d1c4abbcdba9a5db8e0f2fdeaa9365b1646a6ad64aabc431951299f02202e29
|
4
|
+
data.tar.gz: aa786850bd14f761ec57c4139a94cbfa15673e941bb077772d35734e51badc05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20de8618b3099b989c3784acfd1ae5500ffac973b89dc169b09b19b188a6e663415b930af3f8d704fa66a30957cfd8cf9f56364672390fcfcb6e770938c71a5d
|
7
|
+
data.tar.gz: 9a05da3d301bba8cbb4047f359128728c1d0218509ab1e9b235df3c5fd4f3740714e9737b27a7731a39987ab397d91c46e73c698e4bac4f3db6da7b9bca45f67
|
data/Gemfile.lock
CHANGED
data/lib/to_simple_yaml/core.rb
CHANGED
@@ -25,7 +25,11 @@ class Object
|
|
25
25
|
obj.compact.keys.each_with_index do |key, index|
|
26
26
|
array_first = array && index == 0
|
27
27
|
array_inline = array && index != 0
|
28
|
-
if obj[key].is_a?(String)
|
28
|
+
if obj[key].is_a?(String) && obj[key].match?(/\n/)
|
29
|
+
sentence = obj[key].split("\n").reject(&:empty?)
|
30
|
+
yaml << template("#{array_first ? '- ' : ''}#{text(key)}: |", array_inline ? indent + 1 : indent)
|
31
|
+
sentence.each {|s| yaml << template(s, array_inline ? indent + 2 : indent + 1)}
|
32
|
+
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)
|
29
33
|
yaml << template("#{array_first ? '- ' : ''}#{text(key)}: #{text(obj[key])}", array_inline ? indent + 1 : indent)
|
30
34
|
elsif obj[key].is_a?(Array)
|
31
35
|
yaml << template("#{array_first ? '- ' : ''}#{text(key)}:", array_inline ? indent + 1 : indent)
|
@@ -39,7 +43,11 @@ class Object
|
|
39
43
|
elsif obj.is_a?(Array)
|
40
44
|
yaml = ''
|
41
45
|
obj.compact.each do |value|
|
42
|
-
if value.is_a?(String)
|
46
|
+
if value.is_a?(String) && value.match?(/\n/)
|
47
|
+
sentence = value.split("\n").reject(&:empty?)
|
48
|
+
yaml << template("- |", indent)
|
49
|
+
sentence.each{|s| yaml << template(s, indent + 1)}
|
50
|
+
elsif value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(Numeric) || value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
43
51
|
yaml << template("- #{text(value)}", indent)
|
44
52
|
elsif value.is_a?(Array)
|
45
53
|
yaml << template('-', indent)
|
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.7
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|