equal
deleted
inserted
replaced
37 import platform.Foundation.dataWithContentsOfURL |
37 import platform.Foundation.dataWithContentsOfURL |
38 import kotlin.coroutines.resume |
38 import kotlin.coroutines.resume |
39 import kotlin.coroutines.resumeWithException |
39 import kotlin.coroutines.resumeWithException |
40 import kotlin.coroutines.suspendCoroutine |
40 import kotlin.coroutines.suspendCoroutine |
41 |
41 |
|
42 /** |
|
43 * Parse LicensePlist files |
|
44 */ |
42 class LicensePlistParser { |
45 class LicensePlistParser { |
43 |
46 |
|
47 /** |
|
48 * Parse LicensePlist files |
|
49 * |
|
50 * @param licensePlistInput url of com.mono0926.LicensePlist.plist file |
|
51 * @return a map of dependency name to license |
|
52 */ |
44 @Suppress("UNCHECKED_CAST") |
53 @Suppress("UNCHECKED_CAST") |
45 suspend fun parseLicenses( |
54 suspend fun parseLicenses( |
46 licensePlistInput: NSURL |
55 licensePlistInput: NSURL |
47 ): Map<String, String> { |
56 ): Map<String, String> { |
48 val fileContent = getContent(licensePlistInput) |
57 val fileContent = getContent(licensePlistInput) |
93 } |
102 } |
94 cont.resume(parsed!!) |
103 cont.resume(parsed!!) |
95 } |
104 } |
96 |
105 |
97 companion object { |
106 companion object { |
|
107 /** |
|
108 * Get url of the default LicensePlist file |
|
109 */ |
98 fun getDefaultLicensePlistUrl(): NSURL { |
110 fun getDefaultLicensePlistUrl(): NSURL { |
99 val path = NSBundle.mainBundle.pathForResource( |
111 val path = NSBundle.mainBundle.pathForResource( |
100 "com.mono0926.LicensePlist", |
112 "com.mono0926.LicensePlist", |
101 ofType = "plist", |
113 ofType = "plist", |
102 inDirectory = "licenseplist" |
114 inDirectory = "licenseplist" |