Created
October 26, 2025 22:29
-
-
Save SamSaffron/e48b5773236501ada6d11c916cd932b8 to your computer and use it in GitHub Desktop.
yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require "psych" | |
| require "psych/pure" | |
| yaml_source = <<~YAML | |
| hierarchy: | |
| - name: "osfamily/major release" | |
| paths: | |
| # Comment above first item | |
| - "path/one.yaml" | |
| - "path/two.yaml" | |
| # Comment above third item | |
| - path/three.yaml | |
| - name: "osfamily" | |
| paths: | |
| - "path/four.yaml" | |
| - "path/five.yaml" | |
| YAML | |
| puts "=== Original YAML ===" | |
| puts yaml_source | |
| config = | |
| Psych::Pure.load( | |
| yaml_source, | |
| comments: true, | |
| aliases: true, | |
| permitted_classes: [Symbol, Date, Time, Set] | |
| ) | |
| puts "\n=== After Load + Dump ===" | |
| dumped = Psych::Pure.dump(config) | |
| puts dumped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment