diff --git a/lib/foreman.rb b/lib/foreman.rb index 9c44522e644..4f1c9f89ec2 100644 --- a/lib/foreman.rb +++ b/lib/foreman.rb @@ -2,14 +2,14 @@ module Foreman # generate a UUID def self.uuid - SecureRandom.uuid.to_s + SecureRandom.uuid end UUID_REGEXP = Regexp.new("^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-" + - "([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})$") + "([0-9a-f]{4})-([0-9a-f]{12})$") # does this look like a UUID? def self.is_uuid?(str) - !!(str =~ UUID_REGEXP) + str.is_a?(String) && str.length == 36 && str.match?(UUID_REGEXP) end def self.in_rake?(*rake_tasks)