I
Ian Bridgeman
Hello all!
I have a small app/set of libraries I'm developing at work called
Sweet. I'm distributing it internally as a ruby gem, which is working
nicely. However I rather foolishly put Sweet's yaml config file in its
config/ directory, so now every time the gem gets upgraded, it wipes
out the current settings. Oops! My plan to fix this problem is to
store the config file at ~/.sweetrc, with a global config file at
/etc/sweetrc to fall back to if the home directory one isn't
available. Does this sound like a sensible solution? Or am I going
mad?
The second (and more ruby-ish) question I have is: How can I make sure
all my classes have access to the contents of the config file? My
classes all reside within the 'Sweet' module, and ideally I would like
to be able to do something along the lines of
@data_directory = Sweet::Config['data_directory']
in the initialisation method of any of my classes. Previously all of
the code was pretty much in one class, so that class just had a method
to load the yaml, but I'm doing a pretty major refactoring for Sweet
v2.
Any assistance would be greatly appreciated!
- Ian
(Instances of the words 'config file' in this email: 4)
I have a small app/set of libraries I'm developing at work called
Sweet. I'm distributing it internally as a ruby gem, which is working
nicely. However I rather foolishly put Sweet's yaml config file in its
config/ directory, so now every time the gem gets upgraded, it wipes
out the current settings. Oops! My plan to fix this problem is to
store the config file at ~/.sweetrc, with a global config file at
/etc/sweetrc to fall back to if the home directory one isn't
available. Does this sound like a sensible solution? Or am I going
mad?
The second (and more ruby-ish) question I have is: How can I make sure
all my classes have access to the contents of the config file? My
classes all reside within the 'Sweet' module, and ideally I would like
to be able to do something along the lines of
@data_directory = Sweet::Config['data_directory']
in the initialisation method of any of my classes. Previously all of
the code was pretty much in one class, so that class just had a method
to load the yaml, but I'm doing a pretty major refactoring for Sweet
v2.
Any assistance would be greatly appreciated!
- Ian
(Instances of the words 'config file' in this email: 4)