Sha256: 804e5ad2a941ea48c76568f3e527ec1a1f9a21c5a1876c972384f613ea8a26f8

Contents?: true

Size: 791 Bytes

Versions: 7

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class DebianVersion < BaseResolver
      # :major
      # :minor
      # :full

      @semaphore = Mutex.new
      @fact_list ||= {}

      class << self
        private

        def post_resolve(fact_name)
          @fact_list.fetch(fact_name) { read_debian_version(fact_name) }
        end

        def read_debian_version(fact_name)
          output, _status = Open3.capture2('cat /etc/debian_version')
          full_version = output.delete("\n")
          versions = full_version.split('.')

          @fact_list[:full] = full_version
          @fact_list[:major] = versions[0]
          @fact_list[:minor] = versions[1].gsub(/^0([1-9])/, '\1')

          @fact_list[fact_name]
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facter-4.0.13 lib/resolvers/debian_version_resolver.rb
facter-4.0.12 lib/resolvers/debian_version_resolver.rb
facter-4.0.11 lib/resolvers/debian_version_resolver.rb
facter-4.0.10.pre lib/resolvers/debian_version_resolver.rb
facter-4.0.9.pre lib/resolvers/debian_version_resolver.rb
facter-4.0.8.pre lib/resolvers/debian_version_resolver.rb
facter-4.0.7.pre lib/resolvers/debian_version_resolver.rb