Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / is_mac_address.rb
index 1b3088a..ef1fc20 100644 (file)
@@ -1,26 +1,28 @@
 #
 # 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
+    @summary
+      **Deprecated:** Returns true if the string passed to this function is a valid mac address.
 
-    if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
-    end
+    @return [Boolean]
+      Returns `true` or `false`
 
-    mac = arguments[0]
+    > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
+    [`validate_legacy`](#validate_legacy).
+    DOC
+             ) do |arguments|
 
-    if /^[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}$/.match(mac) then
-      return true
-    else
-      return false
+    if arguments.size != 1
+      raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
+    mac = arguments[0]
+
+    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