Ottomata has submitted this change and it was merged. Change subject: Add union function from stdlib upstream ......................................................................
Add union function from stdlib upstream Change-Id: I7a7160dfee94b8f38e3c7754bd277b1f9b88df79 --- A modules/stdlib/lib/puppet/parser/functions/union.rb 1 file changed, 26 insertions(+), 0 deletions(-) Approvals: Ottomata: Verified; Looks good to me, approved diff --git a/modules/stdlib/lib/puppet/parser/functions/union.rb b/modules/stdlib/lib/puppet/parser/functions/union.rb new file mode 100644 index 0000000..c96345f --- /dev/null +++ b/modules/stdlib/lib/puppet/parser/functions/union.rb @@ -0,0 +1,26 @@ +# +# union.rb +# + +module Puppet::Parser::Functions + newfunction(:union, :type => :rvalue, :doc => <<-EOS +This function returns a union of two or more arrays. +*Examples:* + union(["a","b","c"],["b","c","d"]) +Would return: ["a","b","c","d"] + EOS + ) do |arguments| + + # Check that 2 or more arguments have been given ... + raise(Puppet::ParseError, "union(): Wrong number of arguments " + + "given (#{arguments.size} for < 2)") if arguments.size < 2 + + arguments.each do |argument| + raise(Puppet::ParseError, 'union(): Every parameter must be an array') unless argument.is_a?(Array) + end + + arguments.reduce(:|) + end +end + +# vim: set ts=2 sw=2 et : -- To view, visit https://gerrit.wikimedia.org/r/291119 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7a7160dfee94b8f38e3c7754bd277b1f9b88df79 Gerrit-PatchSet: 2 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ottomata <o...@wikimedia.org> Gerrit-Reviewer: Ottomata <o...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits