Puppet Function: ini

Defined in:
modules/wmflib/lib/puppet/parser/functions/ini.rb
Function type:
Ruby 3.x API

Overview

ini()Any

Returns:

  • (Any)


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'modules/wmflib/lib/puppet/parser/functions/ini.rb', line 31

newfunction(:ini, :type => :rvalue, :arity => -2) do |args|
  if args.map(&:class).uniq != [Hash]
    fail(ArgumentError, 'ini(): hash arguments required')
  end
  args.reduce(&:merge).map do |section, items|
    ini_flatten(items).map do |k, vs|
      case vs
      when Array then vs.map { |v| "#{k}[#{v}] = #{ini_cast(v)}" }
      else "#{k} = #{ini_cast(vs)}"
      end
    end.flatten.sort.push('').unshift("[#{section}]").join("\n")
  end.flatten.sort.push('').join("\n")
end