X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Ffunctions%2Fto_json_pretty.rb;h=6a5a8222da8fbb8ade774f533199fc47e78e6f06;hp=a7a1458254ba3d72a85b0a1e049f11374dad3b89;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/to_json_pretty.rb b/3rdparty/modules/stdlib/lib/puppet/functions/to_json_pretty.rb index a7a145825..6a5a8222d 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/to_json_pretty.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/to_json_pretty.rb @@ -1,14 +1,15 @@ -# Take a data structure and output it as pretty JSON +require 'json' +# @summary +# Convert data structure and output to pretty JSON # -# @example how to output pretty JSON -# # output pretty json to a file +# @example **Usage** +# * how to output pretty JSON to file # file { '/tmp/my.json': # ensure => file, # content => to_json_pretty($myhash), # } # -# @example how to output pretty JSON skipping over keys with undef values -# # output pretty JSON to a file skipping over undef values +# * how to output pretty JSON skipping over keys with undef values # file { '/tmp/my.json': # ensure => file, # content => to_json_pretty({ @@ -16,10 +17,13 @@ # param_two => undef, # }), # } -# -require 'json' - Puppet::Functions.create_function(:to_json_pretty) do + # @param data + # data structure which needs to be converted to pretty json + # @param skip_undef + # value `true` or `false` + # @return + # converted data to pretty json dispatch :to_json_pretty do param 'Variant[Hash, Array]', :data optional_param 'Boolean', :skip_undef