Ruby ParseConfig 0.5 Released - Easily Parse Standard *Nix Style Config Files
drks — Mon, 2009-09-21 17:35
Latest update of the Ruby ParseConfig library adds a few new features, including the ability to do [grouping]. For example, reading a MySQL config file:
#!/usr/bin/ruby require('rubygems') require('parseconfig') c = ParseConfig.new('./my.cnf') puts puts "Available config groups: #{c.groups}" puts puts "config['client']['user'] => #{c.params['client']['user']}" puts "config['client']['password'] => #{c.params['client']['password']}" puts
And the output:
you@linuxbox ~] $ cat ./my.cnf [client] user=johnny password=3uS1F1eufy75 you@linuxbox ~] $ ruby ./read_my_cnf.rb Available config groups: client config['client']['user'] => johnny config['client']['password'] => 3uS1F1eufy75
The following changes have been applied.
Mon Aug 31, 2009 - v0.5 - Added sub-groups feature per RubyForge tracker [#27019]. Config files can now have [subgroups] whose values are added to a nested Hash object. - Added the write() function per RubyForge tracker [#27019]. Will print to STDOUT by default, or to a file object if passed. - Added the add(), and add_to_group() functions to support new features per RubyForge tracker [#27019]. - Thank you to Titouan Christophe for the submissions listed above! - ParseConfig.get_params() returns all params including groups. ParseConfig.get_groups() returns available sub-groups. - See the demo.rb and demo.conf files which have been updated to reflect this update. - The methods override_value() and nil_value() are now deprecated and will be removed in future versions.
Installing
The ParseConfig library is available via Ruby Gems, simply execute the following on your linux box:
you@linuxbox ~] $ sudo gem install parseconfig
Reporting Bugs or Feature Requests
Bugs and Feature Requests can be reported to the RubyForge Project Page.
More Reading About ParseConfig
For a bit of history on ParseConfig and how to use it, feel free to check out the original article I wrote:
* Ruby Configuration File Parser
* Ruby ParseConfig Demo
RSS Feed
nice
Brent Lintner (not verified) — Mon, 2010-01-18 17:08Now it is I who googles a ruby config parser and voila. Great gem, I may just utilize it, rather then write a shabby class myself lol.
Cheers,
Brent.
Thanks, your website is very
odżywki (not verified) — Mon, 2009-09-28 11:08Thanks, your website is very helpful
Post new comment