lib/marty/data_exporter.rb in marty-1.0.47 vs lib/marty/data_exporter.rb in marty-1.0.48
- old
+ new
@@ -48,10 +48,13 @@
}
# FIXME: very hacky to default row_sep to CRLF
conf[:row_sep] ||= "\r\n"
+ # remove non CSV.generate options before entering generate blocks
+ readable = conf.delete(:readable)
+
# FIXME: the following is ridiculously complex. We have different
# data paths for hashes and arrays. Also, arrays can turn into
# hashes is all their items are hashes! We map to complex objects
# to JSON when inside hashes, but not arrays. Really need to
# rethink this. Probably should have separate functions for
@@ -67,10 +70,10 @@
obj.each do |x|
x = [x] unless x.respond_to? :map
csv << x.map { |v|
case v
when Array, Hash
- encode_json(v.to_json)
+ readable ? v.to_s : encode_json(v.to_json)
when nil
nil
else
v.to_s
end