module Bosh::Manifest::Organizer

Constants

TOP_LEVEL_KEY_ORDER
VERSION

Public Class Methods

organize() click to toggle source
# File lib/bosh/manifest/organizer.rb, line 19
def self.organize
  str = (STDIN.tty?) ? nil : $stdin.read

  if str
    puts self.organize_yml str
  else
    raise 'Incorrect usage: cat something.yml | bosh-manifest-organizer'
  end
end
organize_yml(str) click to toggle source
# File lib/bosh/manifest/organizer.rb, line 29
def self.organize_yml(str)
  yml = YAML.load str

  new_hash = {}

  TOP_LEVEL_KEY_ORDER.each do |key|
    if yml.key? key
      new_hash[key] = yml[key]
    end
  end

  new_hash.merge!(yml)

  YAML.dump(new_hash)
end