Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
2c836c5
(PUP-5556) Update sprintf_hash with info that this is in sprintf
hlindberg May 11, 2018
f3bf4cd
(PUP-8603) Add note that abs() is in puppet since 6.0.0
hlindberg May 14, 2018
1e48c41
(docs) Add information to base64 function about Binary data type
hlindberg May 14, 2018
032d536
(PUP-8603) Add note to camelcase() that function is now in puppet.
hlindberg May 14, 2018
56897e5
(PUP-8603) Add note to capitalize() that function is now in puppet.
hlindberg May 14, 2018
2311e2d
(PUP-8603) Add note to ceiling() that function is now in puppet.
hlindberg May 14, 2018
63a42f9
(PUP-8604) Add note to chomp() that function is now in puppet.
hlindberg May 16, 2018
d38811b
(PUP-8604) Add note to chop() that function is now in puppet.
hlindberg May 16, 2018
ad58e8b
(docs) Add note how to do equivalence of clamp() function in puppet 6
hlindberg May 16, 2018
c5db075
(docs) Add note that concat() can be done with + since puppet 4.0.0
hlindberg May 16, 2018
9b78497
(docs) Add note to convert_base() how to do this with puppet core
hlindberg May 16, 2018
678d498
(docs) Correct documentation of count() wrt matches and empty string
hlindberg May 16, 2018
ac5485a
(docs) Add equivalent puppet core way of doing count()
hlindberg May 16, 2018
ba8a8cc
(docs) Add docs for equivalent language constructs for delete_at()
hlindberg May 16, 2018
fb5fbc8
(docs) Add docs for equivalent puppet language for delete_regexp()
hlindberg May 16, 2018
735f361
(docs) Add puppet 4 equivalent for delete_undef() function
hlindberg May 16, 2018
94914cc
(docs) Add equivalent puppet language for delete_values()
hlindberg May 16, 2018
6692fd3
(docs) Update delete() function with docs about equivalent language
hlindberg May 16, 2018
87165bb
(docs) Add docs that - between arrays is the same as difference()
hlindberg May 16, 2018
0a264fe
(PUP-8604) Add note to downcase() that function is now in puppet.
hlindberg May 17, 2018
fec3d74
(PUP-8492) Add note to empty() that function is now in puppet.
hlindberg May 17, 2018
6432ed7
(PUP-8509) Add note to flatten() that function is now in puppet.
hlindberg May 17, 2018
22c2bf5
(PUP-8503) Add note to floor() that function is now in puppet.
hlindberg May 17, 2018
91c3cec
(PUP-6977) Add note to get_module_path() that puppet has similar func
hlindberg May 17, 2018
02e68e4
(docs) Correct example in getparam() and add note about equiv in puppet
hlindberg May 17, 2018
88a3cc8
(docs) Amend documentation for getvar()
hlindberg May 17, 2018
d465bc0
(docs) Add note to grep() that filter() in puppet does the same.
hlindberg May 17, 2018
ccf6749
(docs) Update has_key() with equivalent puppet lang expresion
hlindberg May 17, 2018
9f6f355
(docs) Update the hash() function to show equivalent expression
hlindberg May 17, 2018
68baa55
(docs) Add note about more formatting options with String() in puppet
hlindberg May 17, 2018
4783a29
(PUP-8507) Add note to join() that it is in puppet since 5.4.0
hlindberg May 17, 2018
dd8a076
(PUP-8496) Add note to keys() that it is in puppet since 5.4.0
hlindberg May 17, 2018
c0e997c
(PUP-8604) Add note to functions that they are in puppet since 6.0.0
hlindberg May 17, 2018
0042e66
(docs) Update member() with equivalent language expression example
hlindberg May 17, 2018
f8be3a7
(docs) Update merge() with puppt language equivalent example
hlindberg May 17, 2018
b8e9406
(PUP-8603) Update min() and max() with note that they are in puppet
hlindberg May 17, 2018
d468191
(docs) Update num2bool() with information that Boolean can convert
hlindberg May 17, 2018
b75a13f
(docs) Update prefix() function with equivalent operation in pupppet
hlindberg May 17, 2018
a3f08eb
(docs) Update range() with information that Integer can be used
hlindberg May 17, 2018
b7fe1c7
(docs) Update reject() with equivalent filter() call.
hlindberg May 17, 2018
e499610
(docs) Add note to reverse() that reverse_each() does the same
hlindberg May 17, 2018
41f9aa9
(PUP-8603) Add note to round() that it has moved to puppet in 6.0.0
hlindberg May 17, 2018
2f77555
(PUP-8497) Add note to size() that length() is in puppet since 5.4.0
hlindberg May 17, 2018
3ef6071
(PUP-8605) Add note to sort() that is has moved to Puppet in 6.0.0
hlindberg May 17, 2018
fbee143
(docs) Update str2bool() with a note that Boolean can handle conversion
hlindberg May 17, 2018
77e5c09
(PUP-6724) Add note to strftime that it moved to puppet in 4.8.0
hlindberg May 17, 2018
8e090ea
(docs) Add note to suffix() that the same can be done with map()
hlindberg May 17, 2018
70a8f5a
(docs) Update time() to mention Timespan and Timestamp data types
hlindberg May 17, 2018
5c32e03
(docs) Add note to values_at for equivalent slice operation in language
hlindberg May 17, 2018
130a1a4
(PUP-8496) Add note to values() that it moved to puppet in 5.5.0
hlindberg May 17, 2018
d37710a
(PUP-8496) Correct docs for keys() - in puppet since 5.5.0
hlindberg May 17, 2018
d4b11dc
(PUP-8497) Add note to length() that function moved to puppet
hlindberg Jun 12, 2018
0ce6c5d
(docs) Update README.md with deprecations for functions moved to puppet
hlindberg Jun 12, 2018
dc816e6
(docs) Update documentation of values_at
hlindberg Jun 12, 2018
c00ad33
(docs) Update README with note from time() aobut data types for time
hlindberg Jun 12, 2018
74aa91d
(docs) Update README for strintf_hash (supported by builtin sprintf)
hlindberg Jun 12, 2018
70b2a27
(docs) Update README with deprecation of hash() function (use data type)
hlindberg Jun 12, 2018
359a759
(docs) Update README `suffix` with equiv example for `map`
hlindberg Jun 12, 2018
832b221
(docs) Update README with `reject` equivalent call to `filter`
hlindberg Jun 12, 2018
2206ad1
(docs) Update README with `range` equiv use of type system + `each`
hlindberg Jun 12, 2018
61f17f6
(docs) Update README with `prefix` equiv func using `map`
hlindberg Jun 13, 2018
465f144
(docs) Update README for `num2bool` with info about Boolean type.
hlindberg Jun 13, 2018
2d54af2
(docs) Fix URL to use 'latest' instead of '5.5' for `Hash.new` function
hlindberg Jun 13, 2018
5e45b1a
(docs) Update README `str2bool` with information about `Boolean` equiv
hlindberg Jun 13, 2018
64c76d4
(docs) Update README `merge` with info about `+` operator equiv
hlindberg Jun 13, 2018
35403f3
(docs) Update README `member` with equiv alternative in language
hlindberg Jun 13, 2018
a097709
(docs) Update README `join_keys_to_values` with link to String.new
hlindberg Jun 13, 2018
6bb304a
(docs) Update README `has_key` shows deprecation in favor of `in`
hlindberg Jun 13, 2018
30f3695
(docs) Update README `grep` adds information about `filter`
hlindberg Jun 13, 2018
b0ed439
(docs) Update README and `getvar.rb` as getvar has moved to puppet
hlindberg Jun 14, 2018
4e91058
(docs) Update README for `getparam` to be the same as in function
hlindberg Jun 14, 2018
979aafe
(docs) Update README `get_module_path` with info about built in variant
hlindberg Jun 14, 2018
435d966
(docs) Update README `difference` to mention `-` operator equiv
hlindberg Jun 14, 2018
bbb62bc
(docs) Update README `delete` with built-in alternatives
hlindberg Jun 14, 2018
437f65d
(docs) Update README `delete_values` with builtin equiv
hlindberg Jun 14, 2018
0ce7dcb
(docs) Update README `delete_undef` & `delete_regexp` with builtin equiv
hlindberg Jun 14, 2018
1ecaa18
(docs) Update README `delete_at` with equivalent built-in examples
hlindberg Jun 14, 2018
319972a
(docs) Update README `count` to show built-in equiv
hlindberg Jun 14, 2018
b23a86a
(docs) Update README `convert_base` with built-in equiv
hlindberg Jun 14, 2018
870eb14
(docs) Update README `concat` with built-in equiv using + and <<
hlindberg Jun 14, 2018
674091a
(docs) Update README `base_64` with built-in equiv using Binary type
hlindberg Jun 14, 2018
fa94dc1
(PUP-8491) Skip tests for `abs` if puppet version < 6.0.0
hlindberg Jun 15, 2018
4d7adc3
(PUP-8491) Skip tests for `min` and `max` if puppet version < 6.0.0
hlindberg Jun 15, 2018
b54352e
(PUP-8491) Skip tests for `floor` if puppet version < 6.0.0
hlindberg Jun 15, 2018
32637f4
(PUP-8491) Skip tests for `ceiling` if puppet version < 6.0.0
hlindberg Jun 15, 2018
9959f5a
(PUP-8491) Skip tests for `round` if puppet version < 6.0.0
hlindberg Jun 15, 2018
687615b
(PUP-8491) Skip tests for `upcase` if puppet version < 6.0.0
hlindberg Jun 15, 2018
a848dab
(PUP-8491) Skip tests for `downcase` if puppet version < 6.0.0
hlindberg Jun 15, 2018
138c1e0
(PUP-8491) Skip tests for `capitalize` if puppet version < 6.0.0
hlindberg Jun 15, 2018
64743d4
(PUP-8491) Skip tests for `camelcase` if puppet version < 6.0.0
hlindberg Jun 15, 2018
02226ee
(PUP-8491) Skip tests for strip functions if puppet version < 6.0.0
hlindberg Jun 15, 2018
80087f5
(PUP-8491) Skip tests for `chop` and `chomp` if puppet version < 6.0.0
hlindberg Jun 15, 2018
7640928
(PUP-8491) Skip tests for `sort` if puppet version < 6.0.0
hlindberg Jun 15, 2018
bc0f5d1
(PUP-8491) Remove extra space in `describe` for `abs` test
hlindberg Jun 15, 2018
0770799
(docs) Update README with deprecations for functions moved to puppet
hlindberg Jun 18, 2018
f86639c
(docs) Update README and `any2array` with built-in equiv Array.new
hlindberg Jun 18, 2018
57830db
(docs) Update README and `any2bool` with built-in equiv Boolean.new
hlindberg Jun 18, 2018
8a5fbae
(docs) Update README and `bool2num` with built-in equiv Numeric.new
hlindberg Jun 18, 2018
200ac06
(docs) Update README and `bool2str` with built-in equiv String.new
hlindberg Jun 18, 2018
eb97b53
(docs) Correct equiv example for `count`
hlindberg Jun 18, 2018
0a1d4b9
(docs) Update README and make mention of `filter` in `delete` a link
hlindberg Jun 18, 2018
eb55092
(maint) Update docs and tests for `strftime`
hlindberg Jun 18, 2018
e835d93
readme edits
clairecadman Jun 19, 2018
b095a1c
(maint) Update all acceptance test using Puppet.version
hlindberg Jun 19, 2018
bc54ab6
readme edits 2
clairecadman Jun 20, 2018
b523727
Update README.md
clairecadman Jun 21, 2018
eac001e
Merge pull request #1 from clairecadman/readme_edits
hlindberg Jun 21, 2018
0fcf391
(docs) Update README make Puppet consistent with upper case P
hlindberg Jun 21, 2018
8ded9ad
(docs) Change 'puppet' to 'Puppet' in function doc strings
hlindberg Jun 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
313 changes: 295 additions & 18 deletions README.md

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion lib/puppet/functions/length.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# A function to eventually replace the old size() function for stdlib - The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution.
# A function to eventually replace the old size() function for stdlib
# The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution.
#
# Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
# will be used instead of this function.
#
Puppet::Functions.create_function(:length) do
dispatch :length do
param 'Variant[String,Array,Hash]', :value
Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/functions/sprintf_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# { 'foo' => 'a string', 'number' => 5 })
# # $output = 'String: a string / number converted to binary: 101'
#
# Note that since Puppet 4.10.10, and 5.3.4 this functionality is supported by the
# `sprintf` function in puppet core.
#
Puppet::Functions.create_function(:sprintf_hash) do
# @param format The format to use.
# @param arguments Hash with parameters.
Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/abs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module Puppet::Parser::Functions
newfunction(:abs, :type => :rvalue, :doc => <<-DOC
Returns the absolute value of a number, for example -34.56 becomes
34.56. Takes a single integer and float value as an argument.

Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
17 changes: 17 additions & 0 deletions lib/puppet/parser/functions/any2array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ module Puppet::Parser::Functions
This converts any object to an array containing that object. Empty argument
lists are converted to an empty array. Arrays are left untouched. Hashes are
converted to arrays of alternating keys and values.

Note that since Puppet 5.0.0 it is possible to create new data types for almost any
datatype using the type system and the built-in
[`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple)
function is used to create a new Array..

$hsh = {'key' => 42, 'another-key' => 100}
notice(Array($hsh))

Would notice `[['key', 42], ['another-key', 100]]`

The Array data type also has a special mode to "create an array if not already an array"

notice(Array({'key' => 42, 'another-key' => 100}, true))

Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being
transformed into an array.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/any2bool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module Puppet::Parser::Functions
* Number (or a string representation of a number) > 0 will return true, otherwise false
* undef will return false
* Anything else will return true

Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
function.
DOC
) do |arguments|

Expand Down
9 changes: 9 additions & 0 deletions lib/puppet/parser/functions/base64.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ module Puppet::Parser::Functions
$encodestring = base64('encode', 'thestring', $method)
$decodestring = base64('decode', 'dGhlc3RyaW5n', $method)

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.

# encode a string as if it was binary
$encodestring = String(Binary('thestring', '%s'))
# decode a Binary assuming it is an UTF-8 String
$decodestring = String(Binary("dGhlc3RyaW5n"), "%s")

DOC

require 'base64'
Expand Down
10 changes: 10 additions & 0 deletions lib/puppet/parser/functions/bool2num.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ module Puppet::Parser::Functions
false, f, 0, n, and no to 0
true, t, 1, y, and yes to 1
Requires a single boolean or string as an input.

Note that since Puppet 5.0.0 it is possible to create new data types for almost any
datatype using the type system and the built-in
[`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric),
[`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and
[`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float)
function are used to convert to numeric values.

notice(Integer(false)) # Notices 0
notice(Float(true)) # Notices 1.0
DOC
) do |arguments|

