Sha256: d68f5cbb9b056e10f19a960f48afdc3cd2676784668eaf8a3a470fcf0f362698
Contents?: true
Size: 878 Bytes
Versions: 31
Compression:
Stored size: 878 Bytes
Contents
# frozen_string_literal: true require 'faker' module Uffizzi module ProjectHelper SLUG_ENDING_LENGTH = 6 class << self def generate_default_params name = generate_name { name: name, description: default_description, slug: generate_slug(name), } end 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 def default_description 'Project generated by Uffizzi' end def generate_name Faker::Lorem.word end end end end
Version data entries
31 entries across 31 versions & 1 rubygems