Module: YamlNormalizer::Helpers::Normalize
- Included in:
- Services::Check, Services::IsYaml, Services::Normalize
- Defined in:
- lib/yaml_normalizer/helpers/normalize.rb
Overview
This helper holds shared functionality to normalize a YAML string.
Instance Method Summary collapse
-
#normalize_yaml(yaml) ⇒ String
Transforms a given YAML string to a normalized format.
Instance Method Details
#normalize_yaml(yaml) ⇒ String
Transforms a given YAML string to a normalized format.
24 25 26 27 28 29 30 |
# File 'lib/yaml_normalizer/helpers/normalize.rb', line 24 def normalize_yaml(yaml) hashes = parse(yaml).transform hashes.map do |hash| hash.extend(Ext::SortByKey) hash.sort_by_key.to_yaml end.join end |