Sha256: 55c92feddaa70dd846fdbf204f6ece503bb6214efb7486805957363c7406d5ff

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 Bytes

Contents

# frozen_string_literal: true

module Facts
  module Debian
    module Os
      module Distro
        class Release
          FACT_NAME = 'os.distro.release'

          def call_the_resolver
            fact_value = determine_release_for_os

            return Facter::ResolvedFact.new(FACT_NAME, nil) unless fact_value

            versions = fact_value.split('.')
            release = {}
            release['full'] = fact_value
            release['major'] = versions[0]
            release['minor'] = versions[1].gsub(/^0([1-9])/, '\1') if versions[1]
            Facter::ResolvedFact.new(FACT_NAME, release)
          end

          private

          def determine_release_for_os
            os_name = Facter::Resolvers::OsRelease.resolve(:name)

            if os_name =~ /Debian|Raspbian/
              Facter::Resolvers::DebianVersion.resolve(:version)
            else
              Facter::Resolvers::OsRelease.resolve(:version_id)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facter-4.0.19 lib/facts/debian/os/distro/release.rb