Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for iOS13 #109

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Sources/LicensePlistCore/Entity/LicensePlistHolder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ struct LicensePlistHolder {
let root: Data
let items: [(LicenseInfo, Data)]
static func load(licenses: [LicenseInfo], options: Options) -> LicensePlistHolder {
let rootItems: [[String: String]] = licenses.map { license in
return ["Type": "PSChildPaneSpecifier",
"Title": license.name(withVersion: options.config.addVersionNumbers),
"File": "\(options.prefix)/\(license.name)"]
}
let rootItems: [[String: String]] = {
guard !licenses.isEmpty else { return [] }
return [["Type": "PSGroupSpecifier", "Title": "Licenses"]] + licenses.map { license in
return ["Type": "PSChildPaneSpecifier",
"Title": license.name(withVersion: options.config.addVersionNumbers),
"File": "\(options.prefix)/\(license.name)"]
}
}()
let root = try! PropertyListSerialization.data(fromPropertyList: ["PreferenceSpecifiers": rootItems],
format: .xml,
options: 0)
Expand Down
14 changes: 9 additions & 5 deletions Tests/LicensePlistTests/Entity/LicensePlistHolderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ class LicensePlistHolderTests: XCTestCase {
let result = LicensePlistHolder.load(licenses: [podsLicense], options: Options.empty)
let (root, items) = result.deserialized()
let rootItems = root["PreferenceSpecifiers"]!
XCTAssertEqual(rootItems.count, 1)
XCTAssertEqual(rootItems.count, 2)
XCTAssertEqual(items.count, 1)

let rootItems1 = rootItems.first!
XCTAssertEqual(rootItems1["Type"], "PSChildPaneSpecifier")
XCTAssertEqual(rootItems1["Title"], "name")
XCTAssertEqual(rootItems1["File"], "com.mono0926.LicensePlist/name")
let rootItems1 = rootItems[0]
XCTAssertEqual(rootItems1["Type"], "PSGroupSpecifier")
XCTAssertEqual(rootItems1["Title"], "Licenses")

let rootItems2 = rootItems[1]
XCTAssertEqual(rootItems2["Type"], "PSChildPaneSpecifier")
XCTAssertEqual(rootItems2["Title"], "name")
XCTAssertEqual(rootItems2["File"], "com.mono0926.LicensePlist/name")

let item1 = items.first!.1
let item1_1 = item1["PreferenceSpecifiers"]!.first!
Expand Down