Module: Macos::Artifacts::Apps
- Defined in:
- lib/macos/artifacts/apps.rb
Class Method Summary collapse
- .appInstallLocations ⇒ Object
- .applications ⇒ Object
- .installHistory ⇒ Object
- .packagesReceipts ⇒ Object
- .userInstalledApplications ⇒ Object
Class Method Details
.appInstallLocations ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/macos/artifacts/apps.rb', line 81 def self.appInstallLocations history = `mdfind "kMDItemKind == Application"`.split("\n") puts "Application Install Locations:" history.each do |item| if ! item.start_with?("/System") puts " #{item.strip}" end end end |
.applications ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/macos/artifacts/apps.rb', line 10 def self.applications $applicationsPath = "/Applications" $applicationsDirectory = Dir.entries("#{$applicationsPath}") puts "Applications Folder:" $applicationsDirectory.sort!.each do | filename | if ! filename.start_with?(".") if File.extname(filename) == ".app" plistfile = "#{$applicationsPath}/#{filename}/Contents/Info.plist" if File.exist?("#{plistfile}") plist = CFPropertyList::List.new(:file => "#{$applicationsPath}/#{filename}/Contents/Info.plist") data = CFPropertyList.native_types(plist.value) data.each do |k,v| if k == "CFBundleShortVersionString" puts " #{$applicationsPath}/#{filename}: #{v}" end end end else if File.directory?("#{$applicationsPath}/#{filename}") puts " #{$applicationsPath}/#{filename}:" subpath = Dir.entries("#{$applicationsPath}/#{filename}") subpath.each do |subdirapp| if ! subdirapp.start_with?(".") if File.extname(subdirapp) == ".app" plist = CFPropertyList::List.new(:file => "#{$applicationsPath}/#{filename}/#{subdirapp}/Contents/Info.plist") data = CFPropertyList.native_types(plist.value) data.each do |k,v| if k == "CFBundleShortVersionString" puts " #{$applicationsPath}/#{filename}/#{subdirapp}: #{v}" end end end end end end end end end end |
.installHistory ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/macos/artifacts/apps.rb', line 61 def self.installHistory time = DateTime.now installs = `system_profiler -json SPInstallHistoryDataType`.strip data = JSON.parse(installs) puts "Software Install History:" data["SPInstallHistoryDataType"].each do |item| date = item["install_date"] parsed_date = DateTime.parse(date) installsDays = (time - parsed_date).to_i puts " Name: #{item["_name"]}" puts " Install Days: #{installsDays}" puts " Install Date: #{item["install_date"]}" puts " Version: #{item["install_version"]}" puts " Install Source: #{item["package_source"]}" puts "" end end |
.packagesReceipts ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/macos/artifacts/apps.rb', line 51 def self.packagesReceipts pkgReceipts = `pkgutil --packages`.split("\n") pkgReceipts.sort! puts "Package Receipts: " pkgReceipts.each do |pkg| puts " #{pkg.strip}" end end |
.userInstalledApplications ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/macos/artifacts/apps.rb', line 91 def self.userInstalledApplications history = `mdfind -onlyin /Users/"#{$currentUser}" 'kMDItemKind == "Application"'`.split("\n") puts "User Installed Applications:" history.each do |item| puts " #{item.strip}" end end |