Sha256: 9c329851fabdb6732689d5f7f7390249c77f10639e060d49e4f8f98a30507cb4

Contents?: true

Size: 767 Bytes

Versions: 14

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class SwVers < BaseResolver
      # :productname
      # :productversion
      # :buildversion
      #
      @semaphore = Mutex.new
      @fact_list ||= {}

      class << self
        private

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

        def software_version_system_call(fact_name)
          output, _status = Open3.capture2('sw_vers')
          release_info = output.delete("\t").split("\n").map { |e| e.split(':') }
          result = Hash[*release_info.flatten]
          result.each { |k, v| @fact_list[k.downcase.to_sym] = v }
          @fact_list[fact_name]
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
facter-4.0.20 lib/resolvers/sw_vers_resolver.rb
facter-4.0.19 lib/resolvers/sw_vers_resolver.rb
facter-4.0.18 lib/resolvers/sw_vers_resolver.rb
facter-4.0.17 lib/resolvers/sw_vers_resolver.rb
facter-4.0.16 lib/resolvers/sw_vers_resolver.rb
facter-4.0.15 lib/resolvers/sw_vers_resolver.rb
facter-4.0.14 lib/resolvers/sw_vers_resolver.rb
facter-4.0.13 lib/resolvers/sw_vers_resolver.rb
facter-4.0.12 lib/resolvers/sw_vers_resolver.rb
facter-4.0.11 lib/resolvers/sw_vers_resolver.rb
facter-4.0.10.pre lib/resolvers/sw_vers_resolver.rb
facter-4.0.9.pre lib/resolvers/sw_vers_resolver.rb
facter-4.0.8.pre lib/resolvers/sw_vers_resolver.rb
facter-4.0.7.pre lib/resolvers/sw_vers_resolver.rb