From: Joel VanderWerf Date: 2001-06-18T05:13:04+09:00 Subject: [ruby-talk:16576] Re: Configuration file parsing Anders Johannsen wrote: > In article , "Dave > Thomas" wrote: > >>> Is there a preferred way of parsing configuration files in Ruby? I >>> suppose yacc/lex is ruled out? >> >> A cheap way that works in some circumstances is to write the >> configuration in Ruby, and then just require the file in: >> >> logfile { >> path "/var/log/mylog" >> days_to_expire 10 >> level :error >> } > > It may prove to be an effective solution, however, I am having trouble > figuring out how to extract the option / value pairs in the above example. > > My current solution would be to define attribute writers for path, > days_to_expire and level, thus clouding Object's namespace. > > Anders Johannsen > Here's a hack I've been using to do something of the sort: http://path.berkeley.edu/~vjoel/ruby/option-block.rb