X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fenclose_ipv6.rb;h=b55f76b30762c68efb411dc07e55676a8740fc52;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=1f8a454934f7ed5a117e36ea14ed77c3c730d095;hpb=6963202b4b62c2816655ac9532521b018fdf83bd;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb index 1f8a45493..b55f76b30 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb @@ -1,24 +1,28 @@ # # enclose_ipv6.rb # - module Puppet::Parser::Functions - newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-EOS -Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. - EOS - ) do |arguments| + newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-DOC + @summary + Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. + + @return + encloses the ipv6 addresses with square brackets. + + DOC + ) do |arguments| require 'ipaddr' - rescuable_exceptions = [ ArgumentError ] + rescuable_exceptions = [ArgumentError] if defined?(IPAddr::InvalidAddressError) - rescuable_exceptions << IPAddr::InvalidAddressError + rescuable_exceptions << IPAddr::InvalidAddressError end - if (arguments.size != 1) then + if arguments.size != 1 raise(Puppet::ParseError, "enclose_ipv6(): Wrong number of arguments given #{arguments.size} for 1") end - unless arguments[0].is_a?(String) or arguments[0].is_a?(Array) then + unless arguments[0].is_a?(String) || arguments[0].is_a?(Array) raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument type given #{arguments[0].class} expected String or Array") end @@ -32,7 +36,7 @@ Takes an array of ip addresses and encloses the ipv6 addresses with square brack rescue *rescuable_exceptions raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument given #{val} is not an ip address.") end - val = "[#{ip.to_s}]" if ip.ipv6? + val = "[#{ip}]" if ip.ipv6? end result << val end