Class: Bumpversion::BumpString
- Inherits:
-
Object
- Object
- Bumpversion::BumpString
- Defined in:
- lib/bumpversion/bump_string.rb
Instance Method Summary collapse
- #bump ⇒ Object
- #dictionary ⇒ Object
-
#initialize(options) ⇒ BumpString
constructor
A new instance of BumpString.
- #key_part ⇒ Object
- #matched ⇒ Object
- #pattern ⇒ Object
- #update_version(matched_version) ⇒ Object
Constructor Details
#initialize(options) ⇒ BumpString
Returns a new instance of BumpString.
3 4 5 |
# File 'lib/bumpversion/bump_string.rb', line 3 def initialize() = end |
Instance Method Details
#bump ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/bumpversion/bump_string.rb', line 40 def bump unless [:new_version] matched_version = update_version(matched) new_version_hash = matched_version.map { |_key, value| value.to_s } [:new_version] = new_version_hash.join('.') end end |
#dictionary ⇒ Object
7 8 9 |
# File 'lib/bumpversion/bump_string.rb', line 7 def dictionary { major: 1, minor: 2, patch: 3 } end |
#key_part ⇒ Object
11 12 13 |
# File 'lib/bumpversion/bump_string.rb', line 11 def key_part [:part].to_sym end |
#matched ⇒ Object
19 20 21 22 23 24 |
# File 'lib/bumpversion/bump_string.rb', line 19 def matched match = pattern.match([:current_version]) matched = {} dictionary.each { |part, number| matched[part] = match[number].to_i } matched end |
#pattern ⇒ Object
15 16 17 |
# File 'lib/bumpversion/bump_string.rb', line 15 def pattern /([0-9]+)\.([0-9]+)\.([0-9]+)/ end |
#update_version(matched_version) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bumpversion/bump_string.rb', line 26 def update_version(matched_version) bumped = false matched_version.each do | part, number | matched_version[part] = 0 if bumped if part == key_part matched_version[part] += 1 bumped = true end end matched_version end |