From c99165a51daddcf310eb4f6fce3c14eea491a6e8 Mon Sep 17 00:00:00 2001 From: Masayuki Ono Date: Sat, 20 May 2017 20:44:47 +0900 Subject: [PATCH 1/3] Update Paw --- LicensePlist.paw | Bin 14376 -> 17657 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/LicensePlist.paw b/LicensePlist.paw index 2a636391ea88a30971a31129823443dfdef622e9..c5f7880013dec52c75ec7029114e1d8ae13a2dbc 100644 GIT binary patch delta 8846 zcmaKS33wA#_x@cbP1`i>G)Y66q)nTqNz*b-CVO0PLs^8f6p*zgD-=o#T>#l~%c6n{ zLO@hdp&%lnfS?GXhzeRkWDyV)1x4IG#T^0p_}!T{P4)jhfBHcg3rL!a1C4!pM#s>7Pu9@ z0(Zi_@NKvcegF@{Bk(vp3(vvx@N4)z{2BfZuOomkVo(~&LQ0g649JLzPzfqWHsnNo zP+!y^#VXJMREdV5k!TdELLoE}HK3{JA@neM6fHqZ(F*hwT7x#B7tt296}^gfpgrg< zv={9|ZRiL(ijJex=qx&qE~1~&Z|HaQ7rKm7uoS1`ES!ULu?ZLB5^Tlg*oA$#0uR80 zaU~vtN8oB4!gVoRj~j3!o{s0>x%grH2wsAh;uZKQyasQ=FXAnDD}EL4z&uKKjYu<@Axvl&R`~!$zl|YlF=}^Od(@r%uFfcV4RGHxskbz zxsw^l3}S{bLz$7xSSHNWGm{xr<4{vwb8YQ0kOtC$3}k>(&^vw`(!;!X6)MjFCQuB_ zzyeBuHU1DP&my@*OLRm}@<{$>HZR_Wj4^N%xEb^Sw@}sH25tv;fS%w^a2M!B48%ch zB0WhzGK`EN5mHa4kvU`md4$BtDzcWmNVb!mHy|&;sV(Q&D+aLqp)+;T4qwf)gU4 zruLti4;I9EMiZM4?gMj2S5)?_2{qN!*998xZU4OwfK{7WC0Ga+0TpBPuG(8=D$x>c)|> z_@hb5kH#8>tk(zm`7U2Ez-@gq_j?f)8K9q;LYS#;!L1A z1HKSYeNK9;0cXiA|36UY1yEX&l>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?@lRL*Bxt@@@I{d`G@B-;3|d_vf?tY<>_wiqGZ8^7;HkemTFAU&XKC*YWH54SX%X zncvE9!l6Of=0v;rdtLW1BBWWgmQ z3y%rigx*45pi1RC*n`VpNT&k z|8@M2@&B5j37aBJk)|k9w8>zKF*Py8n&M20O{+|6OovPtO_xlUO;=1;O}9*UOm|Jc znjV-Qnt>UcBg~Oz&McXmnVsh5<|K29xrMovIn~_O95AmluQwmD^tI$###-_%g_a^q zg=Mm(+A`fzLaZYnru(wU@PzwVyS|I@CJc zI?`HTt+Y9gwa% zkVACDJIsy*ht2Vrqm?7o(azDq(aDkKNO$yd^l=Pyukg7dQTiu0=Tn)9afuJc#t1Ls2-$XJe$ zBV|rD%L%egmgHu#-zhhj+sR$!?sAblU9OS+@=STQyhIMjE96!38hM?(McyWFmv_kf z<)iY)@^Sfud`dnepOw$c7v)RMyEpICykGN4u9dD=T{~U7Tzgz~uJ>JsT}NCWyNq@#6Ac3B+8|J`+eI8HWN>6Fv>XRhq|GoPJd}+f2={=g&-A)?@1IN>v nX_~uc&8Bl*F)*vgw@s#?nP@eg!|$a#;{`fve;AmOKI{Jg9S$D? From 9d8ca6cd9bd9e00a1e3a8e6eaaddc97a7a04499e Mon Sep 17 00:00:00 2001 From: Masayuki Ono Date: Sat, 20 May 2017 20:46:18 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Use=20GitHub=20API=E2=80=99s=20response=20c?= =?UTF-8?q?ontent(base64=20encoded)=20instead=20of=20downloadUrl,=20which?= =?UTF-8?q?=20requires=20network=20request=20to=20fetch=20body.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - https://developer.github.com/v3/repos/contents/#get-contents - https://developer.github.com/v3/repos/contents/#custom-media-types --- .../LicensePlistCore/Entity/GitHubLicense.swift | 2 +- .../GitHubClient/RepoRequests.swift | 13 +++++++++++-- .../Entity/GitHubLicense.collectorTests.swift | 4 ---- .../Entity/PlistInfoTests.swift | 16 ++++++++++++---- .../GitHubClient/RepoRequestsTests.swift | 10 +++------- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Sources/LicensePlistCore/Entity/GitHubLicense.swift b/Sources/LicensePlistCore/Entity/GitHubLicense.swift index 3c41e1f1..0a49faed 100644 --- a/Sources/LicensePlistCore/Entity/GitHubLicense.swift +++ b/Sources/LicensePlistCore/Entity/GitHubLicense.swift @@ -56,7 +56,7 @@ extension GitHubLicense { } case .success(let response): let license = GitHubLicense(library: library, - body: response.downloadUrl.lp.download().resultSync().value!, + body: response.contentDecoded, githubResponse: response) return Result(value: license) } diff --git a/Sources/LicensePlistCore/GitHubClient/RepoRequests.swift b/Sources/LicensePlistCore/GitHubClient/RepoRequests.swift index 18a96421..7d301147 100644 --- a/Sources/LicensePlistCore/GitHubClient/RepoRequests.swift +++ b/Sources/LicensePlistCore/GitHubClient/RepoRequests.swift @@ -33,13 +33,22 @@ struct RepoRequests { } struct LicenseResponse { - let downloadUrl: URL + let content: String + let contentDecoded: String + let encoding: String let kind: LicenseKindResponse } extension LicenseResponse: Decodable { static func decode(_ e: Extractor) throws -> LicenseResponse { - return try LicenseResponse(downloadUrl: URL(string: e.value("download_url"))!, kind: e.value("license")) + let content: String = try e.value("content") + let encofing: String = try e.value("encoding") + assert(encofing == "base64") + let contentDecoded = String(data: Data(base64Encoded: content, options: [.ignoreUnknownCharacters])!, encoding: .utf8)! + return try LicenseResponse(content: content, + contentDecoded: contentDecoded, + encoding: encofing, + kind: e.value("license")) } } diff --git a/Tests/LicensePlistTests/Entity/GitHubLicense.collectorTests.swift b/Tests/LicensePlistTests/Entity/GitHubLicense.collectorTests.swift index 812d89dc..e82c9893 100644 --- a/Tests/LicensePlistTests/Entity/GitHubLicense.collectorTests.swift +++ b/Tests/LicensePlistTests/Entity/GitHubLicense.collectorTests.swift @@ -15,8 +15,6 @@ class GitHubLicenseTests: XCTestCase { let license = GitHubLicense.download(carthage).resultSync().value! XCTAssertEqual(license.library, carthage) XCTAssertTrue(license.body.hasPrefix("MIT License")) - XCTAssertEqual(license.githubResponse.downloadUrl, - URL(string: "https://raw.githubusercontent.com/mono0926/NativePopup/master/LICENSE")) XCTAssertEqual(license.githubResponse.kind.spdxId, "MIT") } @@ -27,8 +25,6 @@ class GitHubLicenseTests: XCTestCase { forked.owner = "adjust" XCTAssertEqual(license.library, forked) XCTAssertTrue(license.body.hasPrefix("Copyright (c)")) - XCTAssertEqual(license.githubResponse.downloadUrl, - URL(string: "https://raw.githubusercontent.com/adjust/ios_sdk/master/MIT-LICENSE")) XCTAssertEqual(license.githubResponse.kind.spdxId, "MIT") } func testCollect_invalid() { diff --git a/Tests/LicensePlistTests/Entity/PlistInfoTests.swift b/Tests/LicensePlistTests/Entity/PlistInfoTests.swift index 4d0d70be..0f60e8e0 100644 --- a/Tests/LicensePlistTests/Entity/PlistInfoTests.swift +++ b/Tests/LicensePlistTests/Entity/PlistInfoTests.swift @@ -100,7 +100,9 @@ class PlistInfoTests: XCTestCase { let github = GitHub(name: "LicensePlist", nameSpecified: nil, owner: "mono0926", version: nil) let githubLicense = GitHubLicense(library: github, body: "body", - githubResponse: LicenseResponse(downloadUrl: URL(fileURLWithPath: ""), + githubResponse: LicenseResponse(content: "", + contentDecoded: "", + encoding: "", kind: LicenseKindResponse(name: "name", spdxId: nil))) target.cocoaPodsLicenses = [] @@ -120,7 +122,9 @@ class PlistInfoTests: XCTestCase { let github = GitHub(name: "LicensePlist", nameSpecified: nil, owner: "mono0926", version: nil) let githubLicense = GitHubLicense(library: github, body: "body", - githubResponse: LicenseResponse(downloadUrl: URL(fileURLWithPath: ""), + githubResponse: LicenseResponse(content: "", + contentDecoded: "", + encoding: "", kind: LicenseKindResponse(name: "name", spdxId: nil))) target.licenses = [githubLicense] @@ -132,7 +136,9 @@ class PlistInfoTests: XCTestCase { let github = GitHub(name: "LicensePlist", nameSpecified: nil, owner: "mono0926", version: nil) let githubLicense = GitHubLicense(library: github, body: "body", - githubResponse: LicenseResponse(downloadUrl: URL(fileURLWithPath: ""), + githubResponse: LicenseResponse(content: "", + contentDecoded: "", + encoding: "", kind: LicenseKindResponse(name: "name", spdxId: nil))) target.githubLibraries = [github] @@ -145,7 +151,9 @@ class PlistInfoTests: XCTestCase { let github = GitHub(name: "LicensePlist", nameSpecified: nil, owner: "mono0926", version: nil) let githubLicense = GitHubLicense(library: github, body: "body", - githubResponse: LicenseResponse(downloadUrl: URL(fileURLWithPath: ""), + githubResponse: LicenseResponse(content: "", + contentDecoded: "", + encoding: "", kind: LicenseKindResponse(name: "name", spdxId: nil))) target.githubLibraries = [github] diff --git a/Tests/LicensePlistTests/GitHubClient/RepoRequestsTests.swift b/Tests/LicensePlistTests/GitHubClient/RepoRequestsTests.swift index 7a778fe0..3e7fa7b0 100644 --- a/Tests/LicensePlistTests/GitHubClient/RepoRequestsTests.swift +++ b/Tests/LicensePlistTests/GitHubClient/RepoRequestsTests.swift @@ -13,9 +13,7 @@ class RepoRequestsTests: XCTestCase { let result = Session.shared.lp.sendSync(request) switch result { case .success(let response): - XCTAssertEqual( - response.downloadUrl, - URL(string: "https://raw.githubusercontent.com/mono0926/NativePopup/master/LICENSE")!) + XCTAssertTrue(response.contentDecoded.hasPrefix("MIT License")) case .failure(let error): XCTFail(String(describing: error)) } @@ -41,9 +39,7 @@ class RepoRequestsTests: XCTestCase { queue.addOperations([o1, o2], waitUntilFinished: true) let result = [o1.result!.value!, o2.result!.value!] XCTAssertEqual(result.count, 2) - XCTAssertEqual(result[0].downloadUrl, - URL(string: "https://raw.githubusercontent.com/mono0926/NativePopup/master/LICENSE")!) - XCTAssertEqual(result[1].downloadUrl, - URL(string: "https://raw.githubusercontent.com/ReactiveX/RxSwift/master/LICENSE.md")!) + XCTAssertTrue(result[0].contentDecoded.hasPrefix("MIT License")) + XCTAssertTrue(result[1].contentDecoded.hasPrefix("**The MIT License**")) } } From fc9e110e9ccdc89b639c014f06007e1e5e05e520 Mon Sep 17 00:00:00 2001 From: Masayuki Ono Date: Sat, 20 May 2017 20:48:09 +0900 Subject: [PATCH 3/3] Swiftlint --- .swiftlint.yml | 2 +- Sources/LicensePlist/main.swift | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 49b50f7d..22a4b8e0 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -8,4 +8,4 @@ included: - Sources - Tests -line_length: 140 +line_length: 150 diff --git a/Sources/LicensePlist/main.swift b/Sources/LicensePlist/main.swift index 512cb3e1..f6784ace 100644 --- a/Sources/LicensePlist/main.swift +++ b/Sources/LicensePlist/main.swift @@ -17,14 +17,13 @@ let main = command(Option("cartfile-path", Consts.cartfileName), Option("config-path", Consts.configPath), Flag("force"), Flag("add-version-numbers"), - Flag("suppress-opening-directory")) { - cartfile, podsPath, output, gitHubToken, configPath, force, version, suppressOpeningDirectory in + Flag("suppress-opening-directory")) { cartfile, podsPath, output, gitHubToken, configPath, force, version, suppressOpen in Logger.configure() var config = loadConfig(configPath: URL(fileURLWithPath: configPath)) config.force = force config.addVersionNumbers = version - config.suppressOpeningDirectory = suppressOpeningDirectory + config.suppressOpeningDirectory = suppressOpen let options = Options(outputPath: URL(fileURLWithPath: output), cartfilePath: URL(fileURLWithPath: cartfile), podsPath: URL(fileURLWithPath: podsPath),