Skip to content

Commit

Permalink
Move complex variable initializations to newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
F1248 committed Aug 18, 2024
1 parent 02f041b commit 6398915
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 43 deletions.
32 changes: 17 additions & 15 deletions OpenMacHelper/Extensions/Foundation/Measurement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,28 @@ extension Measurement {
extension UnitFrequency? {

init(_ substring: Substring?) {
self = switch substring {
case "Hz": .hertz
case "kHz": .kilohertz
case "MHz": .megahertz
case "GHz": .gigahertz
default: nil
}
self =
switch substring {
case "Hz": .hertz
case "kHz": .kilohertz
case "MHz": .megahertz
case "GHz": .gigahertz
default: nil
}
}
}

extension UnitInformationStorage? {

init(_ substring: Substring?) {
self = switch substring {
case "B": .bytes
case "KB": .kilobytes
case "MB": .megabytes
case "GB": .gigabytes
case "TB": .terabytes
default: nil
}
self =
switch substring {
case "B": .bytes
case "KB": .kilobytes
case "MB": .megabytes
case "GB": .gigabytes
case "TB": .terabytes
default: nil
}
}
}
41 changes: 21 additions & 20 deletions OpenMacHelper/Types/SystemInformation/Hardware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,30 @@ extension SystemInformation {
static let appleSiliconBased: Bool = SystemProfiler.hardware.contains(key: "chip_type")
static let intelBased: Bool = SystemProfiler.hardware.contains(key: "cpu_type")
static let isLaptop: Bool = name.hasPrefix("MacBook")
static let systemImage: String = switch name {
case _ where name.hasPrefix("MacBook"):
if #available(macOS 14, *) {
static let systemImage: String =
switch name {
case _ where name.hasPrefix("MacBook"):
if #available(macOS 14, *) {
switch identifier {
case "Mac14,7": "macbook.gen1"
case _ where identifier.hasPrefix("MacBookPro18"): "macbook.gen2"
case _ where identifier.hasPrefix("MacBook"): "macbook.gen1"
default: "macbook.gen2"
}
} else { "laptopcomputer" }
case "iMac", "iMac Pro": "desktopcomputer"
case "Mac mini": "macmini"
case "Mac Studio": if #available(macOS 13, *) { "macstudio" } else { "macmini" }
case "Mac Pro":
switch identifier {
case "Mac14,7": "macbook.gen1"
case _ where identifier.hasPrefix("MacBookPro18"): "macbook.gen2"
case _ where identifier.hasPrefix("MacBook"): "macbook.gen1"
default: "macbook.gen2"
case "MacPro3,1", "MacPro4,1", "MacPro5,1": "macpro.gen1"
case "MacPro6,1": "macpro.gen2"
default: "macpro.gen3"
}
} else { "laptopcomputer" }
case "iMac", "iMac Pro": "desktopcomputer"
case "Mac mini": "macmini"
case "Mac Studio": if #available(macOS 13, *) { "macstudio" } else { "macmini" }
case "Mac Pro":
switch identifier {
case "MacPro3,1", "MacPro4,1", "MacPro5,1": "macpro.gen1"
case "MacPro6,1": "macpro.gen2"
default: "macpro.gen3"
case "Xserve": "xserve"
case _ where name.hasPrefix("Apple Virtual Machine"): "macwindow"
default: if #available(macOS 15, *) { "desktopcomputer.and.macbook" } else { "desktopcomputer" }
}
case "Xserve": "xserve"
case _ where name.hasPrefix("Apple Virtual Machine"): "macwindow"
default: if #available(macOS 15, *) { "desktopcomputer.and.macbook" } else { "desktopcomputer" }
}
nonisolated(unsafe) static let marketingName: LocalizedStringKey? = {
guard let serialNumber = Machine.serialNumber, [11, 12].contains(serialNumber.count) else { return nil }
let url: String = """
Expand Down
17 changes: 9 additions & 8 deletions OpenMacHelper/Types/SystemInformation/Software.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ extension SystemInformation {
static let components = (SystemProfiler.software?["os_version"] as? String)?.split(separator: " ")
static let name: String? = String(components?[0])
static let version: VersionNumber? = VersionNumber(components?[1])
static let marketingName: String? = switch version?.major {
case 11: "Big Sur"
case 12: "Monterey"
case 13: "Ventura"
case 14: "Sonoma"
case 15: "Sequoia"
default: nil
}
static let marketingName: String? =
switch version?.major {
case 11: "Big Sur"
case 12: "Monterey"
case 13: "Ventura"
case 14: "Sonoma"
case 15: "Sequoia"
default: nil
}
static let build: String? = components?.last?.trimmingCharacters(in: .parentheses)
static let loaderVersion: VersionNumber? = VersionNumber(SystemProfiler.hardware?["os_loader_version"])
}
Expand Down

0 comments on commit 6398915

Please sign in to comment.