# Encoding: utf-8
Ohai.plugin(:CustomData) do
  provides 'customdata'

  def get_data_from_file(path)
    file_data = Mash.new
    if File.file?(path)
      file_content = File.read(path).chomp
      file_content.split("\n").each do |data|
        a, b = data.chomp.split(/=/)
        a.strip! if a
        b.strip! if b
        file_data[a] = b if a && b
      end
    else
      Ohai::Log.warn("Cannot find file #{path}; returning empty result")
    end
    file_data
  end

  collect_data do
    customdata Mash.new
  end
end
