Skip to content

Commit

Permalink
Merge pull request #10 from cats-oss/v0.0.7
Browse files Browse the repository at this point in the history
Supports cocoaapods-binary
  • Loading branch information
ra1028 authored Jul 12, 2019
2 parents eefea06 + d1b3210 commit a4a356d
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ before_install:
- gem install xcpretty
script:
- swift build
- swift test 2>&1 | xcpretty
- swift test
notifications:
email: false
2 changes: 1 addition & 1 deletion AcknowledgementsPlist.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'AcknowledgementsPlist'
s.version = '0.0.6'
s.version = '0.0.7'
s.summary = 'AcknowledgementsPlist manages the licenses of libraries that depend on your iOS app.'
s.homepage = 'https://github.com/cats-oss/AcknowledgementsPlist'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
2 changes: 1 addition & 1 deletion Sources/AcknowledgementsPlistCore/Models/License.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct License: LicenseType {
public struct License: LicenseType, Hashable {

private enum Key {
static let title = "Title"
Expand Down
2 changes: 1 addition & 1 deletion Sources/AcknowledgementsPlistCore/Models/LicenseLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct LicenseLink: LicenseType {
public struct LicenseLink: LicenseType, Hashable {

private enum Name {
static let plist = "AcknowledgementLinks.plist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ extension LicenseURLsMakable {
} else {
podsDirURL = URL(string: options.podsPath)
}
guard let url = podsDirURL else { return [] }
return try getLicenseURLs(dirURL: url)

return try podsDirURL.map { url in
let podsBinaryDirURL = url.appendingPathComponent("/_Prebuild", isDirectory: true)
return try getLicenseURLs(dirURL: url) + getLicenseURLs(dirURL: podsBinaryDirURL)
} ?? []
}

private func getCarthageLicenseURLs() throws -> [URL] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ extension LicensesMakable {
let carthageLicenses = try getLicenses(licenseURLs: carthageLicenseURLs)
let manualPlistLicenses = try getManualPlistLicenses().map { License(object: $0) }
let manualLicenses = try getLicenses(licenseURLs: manualLicenseURLs)
return (podsLicenses + carthageLicenses + manualPlistLicenses + manualLicenses)
return Set(podsLicenses + carthageLicenses + manualPlistLicenses + manualLicenses)
.sorted(by: { $0.title < $1.title })
}

public func makeLicenseLinks() throws -> [LicenseType] {
let podsLicenseLinks = getLicenseLinks(licenseURLs: podsLicenseURLs)
let carthageLicenseLinks = getLicenseLinks(licenseURLs: carthageLicenseURLs)
let manualLicenseLinks = try getManualPlistLicenses().map { LicenseLink(object: $0) }
return (podsLicenseLinks + carthageLicenseLinks + manualLicenseLinks).sorted(by: { $0.title < $1.title })
return Set(podsLicenseLinks + carthageLicenseLinks + manualLicenseLinks)
.sorted(by: { $0.title < $1.title })
}

private func getLicenses(licenseURLs: [URL]) throws -> [License] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CCC
CCC
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DDD
DDD

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
CCC
CCC
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DDD
DDD

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ import XCTest
@testable import AcknowledgementsPlistCore

class LicensesMakableTests: XCTestCase, LicensesMakable {

var options: Options = .init(projectRootPath: "",
outputPlistPath: "",
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
var podsLicenseURLs: [URL] = []
var carthageLicenseURLs: [URL] = []
var manualLicenseURLs: [URL] = []

func testNotAllLicenses() {
options = .init(projectRootPath: "",
outputPlistPath: "",
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = []
carthageLicenseURLs = []
Expand All @@ -41,7 +43,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) }
guard let licenses = try? makeLicenses() as? [License] else {
Expand All @@ -58,7 +61,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) }
guard let licenses = try? makeLicenses() as? [License] else {
Expand All @@ -75,7 +79,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) }
carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) }
Expand All @@ -93,7 +98,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: ConstMocks.manualAcknowledgementsPath,
manualPlistPath: ConstMocks.manualAcknowledgementsPath,
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) }
carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) }
Expand All @@ -111,7 +117,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "foo",
manualPlistPath: "foo",
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) }
carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) }
Expand All @@ -124,7 +131,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = []
carthageLicenseURLs = []
Expand All @@ -138,7 +146,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) }
guard let licenseLinks = try? makeLicenseLinks() as? [LicenseLink] else {
Expand All @@ -155,7 +164,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) }
guard let licenses = try? makeLicenseLinks() as? [LicenseLink] else {
Expand All @@ -172,7 +182,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "",
manualPlistPath: "",
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) }
carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) }
Expand All @@ -190,7 +201,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: ConstMocks.manualAcknowledgementsPath,
manualPlistPath: ConstMocks.manualAcknowledgementsPath,
manualLicenseFilesPath: "",
excludeWordArray: [])
podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) }
carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) }
Expand All @@ -208,10 +220,11 @@ class LicensesMakableTests: XCTestCase, LicensesMakable {
outputBundlePath: "",
podsPath: "",
carthageCheckoutsPath: "",
manualAcknowledgementsPath: "bar",
manualPlistPath: "",
manualLicenseFilesPath: "bar",
excludeWordArray: [])
podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) }
carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) }
XCTAssertThrowsError(try makeLicenseLinks())
XCTAssertNoThrow(try makeLicenseLinks())
}
}

0 comments on commit a4a356d

Please sign in to comment.