views:

41

answers:

1

I needed a little script to read data out of windows-style .ini files. Searching my windows machine I found inifile.rb in this path:

 C:\ruby\lib\ruby\site_ruby\1.8\vr\contrib\

it seems unnatural to add this path directly to my rubylib path as this will mean any other special units I want will need to be added.

so in my code I wrote this:

require 'vr/contrib/inifile'

ini = Inifile.new("file.ini")
puts ini.read("common","name","default name")

This worked, but also doesn't seem elegant for inclusion. There must be a better way to specify this in the code ?

+1  A: 

I think inifile.rb is part of vruby, which, it appears, is "a GUI library on MS Windows for Ruby". Which is something I'd never come across, so thanks!

It looks like that path is going to be necessary unless you either add it to your main Windows PATH (possible overkill) or to your Ruby load path, which you can access via the slightly arcane $:

I hope that , if only perhaps a little...

Mike Woodhouse
Mike is correct, inifile is part of vr. Unless there is a standalone version of inifile (as a library or gem) then you will be dependent of vr being installed and contained that particular version.A recommendation will be "vendorize" inifile inside your application, like vr developer did.
Luis Lavena
luis - could you explain this "vendorize" concept?
MikeJ