puppetlabs / ruby-hocon

A Ruby port of the Typesafe Config library.
Apache License 2.0
34 stars 30 forks source link

How to include a file? #87

Open colindean opened 8 years ago

colindean commented 8 years ago

I'm using ruby-hocon to construct a HOCON file.

Setting values is pretty straightforward, e.g. myconf.set_value("whatever.somewhere", "some_value"), but I'm having trouble tracking down how to set an include.

This is what I want the output to be:

top { 
  something {
    include "junk/something.conf"
  }
}

I've got this already:

doc = Hocon::Parser::ConfigDocumentFactory.parse_file("config/application.conf")

And #set_value and #set_config_value seem to work great for basic types, but I can't for the life of me figure out how to set an include within a key's context. I see that non-file includes are not supported, but have a feeling that includes are only supported in the context of reading config files, not writing them.

How can I accomplish this? I've pored over the docs and the code for about an hour and I'm coming up short 😞