From: "NAKAMURA, Hiroshi" Date: 2003-12-18T17:48:23+09:00 Subject: Re: Configuration Files Hi, > From: "John W. Long" > Sent: Thursday, December 18, 2003 1:01 PM > I like this concept, but I wanted a better implementation. So I set to work > and created the attached files. The attached now enables you to do this: Interesting. > You get the idea. > > A couple of advantages that this has over the previous concept: > -- You define the default values and create the config structure at the same > time > -- Because you define a config structure if someone makes a typo in the > config file misspelling "toolbar" as "tolbar" an error will be thrown > (eventually it will even tell you what line the error was on) > -- You access the values from the config file in almost the same way that > they are written into the config file on your Config object Sorry for not related to your great work, but let me introduce mine. From the similar point of view, I wrote my own version for soap4r, too. http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/lib/soap4r/lib/soap/property.rb http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/lib/soap4r/test/soap/test_property.rb My concept is; define property tree and lock to avoid typo. And I want to "hook" property changes to reconfigure something and value-space checking. require 'soap/property' ### ## property definition # prop = SOAP::Property.new prop.add_hook("protocol.http.proxy") do |name, value| # check value here... puts "(proxy) #{name}: #{value}" end sitebag = prop["protocol.http.sites"] = SOAP::Property.new prop.lock(true) # true: locks properties cascading. sitebag.unlock # unlock sitebag property node. ### ## assigning values # prop["protocol.http.proxy"] = "myproxy:8080" prop["protocol.http.sites"] << "foo" prop["protocol.http.sites"] << "bar" p prop["protocol.http.sites.0"] # => "foo" p prop["protocol.http.sites.1"] # => "bar" p prop["protocol.http.sites"].values # => ["foo", "bar"] # typo prop["protocooool.http.proxy"] = "foo" #=> error prop["protocol.htttttp.proxy"] = "foo" #=> error prop["protocol.http.proxxxxy"] = "foo" #=> error But mine cannot read property file after property definition for now though it may be able to do easily. How do you think hooking feature of configuration files? Regards, // NaHi