From: Wilbert Berendsen Date: 2003-01-26T06:18:09+09:00 Subject: datafiles as Ruby source musings -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I would like to have a Ruby program read some data- or descriptionfiles which are just Ruby code. ( ofcourse I'll look at security, etc. ), but I found some caveats: 1. snippet of datafile e.g.: - ----------------------- VAR=true OTHERVAR=false YETANOTHER=true - ---------etc.------------ module Data load "datafile" end However, the constants loaded are not defined in the scope of the module, but in the global space. I must use: module Data eval File.new ("datafile").read end or put the module definition line in the datafile as well. Which, both are not very elegant. 2. Other files which my app will need, must contain Makefile-like structures. I would rather just "load" the file, and having the Ruby interpreter take care of the parsing (example:) ALSA && ( depend "audio/alsa-driver" { |p| p.version >= 0.9 } configure << "--enable-alsa" ) where 'depend' and 'configure' are just methods in the current instance, and 'ALSA' a constant defined in a module that got included. But again using 'obj.instance_eval File.new("file").read' is the only thing I can think of. Does anybody have a nice hint or better trick to create data- or config files readable with Ruby without having to write parsers in ruby? thanks, Wilbert - -- Wilbert Berendsen (http://www.xs4all.nl/~wbsoft/) To understand recursion, one must first understand recursion. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+Mv6jx+vk367Vl7wRAtN1AKDJ+kW/jNcexLyF+WhMq+couqz5kgCfQQ0F G+Ds8Fr4rEf+ZDh4FO93CQc= =lOQk -----END PGP SIGNATURE-----