Sha256: 4c626348e01dbeb0ecddb7f5a92c0a2fef207dbb6f877ebf0233ecfa9865eb7e

Contents?: true

Size: 707 Bytes

Versions: 7

Compression:

Stored size: 707 Bytes

Contents

# frozen_string_literal: true

require_relative 'character_set'

module RakeSecrets
  module Types
    class Alphabetic
      LOWERCASE_CHARACTERS = ('a'..'z').to_a
      UPPERCASE_CHARACTERS = ('A'..'Z').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 = []
        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

Version Path
rake_secrets-0.3.0.pre.2 lib/rake_secrets/types/alphabetic.rb
rake_secrets-0.3.0.pre.1 lib/rake_secrets/types/alphabetic.rb
rake_secrets-0.2.0 lib/rake_secrets/types/alphabetic.rb
rake_secrets-0.1.0.pre.8 lib/rake_secrets/types/alphabetic.rb
rake_secrets-0.1.0.pre.7 lib/rake_secrets/types/alphabetic.rb
rake_secrets-0.1.0.pre.6 lib/rake_secrets/types/alphabetic.rb
rake_secrets-0.1.0.pre.5 lib/rake_secrets/types/alphabetic.rb