J
Joe Van Dyk
Hi,
Say I have /joe/configuration/config.rb:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
puts "this configuration file is located in this directory: " +
File.dirname( ????? )
eval File.read(File.dirname( ?????? ) + "/common.rb")
# other stuff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
common.rb is located in /joe/configuration. It also contains some Ruby cod=
e.
The main program looks something like this:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
config_file =3D ARGV.shift
eval File.read config_file
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
And I'd start the program via 'ruby main.rb /joe/configuration.rb'.
So, I have a main program that reads in a Ruby configuration file that
can also read other configuration files that are in a relative
directory. I'm having problems with the relative directory part. If
I hardcode the directory paths, everything's ok. But I don't want
/joe/configuration/config.rb to know that it's in /joe/configuration.=20
I just want that configuration file to be able to read
/joe/configuration/common.rb.
Sorry if this is confusing, let me know if I can clarify the question.
Joe
Say I have /joe/configuration/config.rb:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
puts "this configuration file is located in this directory: " +
File.dirname( ????? )
eval File.read(File.dirname( ?????? ) + "/common.rb")
# other stuff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
common.rb is located in /joe/configuration. It also contains some Ruby cod=
e.
The main program looks something like this:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
config_file =3D ARGV.shift
eval File.read config_file
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
And I'd start the program via 'ruby main.rb /joe/configuration.rb'.
So, I have a main program that reads in a Ruby configuration file that
can also read other configuration files that are in a relative
directory. I'm having problems with the relative directory part. If
I hardcode the directory paths, everything's ok. But I don't want
/joe/configuration/config.rb to know that it's in /joe/configuration.=20
I just want that configuration file to be able to read
/joe/configuration/common.rb.
Sorry if this is confusing, let me know if I can clarify the question.
Joe