You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
345 B

require 'securerandom'
module Carto
module UUIDHelper
module_function
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})$")
def uuid?(text)
!(Regexp.new(%r{\A#{UUID_REGEXP}\Z}) =~ text).nil?
end
def random_uuid
SecureRandom.uuid
end
end
end