X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fis_mac_address.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fis_mac_address.rb;h=597c928f4a162f4f44effb4f7365ce6b34006650;hb=131e09855e065be940e104d9ab0f18940cc76257;hp=5993ed234b74f0a04df9474010df837c1395e1d2;hpb=407d322498f4fde815abf381007fbecfe5c10b2b;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb index 5993ed234..597c928f4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb @@ -1,25 +1,21 @@ # # is_mac_address.rb # - module Puppet::Parser::Functions - newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS -Returns true if the string passed to this function is a valid mac address. - EOS - ) do |arguments| + newfunction(:is_mac_address, :type => :rvalue, :doc => <<-DOC + Returns true if the string passed to this function is a valid mac address. + DOC + ) do |arguments| - if (arguments.size != 1) then + if arguments.size != 1 raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments given #{arguments.size} for 1") end mac = arguments[0] - if /^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){5}$/i.match(mac) then - return true - else - return false - end - + return true if %r{^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){5}$}i =~ mac + return true if %r{^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){19}$}i =~ mac + return false end end