iniparser v1.0 - read / parse INI configuration, settings and data files into a hash (incl. named subsections)


  I've updated the iniparser gem / library [1] to support "modern"
named subsections and now you can even use space as your name / value
separator in keys / properties and much more.

   The usage from the readme reads:

Option 1) `INI.load` - load from string. Example:

hash = INI.load( <<TXT )
  title = Planet Open Data News

  [Open Street Map (OSM) News]
    feed =

Option 2) `INI.load_file` - load from file (shortcut). Example:

hash = INI.load_file( './planet.ini' )

All together now. Example:

require 'iniparser'

text = <<TXT
# comment
; another comment

key1 = hello
key2 = hi!

key3 = salut    # end of line comment here

key4  = hola    ; another end of line comment here
blank =

[section3 ""]
# comment here
title  = A rose is a rose is a rose, eh?
; another comment here
title2 = A rose is a rose is a rose, eh?

hash = INI.load( text )
pp hash

resulting in:

 "section2"=>{"key4"=>"hola", "blank"=>"", "blank2"=>""},
 "section3"=>{""=>{"title"=>"A rose is a rose is a rose, eh?",
                                     "title2"=>"A rose is a rose is a
rose, eh?"}}}

to access use:

puts hash['key1']
#=> 'hello'
puts hash['key2']
#=> 'hi!'
puts hash['section1']['key3']
#=> 'salut'
puts hash['section2']['key4']
#=> 'hola'
puts hash['section2']['blank']
#=> ''
puts hash['section2']['blank2']
#=> ''
puts hash['section3']['']['title']
#=> 'A rose is a rose is a rose, eh?'
puts hash['section3']['']['title2']
#=> 'A rose is a rose is a rose, eh?'

  Cheers. Prost.

PS: The readme includes Frequently Asked Questions (FAQ) and Answers
such as
- Q: Why not use TOML (Tom's Obvious, Minimal Language)? or
- Q: Why not use IniFile - the most popular library (10+ million
downloads and counting)?