extended_stdlib
Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x
- Puppet >= 5.5.0 < 8.0.0
- , , ,
Start using this module
Add this module to your Puppetfile:
mod 'mschuchard-extended_stdlib', '0.9.0'
Learn more about managing modules with a PuppetfileDocumentation
Extended Stdlib
Overview
This module provides an extra set of extensions and expanded functionality for Puppet modules beyond that which is covered by stdlib
.
Module Description
This Puppet module adds extra facts, functions, types and providers, and plans and tasks to Puppet. These should not overlap with the functionality provided by the stdlib
module. These are also likely to be overall at least slightly less useful than those provided in stdlib
.
Setup
Install the extended_stdlib
module to add the functionality to Puppet. Pluginsync will automatically ensure the functionality prior to the next catalog application.
If you are authoring a module that depends on extended_stdlib
, then be sure to specify dependencies in your metadata.json
.
Usage
These are all automatically loaded by Puppet via pluginsync.
Reference
Please see the Reference for generated documentation.
Limitations
The Ruby code is tested primarily with versions synced with Puppet 7 and 8. Compatibility with Ruby versions synced with 5 and 6 is desired, but not guaranteed. Please open an issue if an incompatibility is encountered.
Contributing
Code should pass all current tests. New features should include new tests. Adherence to Ruby and Puppet style standards is expected where not overly onerous or where the check is of dubious cost/benefit.
Please consult the GitHub Project for the current development roadmap.
Reference
Table of Contents
Functions
extended_stdlib::compact
: Returns a hash or array with all of the undef value entries removedextended_stdlib::drop
: Returns an Array containing all but the first num element of the array, where num is a non-negative Integerextended_stdlib::intersect
: Returns true if the array and other_array have at least one element in common, otherwise returns false. Will require Puppet version 8 due toextended_stdlib::minmax
: Returns a new two element Array containing the minimum and maximum values from an array of integersextended_stdlib::none
: Returns a boolean of whether no elements of an array, or array or hash with a lambda block meet a given criterion. Note that the combined bloextended_stdlib::subset
: Returns a boolean of whether the first hash is a subset of the second hash
Functions
extended_stdlib::compact
Type: Ruby 4.x API
Returns a hash or array with all of the undef value entries removed
Examples
Input a hash and return it compacted.
compact({'foo' => 0, 'bar' => undef, 'baz' => 2, 'bat' => undef}) => {'foo' => 0, 'baz' => 2}
Input an array and return it compacted.
compact([undef, 0, undef, 1, undef, 2, undef]) => [0, 1, 2]
extended_stdlib::compact(Variant[Hash, Array] $hash_or_array)
Returns a hash or array with all of the undef value entries removed
Returns: Variant[Hash, Array]
The hash or array with all of the undef value entries removed.
Examples
Input a hash and return it compacted.
compact({'foo' => 0, 'bar' => undef, 'baz' => 2, 'bat' => undef}) => {'foo' => 0, 'baz' => 2}
Input an array and return it compacted.
compact([undef, 0, undef, 1, undef, 2, undef]) => [0, 1, 2]
hash_or_array
Data type: Variant[Hash, Array]
The hash or array from which to remove the undef value entries.
extended_stdlib::drop
Type: Ruby 4.x API
Returns an Array containing all but the first num element of the array, where num is a non-negative Integer
Examples
Remove the first 0, 1, and 2 elements from an array, and return that array.
drop([0, 1, 2, 3, 4, 5], 0) => [0, 1, 2, 3, 4, 5]
drop([0, 1, 2, 3, 4, 5], 1) => [1, 2, 3, 4, 5]
drop([0, 1, 2, 3, 4, 5], 2) => [2, 3, 4, 5]
extended_stdlib::drop(Array $the_array, Integer $num)
Returns an Array containing all but the first num element of the array, where num is a non-negative Integer
Returns: Array
Returns the array with the first num elements removed.
Examples
Remove the first 0, 1, and 2 elements from an array, and return that array.
drop([0, 1, 2, 3, 4, 5], 0) => [0, 1, 2, 3, 4, 5]
drop([0, 1, 2, 3, 4, 5], 1) => [1, 2, 3, 4, 5]
drop([0, 1, 2, 3, 4, 5], 2) => [2, 3, 4, 5]
the_array
Data type: Array
The array to remove the first num elements from.
num
Data type: Integer
The number of first elements to remove from the array.
extended_stdlib::intersect
Type: Ruby 4.x API
Returns true if the array and other_array have at least one element in common, otherwise returns false. Will require Puppet version 8 due to Ruby >= 3.0 requirement.
Examples
Determine if first arry and second array intersect.
intersect([1, 2, 3], [3, 4, 5]) => true
intersect([1, 2, 3], [5, 6, 7]) => false
extended_stdlib::intersect(Array $a_array, Array $other_array)
Returns true if the array and other_array have at least one element in common, otherwise returns false. Will require Puppet version 8 due to Ruby >= 3.0 requirement.
Returns: Boolean
Returns whether the two arrays intersect.
Examples
Determine if first arry and second array intersect.
intersect([1, 2, 3], [3, 4, 5]) => true
intersect([1, 2, 3], [5, 6, 7]) => false
a_array
Data type: Array
The first array to determine if intersects.
other_array
Data type: Array
The second array to determine if intersects.
extended_stdlib::minmax
Type: Ruby 4.x API
Returns a new two element Array containing the minimum and maximum values from an array of integers
Examples
Return the minimum and maximum elements of an array.
minmax([0, 1, 2]) => [0, 2]
extended_stdlib::minmax(Array[Integer, 2] $the_array)
Returns a new two element Array containing the minimum and maximum values from an array of integers
Returns: Array[Integer, 2]
Returns two element array of integers with minimum and maximum values.
Examples
Return the minimum and maximum elements of an array.
minmax([0, 1, 2]) => [0, 2]
the_array
Data type: Array[Integer, 2]
The array of integers from which to return the minimum and maximum values.
extended_stdlib::none
Type: Ruby 4.x API
Returns a boolean of whether no elements of an array, or array or hash with a lambda block meet a given criterion. Note that the combined block input forms do not have code coverage at the moment.
extended_stdlib::none(Array $the_array)
The extended_stdlib::none function.
Returns: Boolean
Returns whether no elements satisfy a conditional (i.e. every element is falsey).
Examples
Return whether no element of any array is truthy.
none([undef, false]) => true
none([undef, 0, false]) => false
none([]) => true
the_array
Data type: Array
The array containing the elements to test the criterion upon. the_hash The hash containing the entries to test the criterion upon. block The optional lambda block to specify the criterion (otherwise directly tests falsiness).
extended_stdlib::none(Hash[Any, Any] $the_hash, Callable[2,2] &$block)
The extended_stdlib::none function.
Returns: Boolean
the_hash
Data type: Hash[Any, Any]
&block
Data type: Callable[2,2]
extended_stdlib::none(Hash[Any, Any] $the_hash, Callable[1,1] &$block)
The extended_stdlib::none function.
Returns: Boolean
the_hash
Data type: Hash[Any, Any]
&block
Data type: Callable[1,1]
extended_stdlib::none(Iterable $enumerable, Callable[2,2] &$block)
The extended_stdlib::none function.
Returns: Boolean
enumerable
Data type: Iterable
&block
Data type: Callable[2,2]
extended_stdlib::none(Iterable $enumerable, Callable[1,1] &$block)
The extended_stdlib::none function.
Returns: Boolean
enumerable
Data type: Iterable
&block
Data type: Callable[1,1]
extended_stdlib::subset
Type: Ruby 4.x API
Returns a boolean of whether the first hash is a subset of the second hash
Examples
Determine if hash is subset of other_hash.
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1, 'baz' => 2}) => true
subset({'foo' => 0, 'bar' => 1, 'baz' => 2}, {'foo' => 0, 'bar' => 1}) => false
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1}) => true
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1}, true) => false
extended_stdlib::subset(Hash $a_hash, Hash $other_hash, Optional[Boolean] $proper)
Returns a boolean of whether the first hash is a subset of the second hash
Returns: Boolean
Returns whether hash is a subset of other_hash.
Examples
Determine if hash is subset of other_hash.
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1, 'baz' => 2}) => true
subset({'foo' => 0, 'bar' => 1, 'baz' => 2}, {'foo' => 0, 'bar' => 1}) => false
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1}) => true
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1}, true) => false
a_hash
Data type: Hash
The hash to determine if this hash is a subset of other_hash.
other_hash
Data type: Hash
The hash to determine if hash is a subset of this hash.
proper
Data type: Optional[Boolean]
Specifies if the subset determination should be for a proper subset or regular subset.
0.9.0
- Initial beta release.