Module: Fastlane::Helper::Ios::VersionHelper

Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb

Overview

A module containing helper methods to manipulate/extract/bump iOS version strings in xcconfig files

Constant Summary collapse

MAJOR_NUMBER =

The index for the major version number part

0
MINOR_NUMBER =

The index for the minor version number part

1
HOTFIX_NUMBER =

The index for the hotfix version number part

2
BUILD_NUMBER =

The index for the build version number part

3

Class Method Summary collapse

Class Method Details

.calc_next_release_version(version) ⇒ String

Compute the name of the next release version.

Parameters:

  • version (String)

    The current version that we want to increment

Returns:

  • (String)

    The predicted next version, in the form of “X.Y”. Corresponds to incrementing the minor part, except if it reached 10 (in that case we go to the next major version, as decided in our versioning conventions)



26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb', line 26

def self.calc_next_release_version(version)
  vp = get_version_parts(version)
  vp[MINOR_NUMBER] += 1
  if vp[MINOR_NUMBER] == 10
    vp[MAJOR_NUMBER] += 1
    vp[MINOR_NUMBER] = 0
  end

  "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}"
end

.get_version_parts(version) ⇒ Array<String>

Note:

If the original version string contains less than 4 parts, the returned array is filled with zeros at the end to always contain 4 items.

Split a version string into its 4 parts, ensuring its parts count is valid

Parameters:

  • version (String)

    The version string to split into parts

Returns:

  • (Array<String>)

    An array of exactly 4 elements, containing each part of the version string.

Raises:

  • (UserError)

    Interrupts the lane if the provided version contains more than 4 parts



46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb', line 46

def self.get_version_parts(version)
  parts = version.split('.')
  parts = parts.fill('0', parts.length...4).map(&:to_i)
  UI.user_error!("Bad version string: #{version}") if parts.length > 4

  parts
end

.is_int?(string) ⇒ Bool

Check if a string is an integer

Parameters:

  • string (String)

    The string to test

Returns:

  • (Bool)

    true if the string is representing an integer value, false if not



60
61
62
63
64
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb', line 60

def self.is_int?(string)
  true if Integer(string)
rescue StandardError
  false
end