self.to_ini

in cookbooks/fb_systemd/libraries/systemd_helpers.rb [59:93]


    def self.to_ini(content)
      append_sections = ''
      case content
      when Hash
        IniParse.gen do |doc|
          content.each_pair do |sect, opts|
            case opts
            when Hash
              doc.section(sect) do |section|
                opts.each_pair do |opt, val|
                  [val].flatten.each do |v|
                    section.option(opt, v)
                  end
                end
              end
            when Array
              opts.each do |o|
                append_sections << "\n" << IniParse.gen do |d|
                  d.section(sect) do |section|
                    o.each_pair do |opt, val|
                      [val].flatten.each do |v|
                        section.option(opt, v)
                      end
                    end
                  end
                end.to_s
              end
            end
          end
        end.to_s + append_sections
      else
        IniParse.parse(content.to_s).to_s
      end
    end