Sha256: 41b02c0953797ebf520ebe85f0a217ad66222520332de2de9ced2b3326d7776d
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Branch module Name module Normalizable NON_WORD_CHARS_REGEX = /[^\w]/ def normalize_branch_name(ticket_description, ticket) normalized_ticket_description = normalize_ticket_description ticket_description return normalized_ticket_description if ticket.blank? normalized_ticket = normalize_ticket ticket "#{normalized_ticket}#{options[:separator]}#{normalized_ticket_description}" end private def normalize_ticket_description(ticket_description) normalize_token ticket_description end def normalize_ticket(ticket) ticket.split(NON_WORD_CHARS_REGEX).filter_map do |token| normalize_token(token) end.join(options[:separator]) end def normalize_token(token) token = token.strip .squeeze(' ') .split.join(options[:separator]) token = token.gsub(NON_WORD_CHARS_REGEX, '') token = token.squeeze(options[:separator]) token = token.downcase if options[:downcase] token end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
branch-name-2.0.0.pre.beta | lib/branch/name/normalizable.rb |