Sha256: db66d57c6e6b0911fd84320065f946908e570ad26c6c9de8babdf9d5800d2001

Contents?: true

Size: 1.31 KB

Versions: 38

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module Facter
  class WindowsReleaseFinder
    class << self
      def find_release(input)
        version = input[:version]
        return unless version

        consumerrel = input[:consumerrel]
        description = input[:description]
        kernel_version = input[:kernel_version]

        if version =~ /10.0/
          check_version_10(consumerrel, kernel_version)
        else
          check_version_6(version, consumerrel) || check_version_5(version, consumerrel, description) || version
        end
      end

      private

      def check_version_10(consumerrel, kernel_version)
        build_number = kernel_version[/([^.]*)$/].to_i
        if consumerrel
          '10'
        elsif build_number >= 17_623
          '2019'
        else
          '2016'
        end
      end

      def check_version_6(version, consumerrel)
        hash = {}
        hash['6.3'] = consumerrel ? '8.1' : '2012 R2'
        hash['6.2'] = consumerrel ? '8' : '2012'
        hash['6.1'] = consumerrel ? '7' : '2008 R2'
        hash['6.0'] = consumerrel ? 'Vista' : '2008'
        hash[version]
      end

      def check_version_5(version, consumerrel, description)
        return unless version =~ /5.2/
        return 'XP' if consumerrel

        description == 'R2' ? '2003 R2' : '2003'
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
facter-4.0.46 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.44 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.43 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.42 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.41 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.40 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.39 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.38 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.37 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.36 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.35 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.34 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.33 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.32 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.31 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.30 lib/facter/facts_utils/windows_release_finder.rb
facter-4.0.29 lib/facts_utils/windows_release_finder.rb
facter-4.0.28 lib/facts_utils/windows_release_finder.rb
facter-4.0.26 lib/facts_utils/windows_release_finder.rb
facter-4.0.25 lib/facts_utils/windows_release_finder.rb