Skip to content

Commit

Permalink
Merge pull request #109 from roana0229/fix-for-ios13
Browse files Browse the repository at this point in the history
Support for iOS13
  • Loading branch information
mono0926 authored Oct 1, 2019
2 parents f604e57 + 0ef9382 commit 6c5e750
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
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

0 comments on commit 6c5e750

Please sign in to comment.