Class: Schmersion::VersionCalculator
- Inherits:
-
Object
- Object
- Schmersion::VersionCalculator
- Defined in:
- lib/schmersion/version_calculator.rb
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(current, commits, **options) ⇒ VersionCalculator
constructor
A new instance of VersionCalculator.
Constructor Details
#initialize(current, commits, **options) ⇒ VersionCalculator
Returns a new instance of VersionCalculator.
8 9 10 11 12 13 14 15 16 |
# File 'lib/schmersion/version_calculator.rb', line 8 def initialize(current, commits, **) if current.is_a?(String) current = Semantic::Version.new(current) end @current = current || Semantic::Version.new('1.0.0') @commits = commits @options = end |
Instance Method Details
#calculate ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/schmersion/version_calculator.rb', line 18 def calculate if @current.pre && pre? new_version = @current.dup elsif breaking_changes? && consider_breaking_changes_major? && @current.major.positive? new_version = @current.increment!(:major) elsif features? || breaking_changes? new_version = @current.increment!(:minor) else new_version = @current.increment!(:patch) end add_pre_to_version(new_version) if @options[:pre] new_version end |