Class: GitBumper::BuildTag
- Inherits:
-
Object
- Object
- GitBumper::BuildTag
- Defined in:
- lib/git_bumper/build_tag.rb
Overview
This object represents a git build tag. It expects the following format of tags:
PREFIX.BUILD_NUMBER
It provides some methods to parse and increment build numbers.
Constant Summary collapse
- REGEX =
/\A([a-z]+)([0-9]+)\z/i
Instance Attribute Summary collapse
-
#build ⇒ Object
Returns the value of attribute build.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Class Method Summary collapse
-
.parse(str) ⇒ BuildTag
Parses a string into a BuildTag object.
Instance Method Summary collapse
-
#increment ⇒ Object
Increments the build number.
-
#initialize(prefix, build) ⇒ BuildTag
constructor
A new instance of BuildTag.
- #to_s ⇒ String
Constructor Details
#initialize(prefix, build) ⇒ BuildTag
Returns a new instance of BuildTag.
26 27 28 29 |
# File 'lib/git_bumper/build_tag.rb', line 26 def initialize(prefix, build) @prefix = prefix @build = build end |
Instance Attribute Details
#build ⇒ Object
Returns the value of attribute build.
22 23 24 |
# File 'lib/git_bumper/build_tag.rb', line 22 def build @build end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
21 22 23 |
# File 'lib/git_bumper/build_tag.rb', line 21 def prefix @prefix end |
Class Method Details
.parse(str) ⇒ BuildTag
Parses a string into a BuildTag object.
13 14 15 16 17 18 19 |
# File 'lib/git_bumper/build_tag.rb', line 13 def self.parse(str) matches = str.scan(REGEX).flatten return false if matches.empty? new(matches[0], matches[1].to_i) end |
Instance Method Details
#increment ⇒ Object
Increments the build number.
37 38 39 |
# File 'lib/git_bumper/build_tag.rb', line 37 def increment(*) @build += 1 end |
#to_s ⇒ String
32 33 34 |
# File 'lib/git_bumper/build_tag.rb', line 32 def to_s "#{prefix}#{build}" end |