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 5993ed2..ef1fc20 100644 (file)
@@ -1,25 +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.
+
+    @return [Boolean]
+      Returns `true` or `false`
+
+    > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
+    [`validate_legacy`](#validate_legacy).
+    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