class Registry
def initialize(filename)
@registry = {
"HKEY_ROOT" => [ ],
"HKEY_ROOT\\Configuration" => [ ],
"HKEY_ROOT\\Configuration\\RACK" => [ ],
"HKEY_ROOT\\Configuration\\Thin" => [ ],
"HKEY_ROOT\\Configuration\\Mongrel" => [ ],
"HKEY_ROOT\\Configuration\\WEBRick" => [ ],
"HKEY_ROOT\\Web Servers" => [ ],
"HKEY_ROOT\\Web Servers\\RACK" => [ ],
"HKEY_ROOT\\Web Servers\\Thin" => [ ],
"HKEY_ROOT\\Web Servers\\Mongrel" => [ ],
"HKEY_ROOT\\Web Servers\\WEBRick" => [ ],
}
end
def [] path
parts = path.split( "\\" )
if @registry.key?(path) == true
@registry[path]
else
my_path, tmp_path = [], []
parts.each_with_object(my_path) {
| part, thePath |
if @registry.key?(thePath.join("\\")) == false
if thePath == parts
node = @registry[tmp_path.join("\\")]
node[parts.last]
end
else
my_path << part
if @registry.key?(thePath.join("\\")) == true
tmp_path << part
end
end
puts "parts:%s tmp_path:%s my_path:%s" % [ (parts.inspect).to_s, (tmp_path).inspect, (my_path).inspect ]
part
}
raise "%s: Path does not exist." % my_path.join("\\")
end
end
end
config = Registry.new( "config" )
puts config["HKEY_ROOT\\Configuration\\RACK\\Server Port"].inspect