Class: Cfruby::OS::OSXOS

Inherits:
OS
  • Object
show all
Defined in:
lib/libcfruby/osmodules/osx.rb

Instance Method Summary collapse

Methods inherited from OS

#get_process_manager, #get_scheduler, #method_missing, #to_s

Constructor Details

#initializeOSXOS

Returns a new instance of OSXOS.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/libcfruby/osmodules/osx.rb', line 10

def initialize()
	@keys = Hash.new()

	@keys['name'] = 'FreeBSD'
	@keys['osx'] = true
	@keys['OSX'] = true
	@keys['MacOS'] = true
	@keys['darwin'] = true
	@keys['Darwin'] = true

	unameoutput = `/usr/bin/uname -v`
	@keys['version'] = unameoutput[/Darwin Kernel Version ([^ ]+):/, 1]

	@keys['hostname'] = `/bin/hostname`.strip
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cfruby::OS::OS

Instance Method Details

#[](key) ⇒ Object

an alternative to calling lookup



58
59
60
# File 'lib/libcfruby/osmodules/osx.rb', line 58

def [](key)
	return(lookup(key))
end

#get_package_managerObject

returns an object implementing the PackageManager interface as appropriate for the default package management system for a given OS



35
36
37
38
39
40
41
# File 'lib/libcfruby/osmodules/osx.rb', line 35

def get_package_manager()
	if(File.executable?('/sw/bin/fink'))
		return(Packages::FinkPackageManager.new())
	end

	return(nil)
end

#get_user_managerObject

Returns a UserManager object specific to OS X



28
29
30
# File 'lib/libcfruby/osmodules/osx.rb', line 28

def get_user_manager()
	return(Users::OSXUserManager.new())
end

#lookup(key) ⇒ Object

returns the value of the given key for this OS. At a minimum an OS should provide the following:

name

returns the name of the OS

version

the version of the OS

osname

e.g. freebsd, linux, windows, etc - these should return true and be case insensitive to allow

lookups of the form lookup(‘Windows’) In addition to the above name and version should be implemented as getter methods for convenience



52
53
54
# File 'lib/libcfruby/osmodules/osx.rb', line 52

def lookup(key)
	return(@keys[key])
end