Module: Chef::DSL::RenderHelpers
- Extended by:
- RenderHelpers
- Included in:
- RenderHelpers, Universal
- Defined in:
- lib/chef/dsl/render_helpers.rb
Instance Method Summary collapse
-
#render_json(hash) ⇒ Object
pretty-print a hash as a JSON string.
-
#render_toml(hash) ⇒ Object
pretty-print a hash as a TOML string.
-
#render_yaml(hash) ⇒ Object
pretty-print a hash as a YAML string.
Instance Method Details
#render_json(hash) ⇒ Object
pretty-print a hash as a JSON string
25 26 27 |
# File 'lib/chef/dsl/render_helpers.rb', line 25 def render_json(hash) JSON.pretty_generate(hash) + "\n" end |
#render_toml(hash) ⇒ Object
pretty-print a hash as a TOML string
30 31 32 |
# 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) ⇒ Object
pretty-print a hash as a YAML string
35 36 37 38 39 |
# 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 |