Reputation: 4080
I have a ruby gem which loads config variables from a yaml file. Currently it is being parsed with YAML.load_file
. In rails it is possible to parse ruby in a yaml file like the following (e.g. settings.yaml):
key: <%= ENV["key"] || "default value" %>
What is the best way to produce a similar result in a ruby gem?
Upvotes: 0
Views: 245
Reputation: 66837
This is just ERB, so you can run your file through ERB before parsing it with YAML:
YAML.load(ERB.new(File.read(your_file_path)).result)
Upvotes: 1