Yams
Yams copied to clipboard
Support deserializing, editing, and serializing with preserving Anchors(`&`) and Aliases(`*`)
On current implementation, information about Anchors(&
) and Aliases(*
) are lost while compose()
.
e.g.:
import Foundation
import Yams
let node = try Yams.compose(yaml: """
aliases:
- &steps-for-linux
- checkout
- run: swift test
version: 2
jobs:
linux_swift_4.0.3:
docker:
- image: norionomura/swiftlint:swift-4.0.3
steps: *steps-for-linux
linux_swift_4.1.1:
docker:
- image: norionomura/swiftlint:swift-4.1.1
steps: *steps-for-linux
""")
let string = try Yams.serialize(node: node!)
print(string)
output:
aliases:
- - checkout
- run: swift test
version: 2
jobs:
linux_swift_4.0.3:
docker:
- image: norionomura/swiftlint:swift-4.0.3
steps:
- checkout
- run: swift test
linux_swift_4.1.1:
docker:
- image: norionomura/swiftlint:swift-4.1.1
steps:
- checkout
- run: swift test
To preserve Anchors and Aliases, it will need to introducing Node.alias(String)
.