public protocol AppCategorizer {
|
func category(for app: AlignerApp) -> AppCategory
|
}
|
|
public struct BundleIDAppCategorizer: AppCategorizer {
|
private let mappings: [String: AppCategory]
|
|
public init(mappings: [String: AppCategory] = BundleIDAppCategorizer.defaultMappings) {
|
self.mappings = mappings
|
}
|
|
public func category(for app: AlignerApp) -> AppCategory {
|
mappings[app.bundleIdentifier] ?? app.category
|
}
|
|
public static let defaultMappings: [String: AppCategory] = [
|
"com.apple.finder": .finder,
|
"com.google.Chrome": .browser,
|
"company.thebrowser.Browser": .browser,
|
"com.apple.Safari": .browser,
|
"org.mozilla.firefox": .browser,
|
"com.apple.Terminal": .terminal,
|
"com.googlecode.iterm2": .terminal,
|
"com.microsoft.VSCode": .editorIDE,
|
"com.todesktop.230313mzl4w4u92": .editorIDE,
|
"com.apple.dt.Xcode": .editorIDE
|
]
|
}
|