Sha256: b513c197df4260850665db514bd2565ef2d144fc60a675531e10ecff4e455546

Contents?: true

Size: 763 Bytes

Versions: 28

Compression:

Stored size: 763 Bytes

Contents

require_relative '../../puppet/util/package'

# Compares two version numbers.
#
# Prototype:
#
#     \$result = versioncmp(a, b)
#
# Where a and b are arbitrary version strings.
#
# This function returns:
#
# * `1` if version a is greater than version b
# * `0` if the versions are equal
# * `-1` if version a is less than version b
#
# @example Using versioncmp
#
#     if versioncmp('2.6-1', '2.4.5') > 0 {
#         notice('2.6-1 is > than 2.4.5')
#     }
#
# This function uses the same version comparison algorithm used by Puppet's
# `package` type.
#
Puppet::Functions.create_function(:versioncmp) do

  dispatch :versioncmp do
    param 'String', :a
    param 'String', :b
  end

  def versioncmp(a, b)
    Puppet::Util::Package.versioncmp(a, b)
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
puppet-7.12.1 lib/puppet/functions/versioncmp.rb
puppet-7.12.1-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.12.1-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.12.1-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-7.12.0 lib/puppet/functions/versioncmp.rb
puppet-7.12.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.12.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.12.0-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-7.11.0 lib/puppet/functions/versioncmp.rb
puppet-7.11.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.11.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.11.0-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-7.10.0 lib/puppet/functions/versioncmp.rb
puppet-7.10.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.10.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.10.0-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-7.9.0 lib/puppet/functions/versioncmp.rb
puppet-7.9.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.9.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-7.9.0-universal-darwin lib/puppet/functions/versioncmp.rb