Module: Kubes::Compiler::Util::YamlDump

Included in:
Decorator::Hashable, Strategy::Result
Defined in:
lib/kubes/compiler/util/yaml_dump.rb

Instance Method Summary collapse

Instance Method Details

#standardize_yaml(data) ⇒ Object



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