Module: Marshmallow
- Defined in:
- lib/marshmallow.rb,
lib/marshmallow/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
- .apps_installed ⇒ Object
- .ard_info1 ⇒ Object
- .ard_info2 ⇒ Object
- .ard_info3 ⇒ Object
- .ard_info4 ⇒ Object
- .boot_rom ⇒ Object
- .boot_volume ⇒ Object
- .build ⇒ Object
- .computer_name ⇒ Object
- .cores ⇒ Object
- .domain_check ⇒ Object
- .fastuserswitch_check ⇒ Object
- .firewall_check ⇒ Object
- .free_space ⇒ Object
- .graphics ⇒ Object
- .hd_size ⇒ Object
- .listoflocaladmins ⇒ Object
- .loginwindow_check ⇒ Object
- .memory ⇒ Object
- .model ⇒ Object
- .model_id ⇒ Object
- .options ⇒ Object
- .os_version ⇒ Object
- .processor_name ⇒ Object
- .processor_number ⇒ Object
- .processor_speed ⇒ Object
- .profiles_all ⇒ Object
- .profiles_installed ⇒ Object
- .serial ⇒ Object
- .smc ⇒ Object
- .system_launchagents ⇒ Object
- .system_launchdaemons ⇒ Object
- .user_launchagents ⇒ Object
- .user_launchdaemons ⇒ Object
- .users ⇒ Object
- .uuid ⇒ Object
Class Method Details
.apps_installed ⇒ Object
24 25 26 27 28 29 30 31 32 |
# 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 ⇒ Object
201 202 203 204 205 206 207 208 209 |
# 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 ⇒ Object
211 212 213 214 215 216 217 218 219 |
# 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 ⇒ Object
221 222 223 224 225 226 227 228 229 |
# 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 ⇒ Object
231 232 233 234 235 236 237 238 239 |
# 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 ⇒ Object
91 92 93 94 95 |
# 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 ⇒ Object
131 132 133 134 135 |
# 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 ⇒ Object
44 45 46 |
# File 'lib/marshmallow.rb', line 44 def self.build build = `sw_vers -buildVersion`.chomp end |
.computer_name ⇒ Object
137 138 139 140 141 |
# 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 ⇒ Object
78 79 80 81 82 |
# 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 ⇒ Object
261 262 263 264 265 266 267 268 269 |
# 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 ⇒ Object
281 282 283 284 285 286 287 288 289 |
# 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 ⇒ Object
271 272 273 274 275 276 277 278 279 |
# 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 ⇒ Object
117 118 119 120 121 122 |
# 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 ⇒ Object
111 112 113 114 115 |
# 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 ⇒ Object
124 125 126 127 128 129 |
# 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 ⇒ Object
18 19 20 21 22 |
# 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 ⇒ Object
291 292 293 294 295 296 297 298 299 |
# 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 ⇒ Object
84 85 86 87 88 89 |
# 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 ⇒ Object
48 49 50 51 52 |
# 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 ⇒ Object
54 55 56 57 58 |
# 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 ⇒ Object
301 302 303 |
# File 'lib/marshmallow.rb', line 301 def self. return Marshmallow.methods(false).sort end |
.os_version ⇒ Object
40 41 42 |
# File 'lib/marshmallow.rb', line 40 def self.os_version os_version = `sw_vers -productVersion`.chomp end |
.processor_name ⇒ Object
60 61 62 63 64 |
# 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 ⇒ Object
72 73 74 75 76 |
# 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 ⇒ Object
66 67 68 69 70 |
# 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 ⇒ Object
256 257 258 259 |
# File 'lib/marshmallow.rb', line 256 def self.profiles_all profiles="profiles -C" system(profiles) end |
.profiles_installed ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# 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 ⇒ Object
34 35 36 37 38 |
# File 'lib/marshmallow.rb', line 34 def self.serial serial = `system_profiler SPHardwareDataType | awk '/Serial/'`.split(":") serial = serial[1].strip! return serial end |
.smc ⇒ Object
97 98 99 100 101 102 |
# 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 ⇒ Object
143 144 145 146 147 148 149 150 151 |
# 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 ⇒ Object
153 154 155 156 157 158 159 160 161 |
# 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 ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# 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 ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# 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 ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# 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 ⇒ Object
104 105 106 107 108 109 |
# 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 |