Sha256: 9c753d6ecf1bdf462049ece1066e3a5204fed124720f9323baffcd4eac211646

Contents?: true

Size: 1.27 KB

Versions: 21

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Facts
  module Macosx
    module Os
      module Macosx
        class Version
          FACT_NAME = 'os.macosx.version'
          ALIASES = %w[macosx_productversion macosx_productversion_major macosx_productversion_minor
                       macosx_productversion_patch].freeze

          def call_the_resolver
            fact_value = Facter::Resolvers::SwVers.resolve(:productversion)
            ver = version_hash(fact_value)

            [Facter::ResolvedFact.new(FACT_NAME, ver),
             Facter::ResolvedFact.new(ALIASES[0], fact_value, :legacy),
             Facter::ResolvedFact.new(ALIASES[1], ver['major'], :legacy),
             Facter::ResolvedFact.new(ALIASES[2], ver['minor'], :legacy),
             Facter::ResolvedFact.new(ALIASES[3], ver['patch'], :legacy)]
          end

          def version_hash(fact_value)
            versions = fact_value.split('.')
            if versions[0] == '10'
              { 'full' => fact_value, 'major' => "#{versions[0]}.#{versions[1]}", 'minor' => versions[-1] }
            else
              { 'full' => fact_value, 'major' => versions[0], 'minor' => versions.fetch(1, '0'),
                'patch' => versions.fetch(2, '0') }
            end
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
facter-4.4.3 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.4.2 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.4.1 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.4.0 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.3.1 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.3.0 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.14 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.13 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.12 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.11 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.10 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.9 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.8 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.7 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.6 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.5 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.4 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.3 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.2 lib/facter/facts/macosx/os/macosx/version.rb
facter-4.2.1 lib/facter/facts/macosx/os/macosx/version.rb