Sha256: a6c0d4f28707d315d4efcf16ef66f9169ad6e2b1fdade83c8ee2af2922630704

Contents?: true

Size: 1.21 KB

Versions: 19

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require 'win32/registry'

module Facter
  module Resolvers
    class ProductRelease < BaseResolver
      init_resolver

      class << self
        private

        def post_resolve(fact_name, _options)
          @fact_list.fetch(fact_name) { read_fact_from_registry(fact_name) }
        end

        def read_fact_from_registry(fact_name)
          reg = ::Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion')
          build_fact_list(reg)
          reg.close

          @fact_list[fact_name]
        end

        def build_fact_list(reg)
          reg.each do |name, _value|
            case name
            when 'EditionID'
              @fact_list[:edition_id] = reg[name]
            when 'InstallationType'
              @fact_list[:installation_type] = reg[name]
            when 'ProductName'
              @fact_list[:product_name] = reg[name]
            when 'DisplayVersion'
              @fact_list[:release_id] = reg[name]
              @fact_list[:display_version] = reg[name]
            when 'ReleaseId'
              @fact_list[:release_id] = reg[name] unless @fact_list[:release_id]
            end
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
facter-4.5.2 lib/facter/resolvers/windows/product_release.rb
facter-4.5.1 lib/facter/resolvers/windows/product_release.rb
facter-4.5.0 lib/facter/resolvers/windows/product_release.rb
facter-4.4.3 lib/facter/resolvers/windows/product_release.rb
facter-4.4.2 lib/facter/resolvers/windows/product_release.rb
facter-4.4.1 lib/facter/resolvers/windows/product_release.rb
facter-4.4.0 lib/facter/resolvers/windows/product_release.rb
facter-4.3.1 lib/facter/resolvers/windows/product_release.rb
facter-4.3.0 lib/facter/resolvers/windows/product_release.rb
facter-4.2.14 lib/facter/resolvers/windows/product_release.rb
facter-4.2.13 lib/facter/resolvers/windows/product_release.rb
facter-4.2.12 lib/facter/resolvers/windows/product_release.rb
facter-4.2.11 lib/facter/resolvers/windows/product_release.rb
facter-4.2.10 lib/facter/resolvers/windows/product_release.rb
facter-4.2.9 lib/facter/resolvers/windows/product_release.rb
facter-4.2.8 lib/facter/resolvers/windows/product_release.rb
facter-4.2.7 lib/facter/resolvers/windows/product_release.rb
facter-4.2.6 lib/facter/resolvers/windows/product_release.rb
facter-4.2.5 lib/facter/resolvers/windows/product_release.rb