Sha256: a1d2cfb8745c87cd9e7a120bd721fc5a78f1b55738a5b4d6e39fe2e02e6a975d

Contents?: true

Size: 748 Bytes

Versions: 311

Compression:

Stored size: 748 Bytes

Contents

require '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

311 entries across 311 versions & 2 rubygems

Version Path
puppet-5.5.21 lib/puppet/functions/versioncmp.rb
puppet-5.5.21-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-5.5.21-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-5.5.21-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-6.16.0 lib/puppet/functions/versioncmp.rb
puppet-6.16.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.16.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.16.0-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-6.15.0 lib/puppet/functions/versioncmp.rb
puppet-6.15.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.15.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.15.0-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-5.5.20 lib/puppet/functions/versioncmp.rb
puppet-5.5.20-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-5.5.20-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-5.5.20-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-5.5.19 lib/puppet/functions/versioncmp.rb
puppet-5.5.19-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-5.5.19-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-5.5.19-universal-darwin lib/puppet/functions/versioncmp.rb