Sha256: 98ca9c4b4915da8ab68b329c2d2e9ad097fb47093aeecff8db7b93ce15dbb7ce
Contents?: true
Size: 888 Bytes
Versions: 22
Compression:
Stored size: 888 Bytes
Contents
# frozen_string_literal: true module Dsu module Support module TransformProjectName TRANSFORM_PROJECT_NAME_REGEX = %r{[^/\w\s]|_} TRANSFORM_PROJECT_NAME_SEPARATOR = '-' module_function def transform_project_name(project_name, options: {}) normalized_name = project_name .gsub(TRANSFORM_PROJECT_NAME_REGEX, ' ') # Replace non-word characters and underscores with space .strip # Remove leading and trailing spaces .squeeze(' ') # Convert consecutive spaces to a single space .tr(' ', TRANSFORM_PROJECT_NAME_SEPARATOR) # Replace spaces with hyphens .squeeze(TRANSFORM_PROJECT_NAME_SEPARATOR) # Ensure no consecutive hyphens normalized_name.downcase! if options[:downcase] normalized_name end end end end
Version data entries
22 entries across 22 versions & 1 rubygems