Sha256: f392044cda3485d0b64f7855368e0e1cf1943c4e093ebfb97b0c9ca45a5988aa
Contents?: true
Size: 513 Bytes
Versions: 2
Compression:
Stored size: 513 Bytes
Contents
require 'securerandom' module Pact module Generator # RandomHexadecimal provides the random hexadecimal generator which will generate a hexadecimal class RandomHexadecimal def can_generate?(hash) hash.key?('type') && hash['type'] == 'RandomHexadecimal' end def call(hash, _params = nil, _example_value = nil) digits = hash['digits'] || 8 bytes = (digits / 2).ceil string = SecureRandom.hex(bytes) string[0, digits] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pact-support-1.21.1 | lib/pact/generator/random_hexadecimal.rb |
pact-support-1.21.0 | lib/pact/generator/random_hexadecimal.rb |