Class: Fastlane::Wpmreleasetoolkit::Versioning::AbstractVersionCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb

Overview

The ‘AbstractVersionCalculator` class is responsible for performing version calculations and transformations. It can be used as a base class for version calculations that use different versioning schemes. It contains calculation and transformation methods that are shared by all platforms. It has the abstract suffix because it should not be instantiated directly.

Instance Method Summary collapse

Instance Method Details

#next_build_number(version:) ⇒ AppVersion

This method increments the build number component.

Parameters:

  • version (AppVersion)

    The version to calculate the next build number for.

Returns:

  • (AppVersion)

    The next version with an incremented build number.



62
63
64
65
66
67
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb', line 62

def next_build_number(version:)
  new_version = version.dup
  new_version.build_number += 1

  new_version
end

#next_major_version(version:) ⇒ AppVersion

This method increments the major version component and resets minor, patch, and build number components to zero.

Parameters:

  • version (AppVersion)

    The version to calculate the next major version for.

Returns:

  • (AppVersion)

    The next major version.



16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb', line 16

def next_major_version(version:)
  new_version = version.dup
  new_version.major += 1
  new_version.minor = 0
  new_version.patch = 0
  new_version.build_number = 0

  new_version
end

#next_minor_version(version:) ⇒ AppVersion

This method increments the minor version component and resets patch and build number components to zero.

Parameters:

  • version (AppVersion)

    The version to calculate the next minor version for.

Returns:

  • (AppVersion)

    The next minor version.



33
34
35
36
37
38
39
40
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb', line 33

def next_minor_version(version:)
  new_version = version.dup
  new_version.minor += 1
  new_version.patch = 0
  new_version.build_number = 0

  new_version
end

#next_patch_version(version:) ⇒ AppVersion

This method increments the patch version component and resets the build number component to zero.

Parameters:

  • version (AppVersion)

    The version to calculate the next patch version for.

Returns:

  • (AppVersion)

    The next patch version.



48
49
50
51
52
53
54
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb', line 48

def next_patch_version(version:)
  new_version = version.dup
  new_version.patch += 1
  new_version.build_number = 0

  new_version
end

#previous_patch_version(version:) ⇒ AppVersion

Calculate the previous patch version by decrementing the patch version if it’s not zero.

Parameters:

  • version (AppVersion)

    The version to calculate the previous patch version for.

Returns:

  • (AppVersion)

    The previous patch version.



75
76
77
78
79
80
81
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb', line 75

def previous_patch_version(version:)
  new_version = version.dup
  new_version.patch -= 1 unless version.patch.zero?
  new_version.build_number = 0

  new_version
end