lib/kumogata/client.rb in kumogata-0.1.4 vs lib/kumogata/client.rb in kumogata-0.1.5
- old
+ new
@@ -151,12 +151,16 @@
options = {
:encode => true,
:strip => true,
}.merge(options)
- data = data.strip_lines + "\n" if options[:strip]
+ if options[:strip]
+ data = data.split("\n").map {|i| i.gsub(/\A\s+/, "") }.join("\n") + "\n"
+ end
+
data = data.encode64 if options[:encode]
+
return data
end
def _join(data, options = {})
options = {
@@ -173,15 +177,25 @@
data = data.split("\0").zip(@__refs__)
@__refs__ = nil
data = data.flatten.select {|i| not i.nil? }
- unless data.last.kind_of?(String) and data.last =~ /\n\Z/
- data << "\n"
+ if options[:strip]
+ data = data.map do |item|
+ if item.kind_of?(String)
+ item.split("\n").map {|i| i.gsub(/\A\s+/, "") }.join("\n")
+ else
+ item
+ end
+ end
end
- if options[:strip]
- data = data.map {|i| i.kind_of?(String) ? i.strip + "\n" : i }
+ if data.last.kind_of?(String) and data.last == ""
+ data.last << "\n"
+ end
+
+ unless data.last.kind_of?(String) and data.last =~ /\n\Z/
+ data << "\n"
end
return {
"Fn::Join" => ["", data]
}