Processing rc file - critical comment asked

I have already a solution for my problem, but I would be glad if some
soul could have a look on it and give suggestion for improvement…

Problem: My application can be controled by a kind of “rc file”,
various options. The options are defined using the Ruby syntax for
constants. For example:

Example rc file


There are many possible options, but of course not all of them need to
be specified.

My solution is basically to evaluate the option file and access the
constants. I am aware that this imposes a pretty high security risk,
since any Ruby code could be put into the rc file, but for my
application I can accept it - security is not a big issue in this
particular case.

An option is “set” by calling a certain function in my application.

Here is my code:

Evaluate RC file in the context of a module. The name of the

rc file is on variable rcfile.

eval(“module Rc\n”"\nend")

Now set the options according to the RC file

Scheduler.setTimeout(Rc::TIMEOUT) if Rc.const_defined?(‘TIMEOUT’);
Logger.setLogFile(Rc::LOGFILE) if Rc.const_defined?(‘LOGFILE’);
… and so on

This works fine, but I don’t like it much. It is a lot of typing for
each option, and it is easy to make a typing error:


SshConnect.setHost(Rc::REMOTEHOST) if Rc.const_defined?(‘REMOTE_HOST’)

Any idea of how I could do it better?