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-6.25.1 lib/puppet/functions/versioncmp.rb
puppet-6.25.1-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.25.1-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.25.1-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-6.25.0 lib/puppet/functions/versioncmp.rb
puppet-6.25.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.25.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.25.0-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-6.24.0 lib/puppet/functions/versioncmp.rb
puppet-6.24.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.24.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.24.0-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-6.23.0 lib/puppet/functions/versioncmp.rb
puppet-6.23.0-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.23.0-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.23.0-universal-darwin lib/puppet/functions/versioncmp.rb
puppet-6.22.1 lib/puppet/functions/versioncmp.rb
puppet-6.22.1-x86-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.22.1-x64-mingw32 lib/puppet/functions/versioncmp.rb
puppet-6.22.1-universal-darwin lib/puppet/functions/versioncmp.rb