Module: Kubes::Compiler::Util::YamlDump
- Included in:
- Decorator::Hashable, Strategy::Result
- Defined in:
- lib/kubes/compiler/util/yaml_dump.rb
Instance Method Summary collapse
-
#standardize_yaml(data) ⇒ Object
stackoverflow.com/questions/24508364/how-to-emit-yaml-in-ruby-expanding-aliases/46104244#46104244 Prevents YAML from generating aliases/anchors.
- #yaml_dump(data) ⇒ Object
Instance Method Details
#standardize_yaml(data) ⇒ Object
stackoverflow.com/questions/24508364/how-to-emit-yaml-in-ruby-expanding-aliases/46104244#46104244 Prevents YAML from generating aliases/anchors.
21 22 23 24 |
# File 'lib/kubes/compiler/util/yaml_dump.rb', line 21 def standardize_yaml(data) json = data.to_json YAML.load(json) end |
#yaml_dump(data) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/kubes/compiler/util/yaml_dump.rb', line 6 def yaml_dump(data) case data when Array items = data.map do |i| standardize_yaml(i) end items.map(&:to_yaml).join("") else # single resource in YAML data = standardize_yaml(data) data.to_yaml end end |