Method: EasyType::Type#to_manifest

Defined in:
lib/easy_type/type.rb

#to_manifestObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/easy_type/type.rb', line 48

def to_manifest
  # Collect list of attributes to align => and move ensure first
  attr = parameters.keys
  attr_max = attr.inject(0) { |max, k| k.to_s.length > max ? k.to_s.length : max }

  attr.sort!
  if attr.first != :ensure && attr.include?(:ensure)
    attr.delete(:ensure)
    attr.unshift(:ensure)
  end

  attributes = attr.collect do |k|
    v = self[k]
    format("  %-#{attr_max}s => %s,\n", k, Puppet::Parameter.format_value_for_display(v))
  end.join

  escaped = title.gsub(/'/, "\\\\'")
  format("%s { '%s':\n%s}", type.to_s.downcase, escaped, attributes)
end