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.



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

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

Raises:

  • (UserError)

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



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

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



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

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