It didn’t work.for main.rb can not import variable from config.rb
Is there any mothod to do this without parsing config.rb?
Using $globals or CONSTANTS is fine for simple programs, but these
pollute the global namespace.
If you really want to use ruby syntax in config.rb (rather than YAML or
other text formats), there are some alternatives:
The first one (that’s the one I wrote) doesn’t let you grab local
variables from config.rb, but it does let you access constants
(including classes and modules) and methods defined in config.rb. The
constants and methods are wrapped up in a new module and you access them
through this module. This prevents namespace pollution.
There’s a simple example at:
and some more examples in the package’s example/ dir.
You might also find these projects interesting: