cartodb-4.42/lib/carto/uuidhelper.rb

18 lines
345 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
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