X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fbase64.rb;h=45e1fdbc56af0eec529456ca64e477e15571e2a7;hp=d77db8bbfbabfd85abd20c2bd84a97c5262e112a;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb index d77db8bbf..45e1fdbc5 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb @@ -1,27 +1,36 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. module Puppet::Parser::Functions - newfunction(:base64, :type => :rvalue, :doc => <<-'DOC') do |args| - Base64 encode or decode a string based on the command and the string submitted + newfunction(:base64, :type => :rvalue, :doc => <<-DOC) do |args| + @summary + Base64 encode or decode a string based on the command and the string submitted - Usage: + @example Example usage - $encodestring = base64('encode', 'thestring') - $decodestring = base64('decode', 'dGhlc3RyaW5n') + Encode and decode a string - # explicitly define encode/decode method: default, strict, urlsafe - $method = 'default' - $encodestring = base64('encode', 'thestring', $method) - $decodestring = base64('decode', 'dGhlc3RyaW5n', $method) + $encodestring = base64('encode', 'thestring') + $decodestring = base64('decode', 'dGhlc3RyaW5n') - Note: Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings. - See the `new()` function for the Binary and String types for documentation. Also see `binary_file()` - function for reading a file with binary (non UTF-8) content. + Explicitly define encode/decode method: default, strict, urlsafe + + $method = 'default' + $encodestring = base64('encode', 'thestring', $method) + $decodestring = base64('decode', 'dGhlc3RyaW5n', $method) + + Encode a string as if it was binary - # encode a string as if it was binary $encodestring = String(Binary('thestring', '%s')) - # decode a Binary assuming it is an UTF-8 String + + Decode a Binary assuming it is an UTF-8 String + $decodestring = String(Binary("dGhlc3RyaW5n"), "%s") + > **Note:* + Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings. + See the `new()` function for the Binary and String types for documentation. Also see `binary_file()` + function for reading a file with binary (non UTF-8) content. + + @return [String] The encoded/decoded value DOC require 'base64'