X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fenclose_ipv6.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fenclose_ipv6.rb;h=f412b018ba60ca20a6522a32491cf9ead4c6dd77;hb=131e09855e065be940e104d9ab0f18940cc76257;hp=1f8a454934f7ed5a117e36ea14ed77c3c730d095;hpb=407d322498f4fde815abf381007fbecfe5c10b2b;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..f412b018b 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,23 @@ # # 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 + Takes an array of ip addresses and 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 +31,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