Sha256: 470909383e20e6713add2d09519271b835481b40fe868eb0af3fab5379b5a39e
Contents?: true
Size: 766 Bytes
Versions: 7
Compression:
Stored size: 766 Bytes
Contents
# frozen_string_literal: true require_relative 'character_set' module RakeSecrets module Types class Alphanumeric LOWERCASE_CHARACTERS = ('a'..'z').to_a UPPERCASE_CHARACTERS = ('A'..'Z').to_a NUMBER_CHARACTERS = ('0'..'9').to_a def initialize(opts = {}) @delegate = CharacterSet.new( character_set(opts[:case]), length: opts[:length] || 32 ) end def generate @delegate.generate end private def character_set(case_type) characters = NUMBER_CHARACTERS characters += UPPERCASE_CHARACTERS if %i[upper both].include?(case_type) characters += LOWERCASE_CHARACTERS unless case_type == :upper characters end end end end
Version data entries
7 entries across 7 versions & 1 rubygems