Module Facter::Util::Macosx
In: lib/facter/util/macosx.rb

macosx.rb Support methods for Apple OSX facts

Copyright (C) 2007 Jeff McCune Author: Jeff McCune <jeff.mccune@northstarlabs.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation (version 2 of the License) This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA

Methods

Public Class methods

[Source]

    # File lib/facter/util/macosx.rb, line 48
48:     def self.hardware_overview
49:         profiler_data("SPHardwareDataType")
50:     end

[Source]

    # File lib/facter/util/macosx.rb, line 31
31:     def self.intern_xml(xml)
32:         return nil unless xml
33:         Plist::parse_xml(xml)
34:     end

[Source]

    # File lib/facter/util/macosx.rb, line 52
52:     def self.os_overview
53:         profiler_data("SPSoftwareDataType")
54:     end

Return an xml result, modified as we need it.

[Source]

    # File lib/facter/util/macosx.rb, line 37
37:     def self.profiler_data(data_field)
38:         begin
39:             return nil unless parsed_xml = intern_xml(profiler_xml(data_field))
40:             return nil unless data = parsed_xml[0]['_items'][0]
41:             data.delete '_name'
42:             data
43:         rescue
44:             return nil
45:         end
46:     end

JJM I‘d really like to dynamically generate these methods by looking at the _name key of the _items dict for each _dataType

[Source]

    # File lib/facter/util/macosx.rb, line 27
27:     def self.profiler_xml(data_field)
28:         Facter::Util::Resolution.exec("/usr/sbin/system_profiler -xml #{data_field}")
29:     end

[Source]

    # File lib/facter/util/macosx.rb, line 56
56:     def self.sw_vers
57:         ver = Hash.new
58:         [ "productName", "productVersion", "buildVersion" ].each do |option|
59:             ver["macosx_#{option}"] = %x{sw_vers -#{option}}.strip
60:         end
61:         ver
62:     end

[Validate]