better build phases

This commit is contained in:
Yonas Kolb
2017-07-23 20:58:14 +02:00
parent df19358752
commit 74f0986ffb
8 changed files with 402 additions and 279 deletions
+14
View File
@@ -8,6 +8,8 @@
import Foundation
import JSONUtilities
import PathKit
import Yams
extension Dictionary where Key: JSONKey {
@@ -46,3 +48,15 @@ public protocol NamedJSONConvertible {
init(name: String, json: Any) throws
}
extension JSONObjectConvertible {
public init(path: Path) throws {
let content: String = try path.read()
let yaml = try Yams.load(yaml: content)
guard let jsonDictionary = yaml as? JSONDictionary else {
throw JSONUtilsError.fileNotAJSONDictionary
}
try self.init(jsonDictionary: jsonDictionary)
}
}