157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/ectoplasm.rb', line 157
def pretty indent: 0, width: 25
s = ''
self
.select { |_, value| value != nil || value != '' }
.map do |key, value|
value = true if value == 'true'
value = false if value == 'false'
value = '********' if Regexp.new(DEFAULT_SECURE_KEYS.join '|') =~ key.to_s
if value.is_a? Hash
s += key.to_s.cyan.indent(indent) + "\n"
s += value.pretty(width: width-indent-2).indent(indent+2)
s += "\n"
next
end
s += ' ' * indent
if value.is_a? Array
list = value.pretty(width: width)
if list.split("\n").count > 1
s += key.to_s.cyan + "\n"
s += value.pretty(width: width).indent(indent)
s += "\n"
next
end
value = list
end
s += key.to_s.cyan
s += ' ' + '.' * (width-key.to_s.length-indent) if width-key.to_s.length > indent
s += ': '
s += value.pretty + "\n"
end
s
end
|