module Chef::DSL::RenderHelpers

Public Instance Methods

render_json(hash) click to toggle source

pretty-print a hash as a JSON string

# File lib/chef/dsl/render_helpers.rb, line 25
def render_json(hash)
  JSON.pretty_generate(hash) + "\n"
end
render_toml(hash) click to toggle source

pretty-print a hash as a TOML string

# File lib/chef/dsl/render_helpers.rb, line 30
def render_toml(hash)
  Chef::DSL::Toml::Dumper.new(hash).toml_str
end
render_yaml(hash) click to toggle source

pretty-print a hash as a YAML string

# File lib/chef/dsl/render_helpers.rb, line 35
def render_yaml(hash)
  yaml_content = hash.transform_keys(&:to_s).to_yaml
  # above replaces first-level keys with strings, below the rest
  yaml_content.gsub!(" :", " ")
end