Class: Renegade::BranchName
- Inherits:
-
Object
- Object
- Renegade::BranchName
- Defined in:
- lib/renegade/branch_name.rb
Overview
Verify branch name
Constant Summary collapse
- REGEX_STORY_BRANCH =
/^(?:story)-(\d{4,6})-?(.*)?$/
- REGEX_BUG_BRANCH =
/^(?:bug)-(\d{4,6})-?(.*)?$/
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#warning ⇒ Object
readonly
Returns the value of attribute warning.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
Instance Method Summary collapse
- #check_branch_name(branch_name) ⇒ Object
-
#initialize ⇒ BranchName
constructor
A new instance of BranchName.
- #run(branch_name) ⇒ Object
Constructor Details
#initialize ⇒ BranchName
Returns a new instance of BranchName.
12 13 14 15 16 17 18 |
# File 'lib/renegade/branch_name.rb', line 12 def initialize # Instance variables @label = 'Branch Name' @warnings = [] @errors = [] @warning = 'Branches must start with bug-##### or story-#####.' end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/renegade/branch_name.rb', line 7 def errors @errors end |
#warning ⇒ Object (readonly)
Returns the value of attribute warning.
7 8 9 |
# File 'lib/renegade/branch_name.rb', line 7 def warning @warning end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
7 8 9 |
# File 'lib/renegade/branch_name.rb', line 7 def warnings @warnings end |
Class Method Details
.extract_id(branch_name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/renegade/branch_name.rb', line 26 def self.extract_id(branch_name) data = {} if REGEX_STORY_BRANCH.match(branch_name) data['type'] = 'story' data['id'] = REGEX_STORY_BRANCH.match(branch_name)[1] elsif REGEX_BUG_BRANCH.match(branch_name) data['type'] = 'bug' data['id'] = REGEX_BUG_BRANCH.match(branch_name)[1] end data end |
Instance Method Details
#check_branch_name(branch_name) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/renegade/branch_name.rb', line 39 def check_branch_name(branch_name) if REGEX_STORY_BRANCH.match(branch_name) || REGEX_BUG_BRANCH.match(branch_name) || branch_name == 'master' # placeholder return true else @warnings.push(@warning) @warnings.push('You may continue to develop in this branch, but you'\ ' will not be allowed to merge unless you rename it.') return false end end |