module Marshmallow

Constants

VERSION

Public Class Methods

apps_installed() click to toggle source
# File lib/marshmallow.rb, line 24
def self.apps_installed
        apps=[]
        for x in Dir.entries("/Applications")
                if !x.start_with?(".")
                        apps.push(x)
                end
        end
        return apps
end
ard_info1() click to toggle source
# File lib/marshmallow.rb, line 201
def self.ard_info1
        plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.RemoteDesktop.plist")
        results = CFPropertyList.native_types(plist.value)
        if results.key?('Text1')
    return results['Text1']
else
    return "Error: plist does not contain key for 'Text1'"
end
end
ard_info2() click to toggle source
# File lib/marshmallow.rb, line 211
def self.ard_info2
        plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.RemoteDesktop.plist")
        results = CFPropertyList.native_types(plist.value)
        if results.key?('Text2')
    return results['Text2']
else
    return "Error: plist does not contain key for 'Text2'"
end
end
ard_info3() click to toggle source
# File lib/marshmallow.rb, line 221
def self.ard_info3
        plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.RemoteDesktop.plist")
        results = CFPropertyList.native_types(plist.value)
        if results.key?('Text3')
    return results['Text3']
else
    return "Error: plist does not contain key for 'Text3'"
end
end
ard_info4() click to toggle source
# File lib/marshmallow.rb, line 231
def self.ard_info4
        plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.RemoteDesktop.plist")
        results = CFPropertyList.native_types(plist.value)
        if results.key?('Text4')
    return results['Text4']
else
    return "Error: plist does not contain key for 'Text4'"
end
end
boot_rom() click to toggle source
# File lib/marshmallow.rb, line 91
def self.boot_rom
        boot = `system_profiler SPHardwareDataType`.split("\n")
        boot = boot[13].split(":")
        return boot[1].strip
end
boot_volume() click to toggle source
# File lib/marshmallow.rb, line 131
def self.boot_volume
        boot = `system_profiler SPSoftwareDataType`.split("\n")
        boot = boot[6].split(":")
        return boot[1].strip
end
build() click to toggle source
# File lib/marshmallow.rb, line 44
def self.build
        build = `sw_vers -buildVersion`.chomp
end
computer_name() click to toggle source
# File lib/marshmallow.rb, line 137
def self.computer_name
        name = `system_profiler SPSoftwareDataType`.split("\n")
        name = name[8].split(":")
        return name[1].strip
end
cores() click to toggle source
# File lib/marshmallow.rb, line 78
def self.cores
        cores = `system_profiler SPHardwareDataType`.split("\n")
        cores = cores[9].split(":")
        return cores[1].strip
end
domain_check() click to toggle source
# File lib/marshmallow.rb, line 261
def self.domain_check
        if `dsconfigad -show`.empty?
                puts "no Domain Settings"
        else
                domain_check=`dsconfigad -show | grep "Active Directory Domain"`.split("=")
                domain_check = domain_check[1].strip!
                return domain_check
        end
end
fastuserswitch_check() click to toggle source
# File lib/marshmallow.rb, line 281
def self.fastuserswitch_check
        plist = CFPropertyList::List.new(:file => "/Library/Preferences/.GlobalPreferences.plist")
        results = CFPropertyList.native_types(plist.value)
        if results['MultipleSessionEnabled'] == true
                return "enabled"
        else
                return "disabled"
        end
end
firewall_check() click to toggle source
# File lib/marshmallow.rb, line 271
def self.firewall_check
        plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.alf.plist")
        firewall = CFPropertyList.native_types(plist.value)
        if firewall['globalstate'] == 1
                return "on"
        else
                return "off"
        end
end
free_space() click to toggle source
# File lib/marshmallow.rb, line 117
def self.free_space
        free = `system_profiler SPStorageDataType`.split("\n")
        free = free[4].split(":")
        free = free[1].split("(")
        return free[0].strip
end
graphics() click to toggle source
# File lib/marshmallow.rb, line 111
def self.graphics
        graphics = `system_profiler SPDisplaysDataType`.split("\n")
        graphics = graphics[2].split(":")
        return graphics[0].strip
end
hd_size() click to toggle source
# File lib/marshmallow.rb, line 124
def self.hd_size
        hd = `system_profiler SPStorageDataType`.split("\n")
        hd = hd[5].split(":")
        hd = hd[1].split("(")
        return hd[0].strip
end
listoflocaladmins() click to toggle source
# File lib/marshmallow.rb, line 18
def self.listoflocaladmins
        listoflocaladmins =`dscacheutil -q group -a name admin`.split(":")
        listoflocaladmins=listoflocaladmins[4].strip.split(" ")
        return listoflocaladmins
end
loginwindow_check() click to toggle source
# File lib/marshmallow.rb, line 291
def self.loginwindow_check
        plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.loginwindow.plist")
        results = CFPropertyList.native_types(plist.value)
        if results['SHOWFULLNAME'] == true
                return "Name and Password"
        else
                return "List of users"
        end
