class PuppetGenerator::ImportFilters::Yaml

Public Instance Methods

convert(lines) click to toggle source
# File lib/puppet_generator/import_filters/yaml.rb, line 4
def convert(lines)
  hash_keys_from_str_to_sym(Psych.load(lines.join("\n")))
end

Private Instance Methods

hash_keys_from_str_to_sym(hash) click to toggle source
# File lib/puppet_generator/import_filters/yaml.rb, line 10
def hash_keys_from_str_to_sym(hash)
  hash.inject([]) do |result,(name,attributes)|
    result << attributes.inject( { name: name} ) { |result, (k,v)| result[k.to_sym] = v; result }
  end
rescue Exception => e
  raise Exceptions::InvalidYamlInput, e.message
end