Module Facter::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

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 26
26:   def self.hardware_overview
27:     # JJM Perhaps we should cache the XML data in a "class" level object.
28:     top_level_plist = Plist::parse_xml %x{/usr/sbin/system_profiler -xml SPHardwareDataType}
29:     system_hardware = top_level_plist[0]['_items'][0]
30:     system_hardware.delete '_name'
31:     system_hardware
32:   end

SPSoftwareDataType

[Source]

    # File lib/facter/util/macosx.rb, line 35
35:   def self.os_overview
36:     top_level_plist = Plist::parse_xml %x{/usr/sbin/system_profiler -xml SPSoftwareDataType}
37:     os_stuff = top_level_plist[0]['_items'][0]
38:     os_stuff.delete '_name'
39:     os_stuff
40:   end

[Source]

    # File lib/facter/util/macosx.rb, line 42
42:   def self.sw_vers
43:     ver = Hash.new
44:     [ "productName", "productVersion", "buildVersion" ].each do |option|
45:       ver["macosx_#{option}"] = %x{sw_vers -#{option}}.strip
46:     end
47:     ver
48:   end

[Validate]