Class: RungerReleaseAssistant::VersionCalculator
- Inherits:
-
Object
- Object
- RungerReleaseAssistant::VersionCalculator
- Includes:
- MemoWise
- Defined in:
- lib/runger_release_assistant/version_calculator.rb
Instance Method Summary collapse
-
#increment_for(type) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity.
-
#initialize(current_version:) ⇒ VersionCalculator
constructor
A new instance of VersionCalculator.
Constructor Details
#initialize(current_version:) ⇒ VersionCalculator
Returns a new instance of VersionCalculator.
6 7 8 |
# File 'lib/runger_release_assistant/version_calculator.rb', line 6 def initialize(current_version:) @current_version = current_version end |
Instance Method Details
#increment_for(type) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/runger_release_assistant/version_calculator.rb', line 11 def increment_for(type) new_parts = case type when 'major' if modifier.present? && (minor == 0) && (patch == 0) # e.g. going from `2.0.0.alpha` to `2.0.0` [major, minor, patch] else # e.g. going from `2.3.4` to `3.0.0` [major + 1, 0, 0] end when 'minor' if modifier.present? && (patch == 0) # e.g. going from `0.4.0.alpha` to `0.4.0` [major, minor, patch] else # e.g. going from `0.3.3` to `0.4.0` [major, minor + 1, 0] end when 'patch' if modifier.present? # e.g. going from `0.3.3.alpha` to `0.3.3` [major, minor, patch] else # e.g. going from `0.3.3` to `0.3.4` [major, minor, patch + 1] end end new_parts.map(&:to_s).join('.') end |