Closed kolia closed 8 years ago
I'm not sure there's any good reason not to call Hocon::ConfigFactory.load_file
from Hocon.load
. At a glance it seems like that would be much more intuitive behavior.
We should create an issue in our issue tracker, do a little investigation, and then we can probably get that work knocked out soon-ish.
@kolia The intention in typesafehub's original HOCON library is that all configuration loading and parsing is done directly from the ConfigFactory
class. In that class, the parse
methods create a ConfigValue and do nothing else, whereas the load
methods perform a higher-level operation that resolves all configuration.
Hocon.load
is our own function, and isn't present in the upstream library. I definitely think that function should be calling the load_file
method, but instead it's calling parse_file
. I'll go ahead and change that, and update some documentation to make things a little bit clearer.
This should be fixed as of HOCON 0.9.4
1.0.1 should contain this fix as well.
Calling
Hocon.load
on a file containing a substitution such as:throws an error, and trying some other obvious things don't work either:
1- calling
Hocon::ConfigFactory.parse_file(filename)
works, but theSimpleConfig
object that gets returned has no render method.2- calling
Hocon::Parser::ConfigDocumentFactory.parse_file(filename).resolve()
works and has arender
method, but does not have aresolve
method, so the rendered string show the value ofb
as being${a}
.What does work is:
Hocon::ConfigFactory.load_file('test.conf').root()
Which leads me to the issue:
Could the README or the API docs have a paragraph on how to parse config containing substitutions, resolve those substitutions, and then allow you to render the resolved config? Also, is there any reason why Hocon.load does not do this?