Module: Branch::Name::Normalizable
- Included in:
- BranchNameService, Projectable
- Defined in:
- lib/branch/name/normalizable.rb
Constant Summary collapse
- BRANCH_NAME_REGEX =
The regex used to split ticket and ticket description tokens to formulate a source control branch name.
%r{[^/\w\x20]|_}
- PROJECT_FOLDER_REGEX =
The regex used to split ticket and ticket description tokens to formulate a project folder based on the branch name formulated.
/[\W_]/
- PROJECT_FOLDER_TOKEN_SEPARATORS =
Acceptable project folder token separators. If options returns one of these acceptable values, it will be used; otherwise DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR will be used.
%w[- _].freeze
- DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR =
The default project folder token separator if options is not an acceptable project folder token separator (i.e. PROJECT_FOLDER_TOKEN_SEPARATORS).
PROJECT_FOLDER_TOKEN_SEPARATORS.first
Instance Method Summary collapse
- #normalize_branch_name(ticket_description, ticket) ⇒ Object
-
#project_folder_name_from(normalized_branch_name) ⇒ Object
Returns a project folder name from a normalized branch name.
Instance Method Details
#normalize_branch_name(ticket_description, ticket) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/branch/name/normalizable.rb', line 26 def normalize_branch_name(ticket_description, ticket) formatted_branch_name = format_string_or_default formatted_branch_name = formatted_branch_name.gsub('%t', ticket || '') formatted_branch_name = formatted_branch_name.gsub('%d', ticket_description) formatted_branch_name = formatted_branch_name.gsub('%u', Etc.getlogin) normalize_token formatted_branch_name, BRANCH_NAME_REGEX, [:separator] rescue Branch::Name::OptionError => e raise unless block_given? yield e end |
#project_folder_name_from(normalized_branch_name) ⇒ Object
Returns a project folder name from a normalized branch name. The location of the folder is not included; that is, the folder returned is not fully qualified.
41 42 43 44 45 46 47 |
# File 'lib/branch/name/normalizable.rb', line 41 def project_folder_name_from(normalized_branch_name) normalize_token normalized_branch_name, PROJECT_FOLDER_REGEX, project_folder_separator rescue Branch::Name::OptionError => e raise unless block_given? yield e end |