end
memory() click to toggle source
# File lib/marshmallow.rb, line 84
def self.memory
        memory = `system_profiler SPHardwareDataType`.split("\n")
memory = memory.grep(/Memory:/).join(":").strip.split(":")
memory = memory[1].strip
return memory
end
model() click to toggle source
# File lib/marshmallow.rb, line 48
def self.model
        model = `system_profiler SPHardwareDataType`.split("\n")
        model = model[4].split(":")
        return model[1].strip
end
model_id() click to toggle source
# File lib/marshmallow.rb, line 54
def self.model_id
        model = `system_profiler SPHardwareDataType`.split("\n")
        model = model[5].split(":")
        return model[1].strip
end
options() click to toggle source
# File lib/marshmallow.rb, line 301
def self.options
        return Marshmallow.methods(false).sort
end
os_version() click to toggle source
# File lib/marshmallow.rb, line 40
def self.os_version
        os_version = `sw_vers -productVersion`.chomp
end
processor_name() click to toggle source
# File lib/marshmallow.rb, line 60
def self.processor_name
        processor = `system_profiler SPHardwareDataType`.split("\n")
        processor = processor[6].split(":")
        return processor[1].strip
end
processor_number() click to toggle source
# File lib/marshmallow.rb, line 72
def self.processor_number
        processor = `system_profiler SPHardwareDataType`.split("\n")
        processor = processor[8].split(":")
        return processor[1].strip
end
processor_speed() click to toggle source
# File lib/marshmallow.rb, line 66
def self.processor_speed
        processor = `system_profiler SPHardwareDataType`.split("\n")
        processor = processor[7].split(":")
        return processor[1].strip
end
profiles_all() click to toggle source
# File lib/marshmallow.rb, line 256
def self.profiles_all
        profiles="profiles -C"
        system(profiles)
end
profiles_installed() click to toggle source
# File lib/marshmallow.rb, line 241
def self.profiles_installed
        if `profiles -C`.chomp == "There are no configuration profiles installed in the system domain"
                puts "No profiles installed"
        else
                profiles=`profiles -C`.lines

                installed=[]
                for x in profiles
                     installed.push(x.split.last)
                end
                installed.delete("installed")
                puts installed
        end
end
serial() click to toggle source
# File lib/marshmallow.rb, line 34
def self.serial
        serial = `system_profiler SPHardwareDataType | awk '/Serial/'`.split(":")
        serial = serial[1].strip!
        return serial
end
smc() click to toggle source
# File lib/marshmallow.rb, line 97
def self.smc
        smc = `system_profiler SPHardwareDataType`.split("\n")
smc = smc.grep(/SMC/).join(":").strip.split(":")
smc = smc[1].strip
return smc
end
system_launchagents() click to toggle source
# File lib/marshmallow.rb, line 143
def self.system_launchagents
        launchagents=[]
        for x in Dir.entries("/Library/LaunchAgents")
                if !x.start_with?(".")
                        launchagents.push(x)
                end
        end
        return launchagents
end
system_launchdaemons() click to toggle source
# File lib/marshmallow.rb, line 153
def self.system_launchdaemons
        launchdaemons=[]
        for x in Dir.entries("/Library/LaunchDaemons")
                if !x.start_with?(".")
                        launchdaemons.push(x)
                end
        end
        return launchdaemons
end
user_launchagents() click to toggle source
# File lib/marshmallow.rb, line 163
def self.user_launchagents
        users.each do |username|
                if File.exist?("/Users/#{username}/Library/LaunchAgents")
                        launchAgents=[]
                        for x in Dir.entries("/Users/#{username}/Library/LaunchAgents")
                                if !x.start_with?(".")
                                        launchAgents.push(x)
                                end
                        end
                        puts"#{username} LaunchAgents: "
                        puts launchAgents
                        puts "\n"
                else
                        puts "#{username} LaunchAgents does not exist "
                        puts "\n"
                end
        end
end
user_launchdaemons() click to toggle source
# File lib/marshmallow.rb, line 182
def self.user_launchdaemons
        users.each do |username|
                if File.exist?("/Users/#{username}/Library/LaunchDaemons")
                        launchdaemons=[]
                        for file in Dir.entries("/Users/#{username}/Library/LaunchDaemons")
                                if !file.start_with?(".")
                                        launchdaemons.push(file)
                                end
                        end
                        puts "#{username} LaunchDaemons: "
                        puts launchdaemons
                        puts "\n"
                else
                        puts "#{username} LaunchDaemons: does not exist"
                        puts "\n"
                end
        end
end
users() click to toggle source
# File lib/marshmallow.rb, line 6
def self.users
              users=[]
              Dir.entries("/Users").each do |username|
                      if !username.start_with?(".")
                              users.push(username)
                      end
              end
              users.delete("Guest")
              users.delete("Shared")
              return users
      end
uuid() click to toggle source
# File lib/marshmallow.rb, line 104
    def self.uuid
            uuid = `system_profiler SPHardwareDataType`.split("\n")
    results =  uuid.grep(/UUID:/).join(":").strip.split(":")
    results = results[1].strip
    return results
end