Sha256: d203806e0f13aa6507f877b2eb11be5b8ad7f8c585c4e4f17110ee290736df2a

Contents?: true

Size: 523 Bytes

Versions: 17

Compression:

Stored size: 523 Bytes

Contents

# frozen_string_literal: true

module Uffizzi
  module ProjectHelper
    SLUG_ENDING_LENGTH = 6
    class << self
      def generate_slug(name)
        formatted_name = name.downcase.gsub(/ /, '-').gsub(/[^\w-]+/, '')
        slug_ending = generate_random_string(SLUG_ENDING_LENGTH)

        "#{formatted_name}-#{slug_ending}"
      end

      private

      def generate_random_string(length)
        hexatridecimal_base = 36
        rand(hexatridecimal_base**length).to_s(hexatridecimal_base)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
uffizzi-cli-1.0.5 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-1.0.4 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-1.0.3 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-1.0.2 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-1.0.1 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-1.0.0 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.14.0 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.12.0 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.11.5 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.11.4 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.11.3 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.11.2 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.11.1 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.11.0 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.10.1 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.10.0 lib/uffizzi/helpers/project_helper.rb
uffizzi-cli-0.9.0 lib/uffizzi/helpers/project_helper.rb