lib/kumogata/client.rb in kumogata-0.1.8 vs lib/kumogata/client.rb in kumogata-0.1.9

- old
+ new

@@ -145,81 +145,36 @@ Dslh.deval(template, :key_conv => key_conv, :value_conv => value_conv, :exclude_key => exclude_key) end def define_template_func(scope) scope.instance_eval(<<-'EOS') - def _user_data(data, options = {}) - options = { - :encode => true, - :strip => true, - }.merge(options) - - 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 = { - :strip => true, + :undent => true, :trim_mode => nil, }.merge(options) + data = data.undent if options[:undent] @__refs__ = [] def Ref(value); @__refs__ << {"Ref" => value}; "\0"; end data = ERB.new(data, nil, options[:trim_mode]).result(binding) undef Ref data = data.split("\0").zip(@__refs__) @__refs__ = nil - data = data.flatten.select {|i| not i.nil? } + data = data.flatten.select {|i| not i.nil? }.map {|i| + if i.kind_of?(String) + StringIO.new(i).to_a + else + i + end + }.flatten - if options[:strip] - prev_elem_is_string = true - - data = data.map {|item| - if item.kind_of?(String) - new_item = [] - splited = item.split("\n") - - splited.each_with_index do |i, idx| - unless idx.zero? and not prev_elem_is_string - i.gsub!(/\A\s+/, '') - end - - if idx < splited.length - 1 - i << "\n" - end - - new_item << i - end - - prev_elem_is_string = true - new_item - else - prev_elem_is_string = false - item - end - }.flatten - end - - if data.last.kind_of?(String) and data.last.strip.empty? - data.last.replace("\n") - end - - unless data.last.kind_of?(String) and data.last =~ /\n\Z/ - data << "\n" - end - return { - "Fn::Join" => ["", data] + 'Fn::Join' => ['', data] } end def _path(path, value = nil, &block) if block @@ -407,10 +362,14 @@ :resource_type, :resource_status, :resource_status_reason, :last_updated_timestamp ].each do |k| - summary_hash[k.to_s.camelcase] = summary[k] + camelcase = k.to_s.split(/[-_]/).map {|i| + i[0, 1].upcase + i[1..-1].downcase + }.join + + summary_hash[camelcase] = summary[k] end summary_hash end end