Jano Svitok
10/28/2006 10:49:00 AM
On 10/28/06, Jan Svitok <jan.svitok@gmail.com> wrote:
> On 10/28/06, camenix <vipeak@gmail.com> wrote:
> > Hello all,
> > I have two file :
> >
> > config.rb:
> > tool_mysql='X:/mysql.exe'
> >
> > main.rb :
> > require "config.rb"
> > puts tool_mysql
> >
> > 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?
> >
> > Is here anyone who can help me?
>
> 1.
> eval File.read('config.rb')
>
> 3. use constants:
> TOOL_MYSQL = 'dsfsdffds'
>
> puts TOOL_MYSQL
>
> 2. use global variables:
> config.rb :
> $tool_mysql = 'cxxx'
>
> puts $tool_mysql
>
> 3. use YAML for configuration:
> config.yaml:
> tool_mysql: cxdsfsdf
>
> require 'yaml'
> config = YAML.load_file('config.yaml')
> puts config['tool_mysql']
Except for the numbering ;-) Is seems I'm doing too many things at once...