Expand Down
11 changes: 11 additions & 0 deletions lib/puppet/parser/functions/bool2str.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ module Puppet::Parser::Functions
bool2str(false, 't', 'f') => 'f'

Requires a single boolean as an input.

Note that since Puppet 5.0.0 it is possible to create new data types for almost any
datatype using the type system and the built-in
[`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string)
function is used to convert to String with many different format options.

notice(String(false)) # Notices 'false'
notice(String(true)) # Notices 'true'
notice(String(false, '%y')) # Notices 'yes'
notice(String(true, '%y')) # Notices 'no'

DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/camelcase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
module Puppet::Parser::Functions
newfunction(:camelcase, :type => :rvalue, :doc => <<-DOC
Converts the case of a string or all strings in an array to camel case.

Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/capitalize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module Puppet::Parser::Functions
newfunction(:capitalize, :type => :rvalue, :doc => <<-DOC
Capitalizes the first letter of a string or array of strings.
Requires either a single string or an array as an input.

Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/ceiling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module Puppet::Parser::Functions
newfunction(:ceiling, :type => :rvalue, :doc => <<-DOC
Returns the smallest integer greater or equal to the argument.
Takes a single numeric value as an argument.

Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/chomp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module Puppet::Parser::Functions
Removes the record separator from the end of a string or an array of
strings, for example `hello\n` becomes `hello`.
Requires a single string or array as an input.

Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/chop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module Puppet::Parser::Functions
string returns an empty string. If you wish to merely remove record
separators then you should use the `chomp` function.
Requires a string or array of strings as input.

Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/clamp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
module Puppet::Parser::Functions
newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-DOC
Clamps value to a range.

Note: From Puppet 6.0.0 this can be done with only core Puppet like this:
[$minval, $maxval, $value_to_clamp].sort[1]
DOC
) do |args|

Expand Down
4 changes: 4 additions & 0 deletions lib/puppet/parser/functions/concat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module Puppet::Parser::Functions
Would result in:

['1','2','3','4','5','6','7','8','9']

Note: Since Puppet 4.0 concatenation of arrays and hashes can be done with the + operator.

['1','2','3'] + ['4','5','6'] + ['7','8','9']
DOC
) do |arguments|

Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/parser/functions/convert_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ module Puppet::Parser::Functions
$binary_repr = convert_base(5, 2) # $binary_repr is now set to "101"
$hex_repr = convert_base("254", "16") # $hex_repr is now set to "fe"

Note: Since Puppet 4.5.0 this can be done with String.new() and its many formatting options:

$binary_repr = String(5, '%b') # results in "101"
$hex_repr = String(254, "%x") # results in "fe"
$hex_repr = String(254, "%#x") # results in "0xfe"
DOC

raise Puppet::ParseError, 'convert_base(): First argument must be either a string or an integer' unless args[0].is_a?(Integer) || args[0].is_a?(String)
Expand Down
16 changes: 14 additions & 2 deletions lib/puppet/parser/functions/count.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@
module Puppet::Parser::Functions
newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-DOC
Takes an array as first argument and an optional second argument.
Count the number of elements in array that matches second argument.
If called with only an array it counts the number of elements that are not nil/undef.
Count the number of elements in array that is equal to the second argument.
If called with only an array it counts the number of elements that are not nil/undef/empty-string.

Note: equality is tested with a Ruby method and it is therefore subject to what Ruby considers
to be equal. For strings this means that equality is case sensitive.

In Puppet core, counting can be done in general by using a combination of the core functions
filter() (since Puppet 4.0.0) and length() (since Puppet 5.5.0, before that in stdlib).
Example below shows counting values that are not undef.

notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)

Would notice the value 2.

DOC
) do |args|

Expand Down
16 changes: 16 additions & 0 deletions lib/puppet/parser/functions/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ module Puppet::Parser::Functions

delete('abracadabra', 'bra')
Would return: 'acada'

Note that from Puppet 4.0.0 the minus (-) operator deletes values from arrays and keys from a hash:

['a', 'b', 'c', 'b'] - 'b'
# would return ['a', 'c']

{'a'=>1,'b'=>2,'c'=>3} - ['b','c'])
# would return {'a' => '1'}

A global delete from a string can be performed with the regsubst() function:

'abracadabra'.regsubst(/bra/, '', 'G')
# would return 'acada'

In general, the filter() function can filter out entries from arrays and hashes based on keys and/or values.

DOC
) do |arguments|

Expand Down
11 changes: 11 additions & 0 deletions lib/puppet/parser/functions/delete_at.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ module Puppet::Parser::Functions
delete_at(['a','b','c'], 1)

Would return: ['a','c']

Note that since Puppet 4 this can be done in general with the filter function:

['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }

Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]:

$array[0, -1] # the same as all the values
$array[2, -1] # all but the first 2 elements
$array[0, -3] # all but the last 2 elements
$array[1, -2] # all but the first and last element
DOC
) do |arguments|

Expand Down
6 changes: 6 additions & 0 deletions lib/puppet/parser/functions/delete_regex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ module Puppet::Parser::Functions
delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
Would return: {'b'=>2,'c'=>3}

Note that since Puppet 4 this can be done in general with the filter function:

["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ }
# Would return: ['aaa', 'aca']


DOC
) do |arguments|

Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/parser/functions/delete_undef_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ module Puppet::Parser::Functions

Would return: ['A','',false]

Note that since Puppet 4.0.0 the equivalent can be performed with the filter() function in Puppet:

$array.filter |$val| { $val =~ NotUndef }
$hash.filter |$key, $val| { $val =~ NotUndef }

DOC
) do |args|

Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/parser/functions/delete_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ module Puppet::Parser::Functions

Would return: {'a'=>'A','c'=>'C','B'=>'D'}

Note that since Puppet 4.0.0 the equivalent can be performed with the filter() function in Puppet:

$array.filter |$val| { $val != 'B' }
$hash.filter |$key, $val| { $val != 'B' }

DOC
) do |arguments|

Expand Down
6 changes: 6 additions & 0 deletions lib/puppet/parser/functions/difference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ module Puppet::Parser::Functions
difference(["a","b","c"],["b","c","d"])

Would return: ["a"]

Note: Since Puppet 4 the minus (-) operator in the Puppet language does the same thing:

['a', 'b', 'c'] - ['b', 'c', 'd']
# would return ['a']

DOC
) do |arguments|

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/dig44.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Puppet::Parser::Functions
:type => :rvalue,
:arity => -2,
:doc => <<-DOC
DEPRECATED: This function has been replaced in puppet 4.5.0.
DEPRECATED: This function has been replaced in Puppet 4.5.0.

Looks up into a complex structure of arrays and hashes and returns a value
or the default value if nothing was found.
Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/downcase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
module Puppet::Parser::Functions
newfunction(:downcase, :type => :rvalue, :doc => <<-DOC
Converts the case of a string or all strings in an array to lower case.

Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/empty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
module Puppet::Parser::Functions
newfunction(:empty, :type => :rvalue, :doc => <<-DOC
Returns true if the variable is empty.

Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/flatten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module Puppet::Parser::Functions
flatten(['a', ['b', ['c']]])

Would return: ['a','b','c']

Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/floor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module Puppet::Parser::Functions
newfunction(:floor, :type => :rvalue, :doc => <<-DOC
Returns the largest integer less or equal to the argument.
Takes a single numeric value as an argument.

Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
will be used instead of this function.
DOC
) do |arguments|

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/parser/functions/get_module_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module Puppet::Parser::Functions

Example:
$module_path = get_module_path('stdlib')

Note that since Puppet 5.4.0 the function `module_directory()` in Puppet does the same thing and will return
the path to the first found module if given multiple values or an array.
DOC
) do |args|
raise(Puppet::ParseError, 'get_module_path(): Wrong number of arguments, expects one') unless args.size == 1
Expand Down
Loading