module Atlassian::Util::TextUtil

Public Instance Methods

convert_branch_name_to_sentence(branch_name) click to toggle source
# File lib/atlassian/util/text_util.rb, line 5
def convert_branch_name_to_sentence(branch_name)
  return '' if branch_name.nil?

  branch_name = branch_name.to_s
  return '' if branch_name.empty?

  issue_key_regex = /([A-Z]{1,10}-\d+)/
  branch_components = branch_name.split(issue_key_regex);

  parts = branch_components.each_with_index.map { |value, index|
    (index % 2 === 0) ? value.gsub(/[\-_]/, ' ') : value
  }

  to_sentence_case(parts.join(''))
end
to_sentence_case(str) click to toggle source
# File lib/atlassian/util/text_util.rb, line 21
def to_sentence_case(str)
  return '' if str.nil?

  str = str.to_s
  return '' if str.empty?

  str.slice(0, 1).upcase + str.slice(1, str.length)
end