INNER CODE UNIT · Swift

save

peripheryapp/periphery · Sources/Configuration/Configuration.swift:182

    public func save(to path: FilePath = defaultConfigurationFile) throws {
        let data = try asYaml().data(using: .utf8)
        FileManager.default.createFile(atPath: path.string, contents: data)
    }

    public func load(from path: FilePath?) throws {
        guard let path = try configurationPath(withUserProvided: path) else { return }

        let encodedYAML = try String(contentsOf: path.url, encoding: .utf8)
        let yaml = try Yams.load(yaml: encodedYAML) as? [String: Any] ?? [:]
        let logger = Logger(quiet: false, verbose: false, colorMode: .never)

        for (key, value) in yaml {
            if let setting = settings.first(where: { key == $0.key }) {
                setting.assign(value)
            } else {
                logger.warn("\(path.string): invalid key '\(key)'")
            }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…