45: def self.sw_vers
46: ver = Hash.new
47: [ "productName", "productVersion", "buildVersion" ].each do |option|
48: ver["macosx_#{option}"] = Facter::Util::Resolution.exec("/usr/bin/sw_vers -#{option}").strip
49: end
50: productversion = ver["macosx_productVersion"]
51: if not productversion.nil?
52: versions = productversion.scan(/(\d+)\.(\d+)\.*(\d*)/)[0]
53: ver["macosx_productversion_major"] = "#{versions[0]}.#{versions[1]}"
54: if versions[2].empty?
55: versions[2] = "0"
56: end
57: ver["macosx_productversion_minor"] = versions[2]
58: end
59: ver
60: end