C
ChrisKaelin
I'm currently looking for a simple way to parse a configuration file
in a ruby-script. Is eval a good way to do that? YAML seems a bit an
overkill to learn for such a small task...
Thanks in advance for any suggestions.
So far I'm doing this:
the config-file:
Conf = {
'host' => 'localhost',
'title' => 'TIITEL',
'mailhost' => 'mailhost'
}
the eval-code:
begin
eval File.new(configFile).read
rescue ScriptError=>e
warn("An error occurred while reading #{$configFile}: ", e)
else
$host = Conf['host']
$title = Conf['title']
$mailhost = Conf['mailhost']
end
in a ruby-script. Is eval a good way to do that? YAML seems a bit an
overkill to learn for such a small task...
Thanks in advance for any suggestions.
So far I'm doing this:
the config-file:
Conf = {
'host' => 'localhost',
'title' => 'TIITEL',
'mailhost' => 'mailhost'
}
the eval-code:
begin
eval File.new(configFile).read
rescue ScriptError=>e
warn("An error occurred while reading #{$configFile}: ", e)
else
$host = Conf['host']
$title = Conf['title']
$mailhost = Conf['mailhost']
end